aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/plaintext.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/plaintext.rb')
-rw-r--r--lib/sisu/v3dv/plaintext.rb122
1 files changed, 62 insertions, 60 deletions
diff --git a/lib/sisu/v3dv/plaintext.rb b/lib/sisu/v3dv/plaintext.rb
index 9bef2c09..ba1cc48a 100644
--- a/lib/sisu/v3dv/plaintext.rb
+++ b/lib/sisu/v3dv/plaintext.rb
@@ -155,13 +155,13 @@ module SiSU_Plaintext
? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1))
: (SiSU_TextUtils::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
+ wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m
+ wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB
\\1[\\2]: \\3
GSUB
)
else
- wrap.gsub!(/^(.+)\Z/m, <<GSUB
+ wrap.gsub(/^(.+)\Z/m, <<GSUB
\\1
GSUB
)
@@ -279,66 +279,66 @@ WOK
table_message='[table omitted, see other document formats]'
fix=[]
data.each do |dob|
- dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}") #fix
- dob.obj.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check also [~-]#
- dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
- "#{Px[:bold_o]}\\1#{Px[:bold_c]}")
- dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
- "#{Px[:italics_o]}\\1#{Px[:italics_c]}")
- dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
- "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}")
- dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
- "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}")
- dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
- "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}")
- dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
- "#{Px[:insert_o]}\\1#{Px[:insert_c]}")
- dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
- "#{Px[:cite_o]}\\1#{Px[:cite_c]}")
- dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
- "#{Px[:strike_o]}\\1#{Px[:strike_c]}")
- dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
- "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}")
+ dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{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]}/,
+ "#{Px[:bold_o]}\\1#{Px[:bold_c]}").
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
+ "#{Px[:italics_o]}\\1#{Px[:italics_c]}").
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
+ "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}").
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
+ "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}").
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
+ "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}").
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
+ "#{Px[:insert_o]}\\1#{Px[:insert_c]}").
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
+ "#{Px[:cite_o]}\\1#{Px[:cite_c]}").
+ gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
+ "#{Px[:strike_o]}\\1#{Px[:strike_c]}").
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
+ "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}")
unless dob.is=='code'
- dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1')
- dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1')
- dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]')
- dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]')
- dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}")
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1').
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]').
+ gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]').
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}")
extract_endnotes(dob)
- dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]') # endnote marker marked up
- dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]') # endnote marker marked up
- dob.obj.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<')
- dob.obj.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>')
- dob.obj.gsub!(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&')
- dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!')
- dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#')
- dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*')
- dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-')
- dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/')
- dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_')
- dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{')
- dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}')
- dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~')
- dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©')
- dob.obj.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\')
+ dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up
+ gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up
+ gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<').
+ gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>').
+ gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&').
+ gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
+ gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
+ gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
+ gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
+ gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
+ gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
+ gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
+ gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
+ gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
+ gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©').
+ gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\')
end
- if dob.of=='block' # watch
- dob.obj.gsub!(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ")
- dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n")
- else dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n")
+ dob.obj=if dob.of=='block' # watch
+ dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ").
+ gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n")
+ else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n")
end
if dob.is=='code'
- dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _<
- dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_<
+ dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
+ gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_<
end
- dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1')
- dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1')
- dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links
- dob.obj.gsub!(/&nbsp;|#{Mx[:nbsp]}/,' ') # decide on
- dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]")
- dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]')
- dob.obj.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1').
+ gsub(/<a href=".+?">(.+?)<\/a>/m,'\1').
+ gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links
+ gsub(/&nbsp;|#{Mx[:nbsp]}/,' '). # decide on
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
+ gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]').
+ gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')
wordlist=dob.obj.scan(/\S+/)
if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
#if defined? dob.ocn and dob.ocn.to_s =~/\d+/
@@ -372,9 +372,11 @@ WOK
end # following empty line (@br) missing, fix
end
dob='' if (dob.obj =~/<a name="n\d+">/ \
- and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
- dob.obj.gsub!(/<!.+!>/,' ') if dob ## Clean Prepared Text
- dob.obj.gsub!(/<:\S+>/,' ') if dob ## Clean Prepared Text
+ and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
+ if dob ## Clean Prepared Text
+ dob.obj=dob.obj.gsub(/<!.+!>/,' ').
+ gsub(/<:\S+>/,' ')
+ end
end
end
@plaintext