aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v2/plaintext.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2010-04-30 19:52:57 -0400
committerRalph Amissah <ralph@amissah.com>2010-04-30 19:52:57 -0400
commit88029687c9ad611c1f2c70f789347605dc2041c3 (patch)
tree946d9070e224868df464da3112a5fc94200a759c /lib/sisu/v2/plaintext.rb
parentmarkup for *{emphasis}* configurable as being either bold or italics (diff)
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)
Diffstat (limited to 'lib/sisu/v2/plaintext.rb')
-rw-r--r--lib/sisu/v2/plaintext.rb53
1 files changed, 31 insertions, 22 deletions
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, <<GSUB
@@ -166,7 +175,7 @@ GSUB
array.each do |meta|
tag,inf=meta.scan(/^.+?:\s|.+/)
if tag and inf
- util=SiSU_text_utils::Wrap.new(inf,78,15,1)
+ util=SiSU_text_utils::Wrap.new(inf,@wrap_width,15,1)
txt=util.line_wrap
@plaintext[:metadata] <<<<WOK
@@ -220,22 +229,22 @@ WOK
if dob.is=='para'
if dob.indent =~/[1-9]/
util=if dob.bullet_
- SiSU_text_utils::Wrap.new("* #{dob.obj}",78,dob.indent.to_i*2)
- else SiSU_text_utils::Wrap.new(dob.obj,78,dob.indent.to_i*2)
+ SiSU_text_utils::Wrap.new("* #{dob.obj}",@wrap_width,dob.indent.to_i*2)
+ else SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,dob.indent.to_i*2)
end
else
util=if dob.bullet_
- SiSU_text_utils::Wrap.new("* #{dob.obj}",78,0)
- else SiSU_text_utils::Wrap.new(dob.obj,78,0)
+ SiSU_text_utils::Wrap.new("* #{dob.obj}",@wrap_width,0)
+ else SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,0)
end
end
- else util=SiSU_text_utils::Wrap.new(dob.obj,78,0)
+ else util=SiSU_text_utils::Wrap.new(dob.obj,@wrap_width,0)
end
util.line_wrap
end
if lv
times=wrapped.length
- times=78 if times > 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