From d29a3e5469d8468084641c385ebf16948f7c2437 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 22 Jul 2008 20:00:59 -0400 Subject: sisu-0.68.0 proposed * middle layer document representation changed, (accounting for substantial patch) * texpdf multiple document sizes as specified in config * numerous small fixes [should on the whole be easier to maintain] --- lib/sisu/v0/dal_syntax.rb | 261 +++++++++++++++++++++++++--------------------- 1 file changed, 141 insertions(+), 120 deletions(-) (limited to 'lib/sisu/v0/dal_syntax.rb') diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 22ec72b0..c3bd8a7d 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -58,7 +58,7 @@ ** Description: Syntax for markup, input markup syntaxes, determined here =end -module Syntax +module SiSU_Syntax class Words def initialize(line,md,mkp) @line,@md,@mkp=line,md,mkp @@ -71,11 +71,11 @@ module Syntax @data_new=[] url_and_stub=SiSU_Env::Info_env.new.url @output_url="#{url_and_stub.remote}" - @http_m='\{.+?\}(?:https?|file)://\S+|(?:https?|file):\S+|\.\.\/\S+|\S+?\.png\b|[*]~\S+|^0~.+|<:(?:code|group|alt|verse)(?:-end)?>|<:br>' + @http_m=%r{\{.+?\}(?:https?|file)://\S+|(?:https?|file):\S+|\.\.\/\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} @manmkp_ital='[i/]\\{.+?\\}[i/]' tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)} - tail_m_bold=%q{(?:(?:<\/i>)?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} - bold_line=%q{^!_\s.+?(?:
|\n|$)} + tail_m_bold=%{(?:(?:#{Mx[:fa_italics_c]})?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} + bold_line=%{^!_\s.+?(?:#{Mx[:br_line]}|\n|$)} @line_scan_ital=if defined? @md.make_italic[:str] \ and defined? @vz.markup_make_italic[:str] /#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|(?:#{@md.make_italic[:str]}|#{@vz.markup_make_italic[:str]})#{tail_m_ital}|\S+|\n/ @@ -114,6 +114,8 @@ module Syntax end def pre(line) line=line.dup + line.gsub!(/^0~(\S+)/,"#{Mx[:lv_o]}@\\1#{Mx[:lv_c]}") + line.gsub!(/^@(\S+?):/,"#{Mx[:lv_o]}@\\1#{Mx[:lv_c]}") if line =~/\{(?:t|table)(?:~h)?\s*c?[\d; ]*\}/; line.gsub!(/(\n)/,';;\1') #markup for alternative tables end line @@ -124,7 +126,7 @@ module Syntax and @md.make_italic[:str]) \ or (defined? @vz.markup_make_italic[:str] \ and @vz.markup_make_italic[:str]) - line= if line !~/^(?:0~|%{1,4}\s|<:code)/ #!~/^(?:[0-6]~|!_|%+\s)/ + line= if line !~/^(?:#{Rx[:meta]}|#{Mx[:gr_o]}code)/ #!~/^(?:[0-6]~|!_|%+\s)/ word=line.scan(@line_scan_ital) word.flatten! word.compact! #reinstated @@ -133,10 +135,10 @@ module Syntax unless /#@manmkp_ital|#@http_m/.match(w) if defined? @md.make_italic[:regx] \ and @md.make_italic[:regx] - w.gsub!(@md.make_italic[:regx],'\1') + w.gsub!(@md.make_italic[:regx],"#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") elsif defined? @vz.markup_make_italic \ and @vz.markup_make_italic - w.gsub!(@vz.markup_make_italic,'\1') + w.gsub!(@vz.markup_make_italic,"#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") end end line_array << w @@ -148,10 +150,10 @@ module Syntax line end def embolden(given) - given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)(
)/,'\1\2') - given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)\s+((?:[*]~\S+\s*)+)/,'\1 \2') - given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)\s*([~-]#)$/,'\1 \2') - given.gsub!(/(?:^!_\s+|^[7-9]~\s+)(.*)?\s*$/,'\1') + given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)(
)/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") + given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") + given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") + given.gsub!(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def wordlist_bold(line) line=line.dup @@ -159,7 +161,7 @@ module Syntax and @md.make_bold[:str]) \ or (defined? @vz.markup_make_bold[:str] \ and @vz.markup_make_bold[:str]) - line=if line !~/^(?:[0-9]~|%+\s|<:code)/ + line=if line !~/^(?:#{Rx[:meta]}|#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}|%+\s|#{Mx[:gr_o]}code)/ line_array=[] word=line.scan(@line_scan_bold) word.flatten! @@ -168,13 +170,13 @@ module Syntax unless /#@manmkp_bold|#@http_m/.match(w) if defined? @md.make_bold[:regx] \ and @md.make_bold[:regx] #document header: 0~bold [bold word list] - w.gsub!(@md.make_bold[:regx],'\1') + w.gsub!(@md.make_bold[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") elsif defined? @vz.markup_make_bold \ and @vz.markup_make_bold #defaults and skin adjusted bold word list - w.gsub!(@vz.markup_make_bold,'\1') + w.gsub!(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end else - if w =~ /(?:^!_|^[7-9]~)\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! end end line_array << w @@ -183,8 +185,8 @@ module Syntax else line end else - if line !~/^(?:[0-9]~|%+\s)/ \ - and line =~ /(?:^!_|^[7-9]~)\s+/ + if line !~/^(?:#{Mx[:lv_o]}[0-9]:\S*?#{Mx[:lv_c]}|%+\s)/ \ + and line =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/ embolden(line) end end @@ -218,107 +220,126 @@ module Syntax # # #numbered (list) level 1 # _# #numbered (list) level 2 line=line.dup - if line !~/^0~|<:codeline>|<:code-end>/ + if line !~/^#{Mx[:meta_o]}|#{Mx[:gr_o]}codeline#{Mx[:gr_c]}|#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/ #special characters: ~ { } < > - _ / also used : ^ ! # line_array=[] line.gsub!(/^%{1,4} .+/mi,'') #remove comments - word=line.scan(/\S+|\n/) unless line =~/^(?:0~\S|%+\s)/ + word=line.scan(/\S+|\n/) unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit if word word.each do |w| # _ - / # | : ! ^ ~ - unless w =~/^[0-9]~|~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table/ - w.gsub!(/\\~/,'~') #escaped special character - w.gsub!(/~/,'~') + unless w =~/^#{Mx[:lv_o]}[0-9]:\S*?#{Mx[:lv_c]}|~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table/ + w.gsub!(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + #w.gsub!(/~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") end - w.gsub!(/^\<$/,'<') #escaped special character - w.gsub!(/^\>$/,'>') #escaped special character + w.gsub!(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character + w.gsub!(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character line_array << w end line=line_array.join(' ') line=line.strip end - line.gsub!(/^(1~\??) @title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 #{@md.title} - #{@md.subtitle},
\\2#{@md.dc_creator}") + line.gsub!(/~\{(.+?)\}~/m,"#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") + line.gsub!(/~\[(.+?)\]~/m,"#{Mx[:en_b_o]}\\1#{Mx[:en_b_c]}") + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 #{@md.title} - #{@md.subtitle},
\\2#{@md.dc_creator}") line.gsub!(/^(1~\??) @title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") # - line.gsub!(/^([23]~\??) (?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 \\2#{@md.dc_creator}") # - line.gsub!(/<((?:https?|file):\/\/\S+?)>/,'< \1 >') #catch problem markup - line.gsub!(/\}\.\.\/(\S+)/,"\}#@output_url/\\1") #means you are not supporting relative links (only relevant in html), converted to static here + line.gsub!(/^(#{Mx[:lv_o]}[23]:\??#{Mx[:lv_c]}) (?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 \\2#{@md.dc_creator}") # + line.gsub!(/<((?:https?|file):\/\/\S+?)>/,'< \1 >') #catch problem markup + line.gsub!(/\}\.\.\/(\S+)/,"\}#@output_url/\\1") #means you are not supporting relative links (only relevant in html), converted to static here line.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu') #adjustment 2005w30 line.gsub!(//,'<:\1>') #escaped special character - line.gsub!(/\\~/,'~') #escaped special character - line.gsub!(/\\\{/,'{') #escaped special character - line.gsub!(/\\\}/,'}') #escaped special character - line.gsub!(/\\\<>/,'>>') #escaped special character - line.gsub!(/\\\/,'>') #escaped special character - line.gsub!(/\\\_/,'_') #escaped special character - line.gsub!(/\\\-/,'-') #escaped special character - line.gsub!(/\\\+/,'+') #escaped special character - line.gsub!(/\\\//,'/') #escaped special character - line.gsub!(/\\\#/,'#') #escaped special character - line.gsub!(/\\\&/,'&') #& #escaped special character - line.gsub!(/\\\|/,'|') #not really a sisu special character but made available as possibility - line.gsub!(/\\\:/,':') #not really a sisu special character but made available as possibility - line.gsub!(/\\\!/,'!') #not really a sisu special character but made available as possibility - line.gsub!(/\\\^/,'^') #not really a sisu special character but made available as possibility - line.gsub!(/\\\,/,',') #not really a sisu special character but made available as possibility + line.gsub!(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\<>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}") #& #escaped special character + line.gsub!(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility + line.gsub!(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility + line.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility + line.gsub!(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility + line.gsub!(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility #ADD --> - line.gsub!(/\\\\/,'\') #escaped special character - line.gsub!(/\\\*/,'*') #escaped special character - line.gsub!(/\\\!/,'!') #escaped special character - line.gsub!(/(?:^| )\*~([a-z0-9._-]+)/i,' <:name#\1>') #html name marker - line.gsub!(/^([56]~)(\S+)(.+)/,'\1\2 \3 <:name#\2>') #html name marker , however at present takes you to correct position within sub-toc, will nneed to clean from sub-toc leaving in main body only - line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s[^~]|$))/,'\1{ \2 }\3\4 ~{ \3 }~ ') #text url endnote url shortcut {~^ [text] }http://url is { [text] }http://url ~{ http://url }~ [plus adjustment for commas] #means for this class, non-object, un-numbered ~# will not work # shortcut should not be used in conjunction with rebgular matches #reversed order, and addition of no-tilde.. - line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch - line.gsub!(/<:?br>/,'
') #xml requires - # depreciated --> - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)e\{(.+?)\}e/,'\1\2') #emphasis - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)b\{(.+?)\}b/,'\1\2') #bold - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)u\{(.+?)\}u/,'\1\2') #underscore - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)c\{(.+?)\}c/,'\1\2') #cite /blockquote? - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)i\{(.+?)\}i/,'\1\2') #italics + line.gsub!(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character + line.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character + line.gsub!(/(?:^| )\*~([a-z0-9._-]+)/i," #{Mx[:mk_o]}:name#\\1#{Mx[:mk_c]}") #html name marker + line.gsub!(/^(#{Mx[:lv_o]}[56]:(\S+?)#{Mx[:lv_c]})\s*(.+)/,"\\1 \\3 #{Mx[:mk_o]}:name#\\2#{Mx[:mk_c]}") #html name marker , however at present takes you to correct position within sub-toc, will nneed to clean from sub-toc leaving in main body only + line.gsub!(/(?:<:?br>|
)/,"#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') + if line=~/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m + line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ ([^}]+?)\s*\}((?:https?|file|ftp):\S+)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,"\\1{ \\2 }\\3 #{Mx[:en_a_o]} \\3 \\4 #{Mx[:en_a_c]}") # watch + end + if line=~/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s|$))/m + line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s|$))/m,"\\1{ \\2 }\\3\\4 #{Mx[:en_a_o]} \\3 #{Mx[:en_a_c]} ") + #text url endnote url shortcut {~^ [text] }http://url is { [text] }http://url #{Mx[:en_a_o]} http://url #{Mx[:en_a_c]} [plus adjustment for commas] + #means for this class, non-object, un-numbered ~# will not work # shortcut should not be used in conjunction with rebgular matches #reversed order, and addition of no-tilde.. + end + #line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch + line.gsub!(/<:?p([nb])>/,"#{Mx[:fa_o]}p\\1#{Mx[:fa_c]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') + # depreciated -->#{Mx[:fa_c]} + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)c\{(.+?)\}c/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics # depreciated ^ - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)!\{(.+?)\}!/,'\1\2') #emphasis - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)\*\{(.+?)\}\*/,'\1\2') #bold - line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)_\{(.+?)\}_/,'\1\2') #underscore - line.gsub!(/(^|\s+|['"]| |[\(\[]|\(|\>)\/\{(.+?)\}\//,'\1\2') #italics - line.gsub!(/(^|\s+|['"]| |\(|\>)\"\{(.+?)\}\"/,'\1\2') #cite /blockquote? - line.gsub!(/(^|[^\\])\^\{(.+?)\}\^/,'\1\2') #superscript - line.gsub!(/(^|\s+|['"]| |\(|\>|\S)9\{(.+?)\}9/,'\1\2') #superscript - line.gsub!(/(^|[^\\]),\{(.+?)\},/,'\1\2') #subscript - line.gsub!(/(^|\s+|['"]| |\(|\>)6\{(.+?)\}6/,'\1\2') #subscript - line.gsub!(/(^|\s+|['"]| |\(|\>)\+\{(.+?)\}\+/,'\1\2') #inserted text - line.gsub!(/(^|\s+|['"]| |\(|\>)v\{(.+?)\}v/,'\1\2') #inserted text - line.gsub!(/(^|\s+|['"]| |\(|\>)-\{(.+?)\}-/,'\1\2') #strikethrough - deleted text - line.gsub!(/(^|\s+|['"]| |\(|\>)x\{(.+?)\}x/,'\1\2') #deleted text - line.gsub!(/(^|\s+|['"]| |\(|\>)\*(\S+?)\*/,'\1\2') #bold single word, watch - line.gsub!(/(^|\s+|['"]| |\(|\>)\!(\S+?)\!/,'\1\2') #bold single word, watch - line.gsub!(/(^|\s+|['"]| |\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/,'\1\2\3') #italics single word, watch - line.gsub!(/(^|\s+|['"]| |\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/,'\1\2\3') #underscore single word, watch (made more complicated by url decoration escape tag (_url)) - line.gsub!(/(^|\s+)-([^{]\S+?)-( |$)/,'\1\2\3') #underscore single word, watch - line.gsub!(/(^|\s+|['"]| |\(|\>|\d+)\^(\S+?)\^/,'\1\2') #superscript single word, watch digit added - line.gsub!(/<[:e]\s+(.+?)!?>/,'~{ \1 }~') # not tested - line.gsub!(/^\s*_([1-9])(\*+)\s*/,'<:i\1> _* ') #bullets, shortcut - line.gsub!(/^\s*_([1-9])\s+/,'<:i\1> ') #indent - line.gsub!(/(?:
|
)\s*_[12]\s+/,'
') #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') - line.gsub!(/<:?br>/,'
') #adjustment 2004w41, from # line.gsub!(/
/,'
') + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? + line.gsub!(/(^|[^\\])\^\{(.+?)\}\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |\(|\>|\S)9\{(.+?)\}9/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript + line.gsub!(/(^|[^\\]),\{(.+?)\},/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #strikethrough - deleted text + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #deleted text + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}\\3") #underscore single word, watch (made more complicated by url decoration escape tag (_url)) + line.gsub!(/(^|#{Mx[:gl_c]}|\s+)-([^{]\S+?)-( |$)/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}\\3") #underscore single word, watch + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added + line.gsub!(/<[:e]\s+(.+?)!?>/,"#{Mx[:en_a_o]} \\1 #{Mx[:en_a_c]}") #not tested + line.gsub!(/^\s*_\*\s*/,"#{Mx[:gl_bullet]}") #bullets, shortcut + #line.gsub!(/^\s*_(\*+)\s*/,"#{Mx[:gl_bullet]}") #bullets, shortcut + line.gsub!(/^\s*_([1-9])\*\s*/,"#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}") #bullets, shortcut + #line.gsub!(/^\s*_([1-9])(\*+)\s*/,"#{Mx[:fa_o]}:i\\1#{Mx[:fa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") #bullets, shortcut + line.gsub!(/^\s*_([1-9])\s+/,"#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") #indent + line.gsub!(/(?:<:?br>|
)/,"#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') ##added #line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?([~-]#)$/i,'\1 \2') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - #line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?\s*$/i,'\1') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - #line.gsub!(/(?:(?:^| )!_ |^[7-9]~ |<:b>)(.*)\n/mi,'\1 ') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + #line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?\s*$/i,'\1') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + #line.gsub!(/(?:(?:^| )!_ |^[7-9]~ |<:b>)(.*)\n/mi,'\1 ') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! #line.gsub!(/^_" (.*)\n/i,'
\1
') #blockquotes #introduce KEEP - line.gsub!(/<:hi>/,'') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) - line.gsub!(/<:\/hi>/,'') - line.gsub!(/(<:verse>.+)/m,"\\1\n") + line.gsub!(/<:hi>/,"#{Mx[:fa_hilite_o]}") #'') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) + line.gsub!(/<:\/hi>/,"#{Mx[:fa_hilite_c]}") #'') + #line.gsub!(/<:hi>/, + #line.gsub!(/<:\/hi>/,'') + line.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n") line.gsub!(/[ ]+($)/,'\1') - if line =~/(<:(?:verse|group)>)/; line.gsub!(/(<:(?:verse|group)>)/i,"\\1\n") #cosmetic - else line.gsub!(/(
)/i,"\\1\n") + #line.gsub!(/\{(.+?)\}(https?:\S+)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked (text or image) + #line.gsub!(/\{(.+?)\}(image)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image + ##semantic + #line.gsub!(/([a-z](?:[a-z_:.]+?[a-z])?)+(?::\{(.+?)\}:\1)/m,"\\1#{Mx[:sm_set_o]}\\2#{Mx[:sm_set_c]}\\1") + #line.gsub!(/;\{\s*(.+?)\s*\};([a-z]+(?:[_:.][a-z]+)*)/,"#{Mx[:sm_subset_o]}\\1#{Mx[:sm_subset_c]}\\2") + if line =~/(#{Mx[:gr_o]}(?:verse|group)#{Mx[:gr_c]})/; line.gsub!(/(#{Mx[:gr_o]}(?:verse|group)#{Mx[:gr_c]})/i,"\\1\n") #cosmetic + else line.gsub!(/
/i,"#{Mx[:br_line]}\n") end - elsif line =~/^<:code(?:-end)?>|<:codeline>/ # /^<:code>/ #should be enough # underscore used as escape for angle brackets + elsif line =~/^#{Mx[:gr_o]}code(?:-end)?#{Mx[:gr_c]}|#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/ # /^<:code>/ #should be enough # underscore used as escape for angle brackets line.gsub!(/([<>])/,'_\1') line.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert

back, clumsy - line.gsub!(/(^|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy - line.gsub!(/<:codeline>/,"\n  ") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") + line.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy + line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n  ") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") else # 0~ end line @@ -341,32 +362,32 @@ module Syntax # +2 puts 'tech' @data.each do |line| - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)e\{(.+?)\}e/,'\1\2') #emphasis - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)b\{(.+?)\}b/,'\1\2') #bold - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)u\{(.+?)\}u/,'\1\2') #underscore - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)c\{(.+?)\}c/,'\1\2') #cite - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)i\{(.+?)\}i/,'\1\2') #italics - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)!\{(.+?)\}!/,'\1\2') #emphasis - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)\*\{(.+?)\}\*/,'\1\2') #bold - line.gsub!(/(^|\s+|['"]|[\(\[]|\>)_\{(.+?)\}_/,'\1\2') #underscore - line.gsub!(/(^|\s+|['"]|[\(\[]|\(|\>)\/\{(.+?)\}\//,'\1\2') #italics - line.gsub!(/(^|\s+|['"]|\(|\>)\"\{(.+?)\}\"/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>|\S)\^\{(.+?)\}\^/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>|\S)9\{(.+?)\}9/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>),\{(.+?)\},/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>)6\{(.+?)\}6/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>)\+\{(.+?)\}\+/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>)v\{(.+?)\}v/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>)-\{(.+?)\}-/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>)x\{(.+?)\}x/,'\1\2') - line.gsub!(/(^|\s+|['"]|\(|\>)\*(\S+?)\*/,'\1\2') #bold single word, watch - line.gsub!(/(^|\s+|['"]|\(|\>)\!(\S+?)\!/,'\1\2') #bold single word, watch - line.gsub!(/(^|\s+|['"]|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/,'\1\2\3') #italics single word, watch - line.gsub!(/(^|\s+|['"]|\(|\>)_(\S+?)_/,'\1\2') #underscore single word, watch - line.gsub!(/(^|\s+|['"]|\(|\>|\d+)\^(\S+?)\^/,'\1\2') #superscript single word, watch digit added - line.gsub!(/^\s*_([1-9])(\*+)\s*/,'<:i\1> _* ') # bullets, shortcut - line.gsub!(/^\s*_([1-9])\s+/,'<:i\1> ') - line.gsub!(/<:?br>/,'
') + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore single word, watch + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #check #superscript single word, watch digit added + line.gsub!(/^\s*_\([1-9]\)\(\*\+\)\s*/,"#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") # bullets, shortcut + line.gsub!(/^\s*_\([1-9]\)\s+/,"#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") + line.gsub!(/(?:<:?br>|
)\s*_[12]\s+/,"#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') end @data end -- cgit v1.2.3