From 88029687c9ad611c1f2c70f789347605dc2041c3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 30 Apr 2010 19:52:57 -0400 Subject: emphasis display and plaintext line wrap configurable in document or sis * markup for *{emphasis}* configurable as being displayed either bold or italics, the default is that emphasis output is in bold so there is no at present unless configured, either in sisurc.yml (default: emphasis: 'italics'), or the markup source document header @make: :emphasis: 'it [requested] * plaintext, wrap width configurable between 20 to 200 characters, the default width being 78, configuration eithe rin sisurc.yml (default: t 78), or the markup source document header (@make: :plaintext_wrap: 78) --- lib/sisu/v2/plaintext.rb | 53 ++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'lib/sisu/v2/plaintext.rb') diff --git a/lib/sisu/v2/plaintext.rb b/lib/sisu/v2/plaintext.rb index 851da3f8..c69490ab 100644 --- a/lib/sisu/v2/plaintext.rb +++ b/lib/sisu/v2/plaintext.rb @@ -79,20 +79,29 @@ module SiSU_Plaintext end def read begin - @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) - path=@env.path.output_tell - tool=if @opt.cmd =~/[MVv]/; "#{@env.program.text_editor} #{path}/#{@md.fnb}/#{@md.fn[:plain]}" + md=SiSU_Param::Parameters.new(@opt).get + env=SiSU_Env::Info_env.new(@opt.fns) + path=env.path.output_tell + tool=if @opt.cmd =~/[MVv]/; "#{env.program.text_editor} #{path}/#{md.fnb}/#{md.fn[:plain]}" else '' end tell=SiSU_Screen::Ansi.new(@opt.cmd,'Plaintext',tool) tell.green_hi_blue unless @opt.cmd =~/q/ - tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.path.output_tell}/#{@md.fnb}/#{@md.fn[:plain]}") + tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{env.path.output_tell}/#{md.fnb}/#{md.fn[:plain]}") tell.flow if @opt.cmd =~/[MV]/ my_make=SiSU_Env::Create_file.new(@opt.cmd,@opt.fns) - @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - SiSU_Plaintext::Source::Scroll.new(@dal_array,@md).songsheet - SiSU_Env::Info_skin.new(@md).select #watch + dal_array=SiSU_DAL::Source.new(@opt).get # dal 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_Plaintext::Source::Scroll.new(dal_array,md,wrap_width).songsheet + SiSU_Env::Info_skin.new(md).select #watch rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error ensure end @@ -103,8 +112,8 @@ module SiSU_Plaintext require "#{SiSU_lib}/shared_txt" # shared_txt.rb include SiSU_text_utils @@endnotes={ :para=>[],:end=>[] } - def initialize(data,md) - @data,@md=data,md + def initialize(data,md,wrap_width) + @data,@md,@wrap_width=data,md,wrap_width @brace_url=SiSU_Viz::Skin.new.url_decoration @vz=SiSU_Env::Get_init.instance.skin @tab="\t" @@ -141,9 +150,9 @@ module SiSU_Plaintext end notes=@n.flatten notes.each do |e| - util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_text_utils::Wrap.new(e.to_s,78,4,1) - else SiSU_text_utils::Wrap.new(e.to_s,78,1,1) - end + util=(e.to_s =~/^\[[\d*+]+\]:/) \ + ? (SiSU_text_utils::Wrap.new(e.to_s,@wrap_width,4,1)) \ + : (SiSU_text_utils::Wrap.new(e.to_s,@wrap_width,1,1)) wrap=util.line_wrap if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m wrap.gsub!(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, < 78 + times=@wrap_width if times > @wrap_width @plaintext[:body] << case lv when 1; wrapped.upcase << @br << Px[:lv1]*times << @br when 2; wrapped.upcase << @br << Px[:lv2]*times << @br @@ -356,9 +365,9 @@ WOK content << plaintext[:head] content << plaintext[:body] content << @@endnotes[:end] if @@endnotes_ - content << "#{@br}#{divider*78}#{@br}" + content << "#{@br}#{divider*@wrap_width}#{@br}" content << plaintext[:metadata] - content << "#{@br}#{divider*78}#{@br}" if @md.stmp =~/\w+/ #not used? + content << "#{@br}#{divider*@wrap_width}#{@br}" if @md.stmp =~/\w+/ #not used? content << plaintext[:owner_details] if @md.stmp =~/\w+/ #not used? content << plaintext[:tail] Output.new(content,@md).plaintext -- cgit v1.2.3