diff options
Diffstat (limited to 'lib/sisu/develop/txt_textile.rb')
-rw-r--r-- | lib/sisu/develop/txt_textile.rb | 236 |
1 files changed, 27 insertions, 209 deletions
diff --git a/lib/sisu/develop/txt_textile.rb b/lib/sisu/develop/txt_textile.rb index 4aa9c87f..d777587e 100644 --- a/lib/sisu/develop/txt_textile.rb +++ b/lib/sisu/develop/txt_textile.rb @@ -60,12 +60,16 @@ module SiSU_Txt_Textile include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb + require_relative 'txt_textile_decorate' # txt_textile_decorate.rb + require_relative 'txt_output' # txt_output.rb include SiSU_Param - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source - include SiSU_Parts_Generic + include SiSU_Txt_Read + #include SiSU_Parts_Generic def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -75,46 +79,13 @@ module SiSU_Txt_Textile def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Textile (plaintext utf-8)', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Textile (plaintext utf-8)', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "#{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}" - ).flow - end - end - ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - wrap_width=if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - env.plaintext_wrap - else 78 - end - #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Txt_Textile::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'Textile (plaintext utf-8)', + output_path: md.file.output_path.textile.dir, + output_file: md.file.base_filename.textile, + } + read_generic(@opt,specific) + SiSU_Txt_Textile::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -126,6 +97,7 @@ module SiSU_Txt_Textile class Scroll <Source include SiSU_Parts_Generic include SiSU_TextUtils + include SiSU_Decorate_Txt_Textile @@endnotes={ para: [], end: [] } def initialize(md,data,wrap_width) @md,@data,@wrap_width=md,data,wrap_width @@ -222,143 +194,19 @@ at: * SiSU #{the_url.sisu_txt} WOK end - def decorate - def heading - def inline - def l0 - 'h1. ' - end - def l1 - 'h2. ' - end - def l2 - 'h3. ' - end - def l3 - 'h4. ' - end - def l4 - 'h5. ' - end - def l5 - 'h6. ' - end - self - end - self - end - def bold - def open - '*' - end - def close - '*' - end - self - end - def italics - def open - '_' - end - def close - '_' - end - self - end - def underscore - def open - '+' - end - def close - '+' - end - self - end - #def emphasis - # def open - # '' - # end - # def close - # '' - # end - # self - #end - def cite - def open - '"' - end - def close - '"' - end - self - end - def insert - def open - '' - end - def close - '' - end - self - end - def strike - def open - '-' - end - def close - '-' - end - self - end - def superscript - def open - '^' - end - def close - '^' - end - self - end - def subscript - def open - '~' - end - def close - '~' - end - self - end - def hilite - def open - '*' - end - def close - '*' - end - self - end - def monospace - def open - '' - end - def close - '' - end - self - end - self - end def heading_decorated_inline(dob) - heading_inline = case dob.lc - when 0 then decorate.heading.inline.l0 - when 1 then decorate.heading.inline.l1 - when 2 then decorate.heading.inline.l2 - when 3 then decorate.heading.inline.l3 - when 4 then decorate.heading.inline.l4 - when 5 then decorate.heading.inline.l5 - when 6 then decorate.heading.inline.l6 + if dob.is==:heading + heading_inline = case dob.lc + when 0 then decorate.heading.inline.l0 + when 1 then decorate.heading.inline.l1 + when 2 then decorate.heading.inline.l2 + when 3 then decorate.heading.inline.l3 + when 4 then decorate.heading.inline.l4 + when 5 then decorate.heading.inline.l5 + when 6 then decorate.heading.inline.l6 + end + heading_inline + ' ' + dob.obj end - heading_inline + ' ' + dob.obj end def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document util=nil @@ -509,41 +357,11 @@ WOK content << plaintext[:metadata] content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? content << plaintext[:tail] - Output.new(content,@md).textile + outputfile=SiSU_Env::FileOp.new(@md).write_file.textile + Txt_Output::Output.new.document(content,outputfile) @@endnotes={ para: [], end: [] } end end - class Output <Source - include SiSU_Param - include SiSU_Env - def initialize(content,md) - @content,@md=content,md - end - def textile - file_plaintext=SiSU_Env::FileOp.new(@md).write_file.textile - @sisu=[] - emptyline=0 - @content.each do |para| # this is a hack - if para.is_a?(Array) \ - and para.length > 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - file_plaintext.puts line - end - end - end - else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_plaintext.close - end - end end end __END__ |