# coding: utf-8
=begin
* Name: SiSU
* Description: a framework for document structuring, publishing and search
* Author: Ralph Amissah
* Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009 Ralph Amissah All Rights Reserved.
* License: GPL 3 or later:
SiSU, a framework for document structuring, publishing and search
Copyright (C) Ralph Amissah
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see \n#{@tab*2}#{@txt}\n#{@tab*1}
} if c
png=m.scan(/\S+/)[0]
#image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external
#else @env.url.images_local
#end
ins=if u \
and u.strip !~/^image$/
%{[#{png}]#{caption}}
else %{[#{png}] #{caption}}
end
word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/,ins)
else
link=m[/(.+)/m]
png=m.scan(/\S+/)[0].strip
link=link.strip
ins=%{#{link}#{d}}
#ins=%{#{link} [link]#{d}}
word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp)\S+/,ins)
end
else word
end
word
end
@words=@words.join(' ')
end
def markup(para)
if para !~/^#{Mx[:gr_o]}:code#{Mx[:gr_c]}/
if para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/
wm=para.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp)\S+|image)|\S+/)
words=urls(wm)
para.gsub!(/.+/m,words)
end
para.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;')
para.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
para.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/m,'')
para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration
para.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url
para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration
else
para.gsub!(/(^|[^}])_/m,'\1>') #code-block: angle brackets special characters
para.gsub!(/(^|[^}])_/m,'\1>')
end
para
end
def paragraph
%{#{@tab*1}
\n#{@tab*2}#{@txt}\n#{@tab*1}
\n} << "\n" end def lev4_minus %{#{@tab*1}\n#{@tab*2}#{@txt}\n#{@tab*1}
\n} << "\n" end def norm_comment %{#{@tab*1}\n#{@tab*2}#{@txt}\n#{@tab*1}
\n} end def norm @txt=markup(@txt) %{#{@tab*1}\n#{@tab*2}#{@txt}\n#{@tab*1}
\n} end def indent(t) @txt=markup(@txt) %{#{@tab*1}\n#{@tab*2}#{@txt}\n#{@tab*1}
\n} end def para_table %{}
end
def ocn
%{#{@tab*1}} << "\n"
end
def html_table # get rid of use html_table
@new_content=[]
@txt.split(/\n/).each do |parablock|
m=parablock[//,1]
@@tablefoot< #{x} \n#{@tab*2}#{@txt}\n#{@tab*1}\n} +
%{ })
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
#{@ocn}=ocn.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
%{#{@tab*1}} +
%{#{para_table}})
parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,
%{ } +
%{#{para_table}})
parablock.gsub!(/#{Mx[:tc_c]}/, '