aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/current/txt_plain.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2015-05-01 18:51:40 -0400
committerRalph Amissah <ralph@amissah.com>2015-05-01 18:51:40 -0400
commit58d01ddb946f666b2bc70b867314c00b1e78b1e3 (patch)
tree6ed99ea64d1ad4b02a1c8f901fb6248af9abfe08 /lib/sisu/current/txt_plain.rb
parentdebian/changelog (5.8.0-1) (diff)
parentversion & changelog, tag for release (diff)
Merge tag 'sisu_6.5.0' into debian/sid
SiSU 6.5.0
Diffstat (limited to 'lib/sisu/current/txt_plain.rb')
-rw-r--r--lib/sisu/current/txt_plain.rb243
1 files changed, 28 insertions, 215 deletions
diff --git a/lib/sisu/current/txt_plain.rb b/lib/sisu/current/txt_plain.rb
index 0edd6551..5e8ff667 100644
--- a/lib/sisu/current/txt_plain.rb
+++ b/lib/sisu/current/txt_plain.rb
@@ -51,7 +51,7 @@
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
- <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/plaintext.rb;hb=HEAD>
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/txt.rb;hb=HEAD>
=end
module SiSU_Txt_Plain
@@ -60,11 +60,15 @@ module SiSU_Txt_Plain
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_plain_decorate' # txt_plain_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_Plain
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.txt.dir}/#{md.file.base_filename.txt}"
- : "[#{@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],
- 'Plaintext',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Plaintext',
- 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.txt.dir}/#{md.file.base_filename.txt}"
- ).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_Plain::Source::Scroll.new(md,ao_array,wrap_width).songsheet
+ specific={
+ description: 'Plaintext (utf-8)',
+ output_path: md.file.output_path.txt.dir,
+ output_file: md.file.base_filename.txt,
+ }
+ read_generic(@opt,specific)
+ SiSU_Txt_Plain::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_Plain
class Scroll <Source
include SiSU_Parts_Generic
include SiSU_TextUtils
+ include SiSU_Decorate_Txt_Plain
@@endnotes={ para: [], end: [] }
def initialize(md,data,wrap_width)
@md,@data,@wrap_width=md,data,wrap_width
@@ -133,7 +105,7 @@ module SiSU_Txt_Plain
@@endnotes_=case md.opt.selections.str
when /--footnote/ then false
when /--endnote/ then true
- else true
+ else true
end
@plaintext={ body: [], open: [], close: [], head: [], metadata: [], tail: [] }
end
@@ -197,7 +169,7 @@ WOK
end
def plaintext_tail
# env=SiSU_Env::InfoEnv.new(@md.fns)
- generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
+ generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
lastdone="Last Generated on: #{Time.now}"
rubyv="Ruby version: #{@md.ruby_version}"
sc=if @md.sc_info
@@ -221,135 +193,6 @@ at:
* SiSU #{the_url.sisu_txt}
WOK
end
- def decorate
- def heading_underscore
- def l0
- '='
- end
- def l1
- '*'
- end
- def l2
- '+'
- end
- def l3
- '~'
- end
- def l4
- '-'
- end
- def l5
- '.'
- end
- def l6
- '.'
- end
- def l7
- '.'
- 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 plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document
lv=n=n3=nil
if dob.is==:heading
@@ -535,41 +378,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).plaintext
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.txt
+ 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 plaintext #%plaintext output
- file_plaintext=SiSU_Env::FileOp.new(@md).write_file.txt
- @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__
@@ -585,13 +398,13 @@ __END__
subscript_o: '[', subscript_c: ']',
hilite_o: '*', hilite_c: '*',
monospace_o: '', monospace_c: '',
- po_bold_o: '!{', po_bold_c: '}!',
- po_italics_o: '/{', po_italics_c: '}/',
- po_underscore_o: '_{', po_underscore_c: '}_',
- po_cite_o: '"{', po_cite_c: '}"',
- po_insert_o: '+{', po_insert_c: '}+',
- po_strike_o: '-{', po_strike_c: '}-',
- po_superscript_o: '^{', po_superscript_c: '}^',
- po_subscript_o: ',{', po_subscript_c: '},',
- po_hilite_o: '*{', po_hilite_c: '}*',
- po_monospace_o: '#{', po_monospace_c: '}#',
+ p_bold_o: '!{', p_bold_c: '}!',
+ p_italics_o: '/{', p_italics_c: '}/',
+ p_underscore_o: '_{', p_underscore_c: '}_',
+ p_cite_o: '"{', p_cite_c: '}"',
+ p_insert_o: '+{', p_insert_c: '}+',
+ p_strike_o: '-{', p_strike_c: '}-',
+ p_superscript_o: '^{', p_superscript_c: '}^',
+ p_subscript_o: ',{', p_subscript_c: '},',
+ p_hilite_o: '*{', p_hilite_c: '}*',
+ p_monospace_o: '#{', p_monospace_c: '}#',