diff options
Diffstat (limited to 'lib/sisu/v5/plaintext.rb')
-rw-r--r-- | lib/sisu/v5/plaintext.rb | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/lib/sisu/v5/plaintext.rb b/lib/sisu/v5/plaintext.rb index b82013aa..49c198e7 100644 --- a/lib/sisu/v5/plaintext.rb +++ b/lib/sisu/v5/plaintext.rb @@ -133,13 +133,15 @@ module SiSU_Plaintext when /--endnote/; true else true end - @br="\n" @plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } end def songsheet plaintext=markup(@data) publish(plaintext) end + def break_line + "\n" + end # Used for extraction of endnotes from paragraphs def extract_endnotes(dob='') notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) @@ -198,18 +200,18 @@ WOK lastdone="Last Generated on: #{Time.now}" rubyv="Ruby version: #{@md.ruby_version}" sc=if @md.sc_info - "Source file: #{@md.sc_filename}#{@br}Version number: #{@md.sc_number}#{@br}Version date: #{@md.sc_date}#{@br}" + "Source file: #{@md.sc_filename}#{break_line}Version number: #{@md.sc_number}#{break_line}Version date: #{@md.sc_date}#{break_line}" else '' end @plaintext[:tail] <<<<WOK -#{@br} +#{break_line} plaintext (plain text): - #{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}#{@br} -Other versions of this document: #{@br} + #{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}#{break_line} +Other versions of this document: #{break_line} manifest: - #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{@br} + #{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}#{break_line} at: - #{@md.file.output_path.base.url}#{@br} + #{@md.file.output_path.base.url}#{break_line} #{sc} * #{generator} @@ -376,19 +378,19 @@ WOK times=wrapped.length times=@wrap_width if times > @wrap_width @plaintext[:body] << case lv - when 1; wrapped.upcase << @br << decorate.heading_underscore.l1*times + p_num << @br*2 - when 2; wrapped.upcase << @br << decorate.heading_underscore.l2*times + p_num << @br*2 - when 3; wrapped.upcase << @br << decorate.heading_underscore.l3*times + p_num << @br*2 - when 4; wrapped.upcase << @br << decorate.heading_underscore.l4*times + p_num << @br*2 - when 5; wrapped.upcase << @br << decorate.heading_underscore.l5*times + p_num << @br*2 - when 6; wrapped.upcase << @br << decorate.heading_underscore.l6*times + p_num << @br*2 + when 1; wrapped.upcase << break_line << decorate.heading_underscore.l1*times + p_num << break_line*2 + when 2; wrapped.upcase << break_line << decorate.heading_underscore.l2*times + p_num << break_line*2 + when 3; wrapped.upcase << break_line << decorate.heading_underscore.l3*times + p_num << break_line*2 + when 4; wrapped.upcase << break_line << decorate.heading_underscore.l4*times + p_num << break_line*2 + when 5; wrapped.upcase << break_line << decorate.heading_underscore.l5*times + p_num << break_line*2 + when 6; wrapped.upcase << break_line << decorate.heading_underscore.l6*times + p_num << break_line*2 end else - @plaintext[:body] << wrapped + p_num << @br # main text, contents, body KEEP + @plaintext[:body] << wrapped + p_num << break_line # main text, contents, body KEEP end if @@endnotes[:para] \ and not @@endnotes_ - @@endnotes[:para].each {|e| @plaintext[:body] << e << @br} + @@endnotes[:para].each {|e| @plaintext[:body] << e << break_line} elsif @@endnotes[:para] \ and @@endnotes_ end @@ -403,7 +405,7 @@ WOK plaintext_metadata table_message='[table omitted, see other document formats]' data.each do |dob| - dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}"). #fix + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{break_line}#{table_message}"). #fix gsub(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,''). # remove dummy headings (used by html) #check also [~-]# gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, "#{decorate.bold.open}\\1#{decorate.bold.close}"). @@ -449,8 +451,8 @@ WOK end dob.obj=if dob.of==:block # watch dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/m,"* "). - gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,@br) - else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,@br*2) + gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line) + else dob.obj.gsub(/\n?#{Mx[:br_line]}\n?|\n?#{Mx[:br_nl]}\n?/m,break_line*2) end if dob.is==:code dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< @@ -479,17 +481,17 @@ WOK or dob.is==:verse \ or dob.is==:code \ or dob.is==:table - @plaintext[:body] << dob.obj + p_num << @br + @plaintext[:body] << dob.obj + p_num << break_line elsif dob.is==:break sp=' ' ln='-' @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ or dob.obj==Mx[:br_page_new] \ or dob.obj==Mx[:br_page_line] - "#{@br}#{ln*40}#{@br*2}" + "#{break_line}#{ln*40}#{break_line*2}" elsif dob.obj ==Mx[:br_obj] - "#{@br}#{sp*20}* * *#{@br*2}" - end # following empty line (@br) missing, fix + "#{break_line}#{sp*20}* * *#{break_line*2}" + end # following empty line (break_line) missing, fix end dob='' if (dob.obj =~/<a name="n\d+">/ \ and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote @@ -508,9 +510,9 @@ WOK content << plaintext[:head] content << plaintext[:body] content << @@endnotes[:end] if @@endnotes_ - content << "#{@br}#{divider*@wrap_width}#{@br}" + content << "#{break_line}#{divider*@wrap_width}#{break_line}" content << plaintext[:metadata] - content << "#{@br}#{divider*@wrap_width}#{@br}" if @md.stmp =~/\w+/ #not used? + content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? content << plaintext[:tail] Output.new(content,@md).plaintext @@endnotes={ para: [], end: [] } |