From e0fcd082741e964c3564bc2be3e4c775deb99f00 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 20 Nov 2014 22:44:43 -0500 Subject: d: txt outputs, reorganize, introduce new files --- lib/sisu/develop/txt_rst.rb | 214 ++++---------------------------------------- 1 file changed, 15 insertions(+), 199 deletions(-) (limited to 'lib/sisu/develop/txt_rst.rb') diff --git a/lib/sisu/develop/txt_rst.rb b/lib/sisu/develop/txt_rst.rb index 052051fe..a596fa85 100644 --- a/lib/sisu/develop/txt_rst.rb +++ b/lib/sisu/develop/txt_rst.rb @@ -60,11 +60,15 @@ module SiSU_Txt_rST 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_rst_decorate' # txt_rst_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_Txt_Read def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -74,46 +78,13 @@ module SiSU_Txt_rST 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.rst.dir}/#{md.file.base_filename.rst}" - : "[#{@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], - 'rST (plaintext utf-8)', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'rST (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.rst.dir}/#{md.file.base_filename.rst}" - ).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_rST::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'rST (plaintext utf-8)', + output_path: md.file.output_path.rst.dir, + output_file: md.file.base_filename.rst, + } + read_generic(@opt,specific) + SiSU_Txt_rST::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__ @@ -125,6 +96,7 @@ module SiSU_Txt_rST class Scroll @wrap_width @@ -515,41 +361,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).rst + outputfile=SiSU_Env::FileOp.new(@md).write_file.rst + Txt_Output::Output.new.document(content,outputfile) @@endnotes={ para: [], end: [] } end end - class Output 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__ -- cgit v1.2.3