From 306aed5b8a559aad2fb944a946ffdda9713f07ec Mon Sep 17 00:00:00 2001
From: Ralph Amissah #{@txt}
} if c
+ png=m.scan(/\S+/)[0]
+ ins=if u \
+ and u.strip !~/^image$/
+ %{[#{png}]#{caption}}
+ else %{[#{png}] #{caption}}
+ end
+ word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins)
+ else
+ link=m[/(.+)/m]
+ png=m.scan(/\S+/)[0].strip
+ link=link.strip
+ ins=%{#{link}}
+ word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins)
+ end
+ else word
+ end
+ word
+ end
+ @words=@words.join(' ')
+ end
+ def markup_generic(s)
+ s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1')
+ s=s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1')
+ s=s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1')
+ s=s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"')
+ s=s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+')
+ s=s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-')
+ s=s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1')
+ s=s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1')
+ s=s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~')
+ end
+ def markup_object(t_o)
+ s=t_o.obj
+ if t_o.is !='code'
+ s=markup_generic(s)
+ if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
+ wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/)
+ words=urls(wm)
+ s.gsub!(/.+/m,words)
+ end
+ s.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;')
+ s.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
+ s.gsub!(/#{Mx[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'\1') #http ftp matches escaped, no decoration
+ s.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2') #special case \{ e.g. \}http://url
+ s.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}\\2#{@brace_url.xml_close}\\3}) #http ftp matches with decoration
+ else
+ s.gsub!(/(^|[^}])_/m,'\1>') #code-block: angle brackets special characters
+ s.gsub!(/(^|[^}])_/m,'\1>')
+ end
+ s
+ end
+ def markup_note(s)
+ s=markup_generic(s)
+ if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
+ wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/)
+ words=urls(wm)
+ s=s.gsub(/.+/m,words)
+ end
+ s=s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;')
+ s=s.gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
+ s=s.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2') #http ftp matches escaped, no decoration
+ s=s.gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2') #special case \{ e.g. \}http://url
+ s=s.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration
+ end
+ def paragraph
+ %{
#{h[:txt]}
\n} # << "\n" + end + def tag_para(h) + %{#{h[:txt]}
\n} << "\n" + end + def lev_toc_hname + %{\n} #<< "\n" + end + def lev_toc + h={:txt =>txt,:class =>"toc#{@lv}",:type =>'toc'} + tag_para(h) + end + def lev4_plus + h={:txt =>@txt,:class =>"h#{@lv}",:type =>'substantive',:id =>@ocn,:header =>@hname} + tag_header(h) + end + def lev4_minus + h={:txt =>@t_o.obj,:class =>"h#{@t_o.ln}",:type =>'substantive',:id =>@t_o.ocn} + tag_para(h) + end + def norm_comment + h={:txt =>@t_o.obj,:class =>'norm',:type =>'comment'} + tag_para(h) + end + def norm + txt=markup_object(@t_o) + h={:txt =>txt,:class =>'norm',:type =>'substantive',:id =>@ocn} + tag_para(h) + end + def indent(t) + txt=markup_object(@t_o) + h={:txt =>txt,:class =>"indent#{t}",:type =>'substantive',:id =>@ocn} + tag_para(h) + end + def para_table + %{}
+ end
+ def ocn
+ %{} << "\n"
+ end
+ def html_table # get rid of use html_table
+ @new_content=[]
+ @txt.split(/\n/).each do |parablock|
+ m=parablock[//,1]
+ @@tablefoot << m if m
+ parablock.gsub!(//,'')
+ @@tablehead=1 if parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u
+ parablock.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/,
+ %{ #{x} #{@txt}})
+ if parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/
+ tablefoot=[]
+ @@tablefoot.each {|x| tablefoot << %{
} +
+ %{\n ')
+ @@tablehead=0
+ end
+ parablock
+ else
+ parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
+ %{\n} +
+ %{#{para_table}})
+ parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
+ %{ } +
+ %{#{para_table}})
+ parablock.gsub!(/#{Mx[:tc_c]}/, ' } +
+ %{\n ')
+ parablock
+ end
+ @new_content << parablock
+ end
+ @new_content.join
+ end
+ end
+ class CSS_Format_generic #does CSS_Format in one definition, needs to be told about attrib, despite brevity of generic, easier to see structure with CSS_Format
+ def initialize(attrib='',txt='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil)
+ @tab="\t"
+ @attrib=attrib
+ @txt=txt
+ @lv=@notenumber=lv.to_s
+ @hname=hname.to_s
+ @id=@ocn=id
+ end
+ def paragraph
+ attrib=%{class="#{@attrib}" }
+ if @ocn
+ id=%{id="#{@ocn}" }
+ type=%{type="substantive" }
+ else
+ id=%{id="none" }
+ type=%{type="comment" }
+ end
+ header=%{header="#{@hname}" } if @hname
+ %{} +
+ %{#{para_table}})
+ parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
+ %{ } +
+ %{#{para_table}})
+ parablock.gsub!(/#{Mx[:tc_c]}/, '