From d43865fb6a093625a77e8605d6fb00158546e1e4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 12 Aug 2008 23:37:42 -0400 Subject: html increased use of css; dal, middle layer, url representation, interim commit --- lib/sisu/v0/constants.rb | 8 +- lib/sisu/v0/css.rb | 264 +++++++++++++++++++++------------ lib/sisu/v0/dal.rb | 14 +- lib/sisu/v0/dal_doc_str.rb | 10 +- lib/sisu/v0/dal_syntax.rb | 11 +- lib/sisu/v0/db_import.rb | 6 +- lib/sisu/v0/defaults.rb | 8 +- lib/sisu/v0/digests.rb | 4 +- lib/sisu/v0/html.rb | 31 +++- lib/sisu/v0/html_format.rb | 130 +++++----------- lib/sisu/v0/html_format_css.rb | 133 +++++++---------- lib/sisu/v0/html_segments.rb | 26 ++-- lib/sisu/v0/html_table.rb | 18 +-- lib/sisu/v0/html_tune.rb | 18 +-- lib/sisu/v0/hub.rb | 5 +- lib/sisu/v0/manpage.rb | 6 +- lib/sisu/v0/odf.rb | 16 +- lib/sisu/v0/plaintext.rb | 4 +- lib/sisu/v0/shared_html_lite.rb | 18 +-- lib/sisu/v0/shared_structure.rb | 3 +- lib/sisu/v0/shared_xml.rb | 16 +- lib/sisu/v0/sst_do_inline_footnotes.rb | 1 + lib/sisu/v0/sst_to_s_xml_dom.rb | 2 + lib/sisu/v0/texinfo_format.rb | 6 +- lib/sisu/v0/texpdf.rb | 6 +- lib/sisu/v0/texpdf_format.rb | 86 ++++++----- lib/sisu/v0/wikispeak.rb | 6 +- 27 files changed, 457 insertions(+), 399 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index 68093673..2c08bdfa 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -97,7 +97,8 @@ Mx[:br_page]= "#{Mx[:mk_o]}pb#{Mx[:mk_c]}" Mx[:br_page_new]= "#{Mx[:mk_o]}pn#{Mx[:mk_c]}" Mx[:br_endnotes]= "#{Mx[:mk_o]}ENDNOTES#{Mx[:mk_c]}" Mx[:br_eof]= "#{Mx[:mk_o]}EOF#{Mx[:mk_c]}" -Mx[:lnk_o]='「'; Mx[:lnk_c]='」' +Mx[:lnk_o]='◁'; Mx[:lnk_c]='▷' + #‹ › Mx[:sm_set_o]='《'; Mx[:sm_set_c]='》' Mx[:sm_subset_o]='《 '; Mx[:sm_subset_c]='》' #Mx[:sm_set_o]='∈ '; Mx[:sm_set_c]='∋ ' @@ -166,4 +167,9 @@ check: ‹ › ∗  '〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕' '〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' +◁▷ + +▶this is text or an image◀http:// + +◀this is text or an image▶ http:// diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index cdd05528..52de3351 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -106,7 +106,7 @@ WOK /* SiSU css default stylesheet */ body { color: black; - background: #{@vz.color_white}; + background: "#ffffff"; } /* table { @@ -121,25 +121,25 @@ WOK } */ a:link { - color: #{@vz.color_blue_ink}; + color: #003399; text-decoration: none; } a:visited { - color: #{@vz.color_blue_ink}; + color: #003399; text-decoration: none; } /* a:hover { - color: #{@vz.color_black}; + color: #000000; border-bottom: 2px solid #777777; - background-color: #{@vz.color_yellow_light}; + background-color: #fff3b6; } */ a:hover img { - background-color: #{@vz.color_white}; + background-color: "#ffffff"; } a:active { - color: #{@vz.color_blue_ink}; + color: #003399; text-decoration: underline; } div { @@ -197,24 +197,35 @@ WOK margin-left: 75%; width: 20%; } - p { + ul, li, p { display: block; - font-family: #{fonts}; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-size: 100%; font-weight: normal; line-height: 150%; - text-align: left; - margin-left: 10mm; + text-align: justify; + margin-left: 1em; text-indent: 0mm; margin-top: 3px; margin-bottom: 3px; - margin-right: 5mm; + /* margin-bottom:0; */ + margin-right: 2em; + /* width: 90%; */ } p.norm { - text-align: justify; } + p.i1 {margin-left: 2em;} + p.i2 {margin-left: 3em;} + p.i3 {margin-left: 4em;} + p.i4 {margin-left: 5em;} + p.i5 {margin-left: 6em;} + p.i6 {margin-left: 7em;} + p.i7 {margin-left: 8em;} + p.i8 {margin-left: 9em;} + p.i9 {margin-left: 10em;} p.code { - font-family: monospace; + font-family: inconsolata, andale mono, courier new, courier, monospace; + font-size: 90%; text-align: left; } p.caption { @@ -223,24 +234,24 @@ WOK display: inline; } p.endnote { - font-family: #{fonts}; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-size: 96%; font-weight: normal; line-height: 120%; text-align: left; - margin-left: 10mm; + margin-left: 1em; text-indent: 0mm; margin-top: 3px; margin-bottom: 3px; margin-right: 15mm; } p.endnote_indent { - font-family: #{fonts}; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-size: 96%; font-weight: normal; line-height: 120%; text-align: left; - margin-left: 15mm; + margin-left: 2em; text-indent: 0mm; margin-top: 3px; margin-bottom: 3px; @@ -264,6 +275,8 @@ WOK p.ocn, p.paranum { font-size: 10px; margin-top: 0px; + float: right; + width: 5%; margin-bottom: 5px; color: #777777; margin-right: 5px; @@ -384,7 +397,7 @@ WOK margin-top: 1px; margin-bottom: 3px; } - p.quickref{ + p.quickref { font-size: 10px; font-style: italic; margin-top: 0px; @@ -393,7 +406,7 @@ WOK margin-right: 5px; text-align: left; } - p.bigref{ + p.bigref { font-size: 11px; font-weight: bold; margin-top: 0px; @@ -402,19 +415,11 @@ WOK margin-right: 5px; text-align: center; } - p.i1 {margin-left: 15mm;} - p.i2 {margin-left: 20mm;} - p.i3 {margin-left: 25mm;} - p.i4 {margin-left: 30mm;} - p.i5 {margin-left: 35mm;} - p.i6 {margin-left: 40mm;} - p.i7 {margin-left: 45mm;} - p.i8 {margin-left: 50mm;} - p.i9 {margin-left: 55mm;} table { } tr { } th, td { } + p.left, th.left, td.left { text-align: left; } @@ -428,11 +433,11 @@ WOK h0, h1, h2, h3, h4, h5, h6 { display: block; - font-family: #{fonts}; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-weight: bold; line-height: 120%; - margin-left: 10mm; - margin-right: 10mm; + margin-left: 5mm; + margin-right: 5mm; text-align: left; margin-top: 20px; margin-bottom: 10px; @@ -440,6 +445,7 @@ WOK h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { text-align: center; } + ul { list-style: none; } @@ -449,52 +455,52 @@ WOK ul.vertical { list-style: none; } + li { background: url(../image/bullet_09.png) no-repeat 0px 6px; - /* list-style-type: disc; */ padding-left: 20px; display: block; - font-family: #{fonts}; - /* font-size: 100%; */ + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-weight: normal; line-height: 150%; text-align: left; - margin-left: 10mm; + margin-left: 1em; text-indent: 0mm; margin-top: 3px; margin-bottom: 3px; - margin-right: 0mm; + margin-right: 10mm; } li.bullet { - margin-left: 10mm; + margin-left: 1em; } li.i1 { - margin-left: 15mm; + margin-left: 2em; } li.i2 { - margin-left: 20mm; + margin-left: 3em; } li.i3 { - margin-left: 25mm; + margin-left: 4em; } li.i4 { - margin-left: 30mm; + margin-left: 5em; } li.i5 { - margin-left: 35mm; + margin-left: 6em; } li.i6 { - margin-left: 40mm; + margin-left: 7em; } li.i7 { - margin-left: 45mm; + margin-left: 8em; } li.i8 { - margin-left: 50mm; + margin-left: 9em; } li.i9 { - margin-left: 55mm; + margin-left: 10em; } + #horizontal_links { background: #eeeeee; margin-left: 5%; @@ -515,8 +521,6 @@ WOK background: none; } #horizontal a { - /* font-weight: normal; */ - /* float: left; */ line-height: 12px; margin: 0 0 0 0; text-decoration: none; @@ -525,7 +529,6 @@ WOK #horizontal a.active, #horizontal a:hover { border-bottom: 2px solid #777777; padding-bottom: 2px; - /* font-weight: bold; */ color: #000077; } #horizontal a:hover { @@ -536,7 +539,6 @@ WOK top: 10mm; right: 2%; width: 12%; - /* background: #ffffff; */ float: right; } #vertical_links { @@ -569,7 +571,6 @@ WOK list-style-type: none; } #vertical a { - /* font-weight: normal; */ line-height: 12px; text-decoration: none; color: #000077; @@ -577,13 +578,11 @@ WOK #vertical a.active, #vertical a:hover { border-bottom: 2px solid #777777; padding-bottom: 2px; - /* font-weight: bold; */ color: #000077; } + li.doc { background: url(../image/bullet_09.png) no-repeat 0px 6px; - /* background: url(../image/bullet_doc.png) no-repeat 0 0; */ - /* background: url(../../_sisu/image/bullet_09.png) no-repeat 0px 6px; */ padding-left: 16px; margin-left: 10px; margin-top: 0px; @@ -606,7 +605,6 @@ WOK } li.refcenter { background: url(../image/bullet_09.png) no-repeat 0px 6px; - /* background: url(../image/bullet_doc.png) no-repeat 0 0; */ background: none; padding-left: 20px; margin-left: 10%; @@ -618,8 +616,6 @@ WOK } li.refbold { background: url(../image/bullet_09.png) no-repeat 0px 6px; - /* background: url(../image/bullet_doc.png) no-repeat 0 0; */ - /* padding-left: 0px; */ padding-left: 16px; margin-left: 0; margin-top: 0px; @@ -629,6 +625,7 @@ WOK font-weight: bold; text-align: left; } + h1 { font-size: 120%; margin-top: 20px; @@ -655,7 +652,7 @@ WOK } h1.norm, h2.norm, h3.norm { font-size: 110%; - margin-left: 10mm; + margin-left: 1em; margin-right: 15mm; text-align: left; margin-top: 20px; @@ -682,6 +679,7 @@ WOK margin-right: 0px; text-align: left; } + p.top_band { display: inline; text-align: left; @@ -709,6 +707,7 @@ WOK text-indent: 0mm; margin-right: 1mm; } + h4.norm, h5.norm, h6.norm { font-size: 100%; margin-left: 10mm; @@ -717,6 +716,7 @@ WOK margin-top: 10px; margin-bottom: 0px; } + h1.i {margin-left: 10mm;} h2.i {margin-left: 15mm;} h3.i {margin-left: 20mm;} @@ -726,6 +726,7 @@ WOK h7.i {margin-left: 40mm;} h8.i {margin-left: 45mm;} h9.i {margin-left: 50mm;} + h1.banner { font-weight: bold; text-align: center; @@ -779,6 +780,7 @@ WOK h6.banner { font-weight: bold; } + h1.toc { margin-left: 10mm; font-size: 115%; @@ -824,7 +826,7 @@ WOK margin-bottom: 6px; line-height: 110%; } -/* microtoc (for later) --> */ + h1.microtoc { margin-left: 0mm; font-size: 115%; @@ -864,9 +866,8 @@ WOK margin-top: 2px; margin-bottom: 2px; } -/* subtoc --> */ h5.subtoc { - margin-left: 20mm; + margin-left: 2em; margin-right: 34%; font-weight: normal; font-size: 80%; @@ -874,13 +875,121 @@ WOK margin-bottom: 2px; } h6.subtoc { - margin-left: 25mm; + margin-left: 3em; margin-right: 34%; font-weight: normal; font-size: 75%; margin-top: 0px; margin-bottom: 0px; } + +div.substance { + width: 100%; + background-color: #ffffff; +} +div.ocn { + width: 5%; + float: right; + top: 0; + background-color: #ffffff; +} +div.endnote { + width: 95%; + background-color: #fffffff; +} +/* +body { + font-size: 90%; + font-family: verdana, arial, sans-serif; +} +*/ +div.toc { + position: absolute; + float: left; + margin: 0; + padding: 0; + padding-top: 0.5em; + border: 0; + width: 13em; + background-color: #eeeeee; + margin-right:1em; +} +div.content { + margin: 0; + padding: 0; + border-left: 13em solid #ffffff; + padding-left: 1em; +} +div.content:after { + content:' '; + clear:both; + display:block; + height:0; + overflow:hidden +} +div.footer { + clear:left; + padding: 0.5em; + font-size: 80%; + margin: 0; +} +div.toc ul { + list-style: none; + padding: 0; + margin: 0; +} +div.toc li ul a, li ul span.currentlink +{ + font-weight: normal; + font-size: 90%; + padding-left: 2em; + background-color: #eeeeee; +} +div.toc a, span.currentlink{ + display:block; + text-decoration: none; + padding-left: 0.5em; + color: #0000aa; +} +span.currentlink { + text-decoration: none; + background-color: #aaaaf9; +} +div.toc a:visited { + color: #0000aa; +} +div.toc a:hover { + background-color: #f9f9aa; +} + h1.minitoc, h2.minitoc, h3.minitoc { + margin-left: 0mm; + font-weight: bold; + text-align: left; + font-size: 90%; + margin-top: 4px; + margin-bottom: 4px; + } + h4.minitoc { + margin-left: 0mm; + font-weight: normal; + font-size: 90%; + margin-top: 2px; + margin-bottom: 2px; + } + h5.minitoc { + margin-left: 2mm; + font-weight: normal; + font-size: 85%; + margin-top: 2px; + margin-bottom: 2px; + } + h6.minitoc { + margin-left: 4mm; + font-weight: normal; + font-size: 85%; + margin-top: 2px; + margin-bottom: 2px; + } h1.c, h2.c, h3.c, h4.c, h5.c, h6.c, p.c { text-align: center } @@ -902,35 +1011,6 @@ WOK margin-bottom: 20px; margin-right: 15mm; } -/* - table.hidden { - color: #ffffff; - text-decoration: none; - } - td.hidden { - color: #ffffff; - background-color: #000000; - } - td.hidden a.active, div.hidden a:hover { - color: #ffffff; - background-color: #000000; - } - td.hidden a:hover { - text-decoration: none; - } - div.hidden a { - line-height: 12px; - margin: 0 0 0 0; - text-decoration: none; - color: #000077; - } - div.hidden a.active, div.hidden a:hover { - text-decoration: none; - } - div.hidden a:hover { - text-decoration: none; - } -*/ WOK end def homepage #stylesheet for index, home page diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index cb6d70f8..cf6d8e09 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -257,7 +257,7 @@ module SiSU_DAL when /\^~/ # endnotes #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_para=para.dup - @@endnote_array << sub_para.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/, %{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip + @@endnote_array << sub_para.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip endnote_no+=1 para=nil if para =~/\^~ .+/ #removes 'binary' endnote now in endnote array for later insertion end @@ -275,9 +275,9 @@ module SiSU_DAL end data.each do |para| para.strip! - if para =~/\{\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?\}(?:(?:https?|file|ftp):\S+|image)/ - if para !~/\{\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ - m=/\{\s*(\S+\.(?:png|jpg|gif))/ + if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ + if para !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ + m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ if @rmgk imgs=para.scan(m).flatten images=imgs.each do |image| @@ -306,7 +306,7 @@ module SiSU_DAL end end para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else para.gsub!(/\{\s*(\S+)\.(png|jpg|gif).+?\}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') + else para.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') end end else @@ -317,7 +317,7 @@ module SiSU_DAL end end end - para.gsub!(/\{\s+(\S+\.(?:png|jpg|gif))\s+/i,'{\1 ') if para =~/\{\s+\S+\.(?:png|jpg|gif).+?\}(?:(?:https?|file|ftp):\S+|image)/ + para.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ tuned_file << para unless para.nil? end tuned_file @@ -1147,7 +1147,7 @@ module SiSU_DAL #s=s.gsub(/¡¡\d+¡/,' ') # tables #s=s.gsub(/¡/,' ') # tables tidy later #s=s.gsub(/<.+?>/,'') - s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search + s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search s=s.gsub(/\s\s+/,' ') s=s.strip end diff --git a/lib/sisu/v0/dal_doc_str.rb b/lib/sisu/v0/dal_doc_str.rb index 37e9be3c..d34bf01e 100644 --- a/lib/sisu/v0/dal_doc_str.rb +++ b/lib/sisu/v0/dal_doc_str.rb @@ -216,15 +216,15 @@ module SiSU_document_structure end else ocno+=1 - if para=~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; ocnt+=1 #table + if para=~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; ocnt+=1 #table ocn_dv,ocn_sp="o#{ocno}","t#{ocnt}" - elsif para=~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/; ocnc+=1 #code block + elsif para=~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/; ocnc+=1 #code block ocn_dv,ocn_sp="o#{ocno}","c#{ocnc}" - elsif para=~/^#{Mx[:gr_o]}(?:group|alt|verse)#{Mx[:gr_c]}/; ocng+=1 #group, poem + elsif para=~/^#{Mx[:gr_o]}(?:group|alt|verse)#{Mx[:gr_c]}/; ocng+=1 #group, poem ocn_dv,ocn_sp="o#{ocno}","g#{ocng}" - elsif para=~/\{\S+?\.(?:png|jpg|gif)\s+/m; ocni+=1 #image + elsif para=~/#{Mx[:lnk_o]}\S+?\.(?:png|jpg|gif)\s+/m; ocni+=1 #image ocn_dv,ocn_sp="o#{ocno}","i#{ocni}" - else ocnp+=1 #paragraph + else ocnp+=1 #paragraph ocn_dv,ocn_sp="o#{ocno}","p#{ocnp}" end end diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index c3bd8a7d..35f0582a 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -273,10 +273,12 @@ module SiSU_Syntax 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 + line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ ([^}]+?)\s*\}((?:https?|file|ftp):\S+)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\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]} ") + line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s|$))/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\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 @@ -326,8 +328,9 @@ module SiSU_Syntax #line.gsub!(/<:\/hi>/,'') line.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n") line.gsub!(/[ ]+($)/,'\1') - #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 + line.gsub!(/\{\s*(.+?)\s*\}(https?:\S+)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked (text or image) + line.gsub!(/\{\s*(.+?)\s*\}(image)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image + #line.gsub!(/(#{Mx[:lnk_c]})\s*((?:https?|file|ftp):\S+?)/m,'\1\2') ##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") diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 1e788f8e..addd1ae1 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -141,8 +141,8 @@ module SiSU_DB_import string.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"
\n") string.gsub!(/#{Mx[:gr_o]}(?:code|alt|group|verse)(?:-end)?#{Mx[:gr_c]}/,'') string.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') - string.gsub!(/\{\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)\}\S+/,'[image: \1] \2') - string.gsub!(/\{\s*(.+?)\s*\}(?:https?|file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') + string.gsub!(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2') + string.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') end def strip_markup(string) #define rules, make same as in dal clean string.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') @@ -153,7 +153,7 @@ module SiSU_DB_import string.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' ') #tables string.gsub!(/#{Mx[:tc_p]}/u,' ') #tables tidy later string.gsub!(/<.+?>/,'') - string.gsub!(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search + string.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search string.gsub!(/\s\s+/,' ') string.strip! end diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 4129893a..821893fc 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -936,7 +936,7 @@ module SiSU_Viz } end - def margin_css + def margin_css #unused, check '
' end @@ -1627,11 +1627,13 @@ WOK #{table_close*4}} end def credits_sisu - %{#{widgets_open} + %{
+

+
#{widget_sisu} #{widget_way_better} -
} +

} end def credits_splash end diff --git a/lib/sisu/v0/digests.rb b/lib/sisu/v0/digests.rb index 9510a12a..42fa6962 100644 --- a/lib/sisu/v0/digests.rb +++ b/lib/sisu/v0/digests.rb @@ -161,8 +161,8 @@ module SiSU_Digest_view end ima=[] if para !~/^%+\s/ \ - and para =~/(?:^|[^_\\])\{(\S+\.(png|jpg|gif))\s.+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/ - images=para.scan(/(?:^|[^_\\])\{(\S+\.(?:png|jpg|gif))\s.+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/).flatten + and para =~/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/ + images=para.scan(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/).flatten else image=nil end x=case para diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 5b9639dd..5f0d0de9 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -106,7 +106,7 @@ module SiSU_HTML toc=SiSU_HTML::Source::Toc.new(data,@md).songsheet links_guide=SiSU_HTML::Source::Links_guide.new(data,@md).toc data=@tuned_file_array - scr_toc=SiSU_HTML::Source::Scroll_head_and_segtoc.new(data,@md,toc,links_guide).in_common #watch + scr_toc=SiSU_HTML::Source::Scroll_head_and_segtoc.new(@md,toc,links_guide).in_common #watch SiSU_HTML::Source::Seg.new(data,@md).songsheet data=@tuned_file_array scr=SiSU_HTML::Source::Scroll.new(data,@md).songsheet @@ -246,7 +246,7 @@ module SiSU_HTML end end class Toc [],:scr=>[] } + @@toc={ :seg=>[],:seg_mini=>[],:scr=>[] } @@seg_url='' @@dp,@@firstseg=nil,nil def initialize(data='',md=nil) @@ -255,12 +255,13 @@ module SiSU_HTML @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern @pat_heading=/^(?:#{Mx[:lv_o]}[1-6]:\S*?#{Mx[:lv_c]}\s*)?(.*)#{Mx[:id_o]}~(\d+);(?:[hm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @pat_strip_heading_name=/(.+?)<\/a>/ - @tell=SiSU_Screen::Ansi.new(@md.cmd) + @tell=SiSU_Screen::Ansi.new(@md.cmd) if @md end def songsheet #extracts toc for scroll & seg SiSU_Screen::Ansi.new(@md.cmd,'Toc').txt_grey unless @md.cmd =~/q/ toc=nil @@firstseg=nil + @@toc={ :seg=>[],:seg_mini=>[],:scr=>[] } @data.each do |para| if para =~/^(?:#{Mx[:lv_o]}[1-6]:|4~!)/ para_toc=para.dup @@ -282,6 +283,7 @@ module SiSU_HTML if toc begin @@toc[:seg] << toc[:seg] if toc[:seg] + @@toc[:seg_mini] << toc[:seg_mini] if toc[:seg_mini] @@toc[:scr] << toc[:scr] if toc[:scr] rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error end @@ -291,6 +293,10 @@ module SiSU_HTML @md.firstseg=@@firstseg @@toc end + def minitoc + minitoc=@@toc[:seg_mini].to_s + '
' + minitoc + '
' + end protected def rss #sort all wrong, disabled but kept @@toc[:seg] <<< \\2
}) + if seg_link =~/(#{Mx[:id_o]}\~\d+;(?:\w|[0-6]:\d+);\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/m + m=/#{$1}/m + seg_link.gsub!(m,'') + end @@seg_url=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?$/,1] elsif para =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ seg_link=para.gsub(/^\s*(#{@md.lv4}\s+)\s*(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/, @@ -443,6 +461,7 @@ WOK format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,seg_link) toc={} toc[:seg]=format_toc.lev4 + toc[:seg_mini]=format_toc.mini_lev4 if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ m=/#{$1}/ para.gsub!(m,'') @@ -476,6 +495,7 @@ WOK } format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,lnk_n_txt) toc[:seg]=format_toc.lev5 + toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}} end format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) @@ -504,6 +524,7 @@ WOK } format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,lnk_n_txt) toc[:seg]=format_toc.lev6 + toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}} end format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) @@ -535,8 +556,8 @@ WOK end end class Scroll_head_and_segtoc < Toc - def initialize(data,md='',toc='',links_guide_toc='') - @data,@md,@toc,@links_guide_toc=data,md,toc,links_guide_toc + def initialize(md='',toc='',links_guide_toc='') + @md,@toc,@links_guide_toc=md,toc,links_guide_toc @vz=SiSU_Env::Get_init.instance.skin end def in_common diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 03d97a8d..5e261649 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -85,7 +85,7 @@ module SiSU_HTML_Format ocn_class='ocn' @paranum.gsub(/^(\d+|)$/, %{

-   \\1 + \\1

}) end end @@ -638,53 +638,8 @@ WOK %{
#{@vz.paragraph_txt}} - end - def toc_endnote - %{#{@vz.margin_txt_3} -#{@vz.paragraph_font_small} - - Endnotes - -#{@vz.table_close}} end def title_endnote - %{#{@vz.margin_txt_0} - #{@vz.paragraph_txt} - -#{@vz.margin_num} -   -#{@vz.table_close}} - end - def tail - %{
-#{@vz.margin_txt_0} - - - -
-#{@vz.banner_band} - -
#@tocband_scroll
-
-
-#{@vz.paragraph_txt} -
- #{@vz.credits_splash} - #{@vz.credits_sisu} -
-#{@vz.margin_num} -#{@vz.table_close} - - - - - - - - #{@md.title*10} - - -} end end class Head_seg < Head_information @@ -860,25 +815,8 @@ WOK #{@vz.png_nav_toc} #{@vz.table_close}} - end - def toc_endnote end def title_endnote(title,subtitle,creator,table_top_control) - %{#{@vz.banner_instrument_cover_band_seg} -

- #{title} -

-

- #{subtitle} -

-

- #{creator} -

- -#{@vz.table_close} -

Endnotes

} end def navigation_table %{ @@ -934,18 +872,17 @@ WOK } end def credit - %{
-#{@vz.credits_splash} + %{#{@vz.credits_splash} #{@vz.credits_sisu} -} +} end - def navigation_band(segtocband,seg_table_top_control) - %{
+ def navigation_band(segtocband,seg_table_top_control) #change name to navigaion_band_banner + %{
@@ -957,10 +894,23 @@ WOK
#{@vz.banner_band}
#{seg_table_top_control}} + end + def navigation_band_bottom(segtocband,seg_table_top_control) #change name to navigaion_band_bannerless + %{
+

+ + + +
+ #{doc_types} + + #{segtocband} +
+#{seg_table_top_control} +

} end def endnote_mark %{

-


} #revisit end end @@ -998,51 +948,51 @@ WOK end @vz=SiSU_Env::Get_init.instance.skin end - def para_form(tag,attrib) # regular paragraphs shaped here + def para_form_css(tag,attrib) # regular paragraphs shaped here ul=ulc='' ul,ulc="
    \n ","\n
" if @tag =~/li/ - %{#{@vz.margin_css} - #{ul}<#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} + %{
+ #{@p_num.ocn_display} +#{ul}<#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #@parablock #{ulc} -#{@vz.margin_num_css} - #{@p_num.ocn_display} -#{@vz.table_close} +
} end def para - para_form('p','norm') + para_form_css('p','norm') end def code - para_form('p','code') + para_form_css('p','code') end def center - para_form('p','center') + para_form_css('p','center') end def bold - para_form('p','bold') + para_form_css('p','bold') end def bullet - para_form('li','bullet') + para_form_css('li','bullet') end def format(tag,atrib) - para_form(tag,atrib) + para_form_css(tag,atrib) end def dl "
#@one #@two
" end - def table_end # - %{
- #{@vz.margin_num_css.strip} - #{@p_num.ocn_display} - #{@vz.table_close}} + def table_css_end # + ' +

+ ' end def no_paranum - %{#{@vz.margin_css} -#{@vz.paragraph_txt} + %{
+

 

+

#@one #@two -#{@vz.margin_num} -#{@vz.table_close}} +

+
+} end def gsub_body case @one diff --git a/lib/sisu/v0/html_format_css.rb b/lib/sisu/v0/html_format_css.rb index ace6983b..106157ba 100644 --- a/lib/sisu/v0/html_format_css.rb +++ b/lib/sisu/v0/html_format_css.rb @@ -155,53 +155,29 @@ module SiSU_HTML_Format_type def initialize(md='') super(md) end - def toc_endnote - %{#{@vz.margin_css} -

- - Endnotes - -

-#{@vz.table_close}} - end end class Format_scroll < SiSU_HTML_Format::Format_text_object def initialize(md='',*txt) super(md,*txt) @vz=SiSU_Env::Get_init.instance.skin end - def indent_one_no_paranum - %{#{@vz.margin_txt_1} -#{@paragraph.txt} - #@one -#{@vz.margin_num} -#{@vz.table_close}} - end - def indent_two_no_paranum - %{#{@vz.margin_txt_1} -#{@paragraph.txt} - #@one -#{@vz.margin_num} -#{@vz.table_close}} - end def endnote_body - %{#{@vz.margin_css} -

- #@one + %{

+

 

+

+ #@one

-#{@vz.margin_num_css} -   -#{@vz.table_close}} +
+} end def header_normal - %{#{@vz.margin_css} + %{
+ #{@p_num.ocn_display} <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #@headname #@parablock -#{@vz.margin_num_css} - #{@p_num.ocn_display} -#{@vz.table_close}} +
} end def heading_body @tag,@class='p','norm' @@ -236,13 +212,6 @@ module SiSU_HTML_Format_type def initialize(md='',*txt) super(md,*txt) end - def navigation_para - %{#{@vz.margin_css} -#{@paragraph.txt} - #@one -

-#{@vz.table_close}} - end def navigation_toc_lev1_advert %{#{@banner.home_button}\n
@@ -291,39 +260,36 @@ module SiSU_HTML_Format_type end def navigation_toc_lev6 end - def endnote_body_seg_tail - %{#{@vz.margin_css} + def endnote_body_seg_tail #FIX + %{

#@one

-#{@vz.margin_num_css}  -#{@vz.table_close}} +
} end def endnote_body_seg_tail_indent - %{#{@vz.margin_css} + %{

#@one

-#{@vz.margin_num_css}  -#{@vz.table_close}} +
} end - def endnote_seg_body(fn='') #url construction keep within single line... BUG WATCH 200408 + def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info - %{#{@vz.margin_css} + %{

#@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three

-#{@vz.margin_num_css}  -#{@vz.table_close}} +
} end def title_header - %{#{@vz.margin_css} - <#@tag class="#@class"> + %{
+ #@two +<#@tag class="#@class"> #@one -#{@vz.margin_num_css}  -#@two -#{@vz.table_close}} +
+} end def title_header1 @tag,@class='h1','banner' @@ -338,12 +304,12 @@ module SiSU_HTML_Format_type title_header end def title_header4 - %{#{@vz.margin_css} + %{
+

 

-#{@vz.margin_num_css}  -#{@vz.table_close}} +
} end def subtoc_lev one=if @one \ @@ -374,25 +340,22 @@ module SiSU_HTML_Format_type end #% para sisu def header4 - %{#@format #{@vz.margin_css} + %{
+#{@p_num.ocn_display}

#{@p_num.name} #@format #@parablock

-#{@vz.margin_num_css} -#{@p_num.ocn_display} -#{@vz.table_close}} +
} end def header_sub @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') - %{#{@vz.margin_css} -#{@headname} - <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} + %{
+ #{@p_num.ocn_display} + <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #{@headname} #{@parablock} -#{@vz.margin_num_css} -#{@p_num.ocn_display} -#{@vz.table_close}} +
} end def header5 @tag,@class='p','bold' @@ -419,17 +382,6 @@ module SiSU_HTML_Format_type %{

#@parablock

} - end - def navigation_indent1 - %{#{@vz.margin_txt_00_1} -#{@paragraph.txt_00} - #@parablock - -

-#{@vz.margin_num_css}  -#{@vz.table_close}} - end - def navigation_indent2 end def navigation_center "
#@parablock
" @@ -475,6 +427,27 @@ module SiSU_HTML_Format_type def lev0 #docinfo lev('h0','toc') end + def mini_lev1 + lev('h1','minitoc') + end + def mini_lev2 + lev('h2','minitoc') + end + def mini_lev3 + lev('h3','minitoc') + end + def mini_lev4 + lev('h4','minitoc') + end + def mini_lev5 + lev('h5','minitoc') + end + def mini_lev6 + lev('h6','minitoc') + end + def mini_lev0 #docinfo + lev('h0','minitoc') + end end end __END__ diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index a15c302e..e632c835 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -69,7 +69,7 @@ module SiSU_HTML_seg @@loop_count=@@seg_total=@@tracker=0 @@is4=@@is3=@@is2=@@is1=0 @@header1=@@header2=@@header3=@@header4=0 - @@seg[:tocband],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(9){[]} + @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(10){[]} @@seg[:header_endnotes]='' @@tablehead,@@number_of_cols=0,0 @@flag_alt=false @@ -85,6 +85,7 @@ module SiSU_HTML_seg end def songsheet begin + @@minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc data=get_subtoc_endnotes(@data) data=articles(data) Seg.new.cleanup # (((( added )))) @@ -192,6 +193,8 @@ module SiSU_HTML_seg end end end + @@seg[:main] << '' + data end def header_art(para) format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) @@ -215,7 +218,8 @@ module SiSU_HTML_seg @p_num ||= '' if @@is1 == 1 @dc_creator=%{#{@md.dc_creator}\n} if @md.dc_creator.to_s =~/\S/ - @@seg[:tocband] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) + @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) + @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format_type::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 @@ -320,14 +324,16 @@ module SiSU_HTML_seg elsif para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \ and para =~/^#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ format_txt_obj.gsub_body - @sto.seg_lev_para_ocn.table_end + @sto.seg_lev_para_ocn.table_css_end else para end else para end elsif para =~/#{Mx[:tc_p]}|#{Mx[:gr_o]}T[hZ]?/u + @sto=nil table=SiSU_HTML_shared::Table.new(para) para=table.table + else @sto=nil end if @md.flag_separate_endnotes para.gsub!(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{@md.sfx}#_\\1">}) #endnote- twice #removed file type @@ -345,8 +351,9 @@ module SiSU_HTML_seg para=format_seg.no_paranum end end - if @sto.format=~/4:\S+/ + if @sto and @sto.format=~/4:\S+/ para.gsub!(/^\s*4:\S+\s*|<:[-_\w\d]?(-.+?-)?>|4~!.+/m,'') #sort seg headers + @@seg[:main] << '
' @@seg[:main] << para @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc else @@ -361,20 +368,19 @@ module SiSU_HTML_seg @@seg[:tail] << format_head_seg.endnote_mark @@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| end - @@seg[:tail] << '
 
' ads=SiSU_HTML_promo::Ad.new(@md) @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close end def output(type='') if @@seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... filename_seg=[] - filename_seg << @@seg[:title] << @@seg[:tocband] + filename_seg << @@seg[:title] << @@seg[:tocband_banner] if type !~/endnote/ - filename_seg << @@seg[:headers] << @@seg[:main] + filename_seg << @@minitoc << @@seg[:main] else - filename_seg << @@seg[:header_endnotes] << @@seg[:endnote_all] + filename_seg << @@seg[:header_endnotes] << @@minitoc << '
' << @@seg[:endnote_all] end - filename_seg << @@seg[:tail] << @@seg[:tocband] << @@seg[:credits] + filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] filename_seg.flatten!.compact! filename_seg.each do |para| unless para =~/\A\s*\Z/ @@ -386,7 +392,7 @@ module SiSU_HTML_seg end end def reinitialise - @@seg[:title],@@seg[:dot_nav],@@seg[:tocband],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(7){[]} + @@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]} @@segtocband=nil end def cleanup diff --git a/lib/sisu/v0/html_table.rb b/lib/sisu/v0/html_table.rb index 1aed4f5d..ffba4b0b 100644 --- a/lib/sisu/v0/html_table.rb +++ b/lib/sisu/v0/html_table.rb @@ -67,17 +67,17 @@ module SiSU_HTML_table @one,@parablock,@vz=one,one,SiSU_Env::Get_init.instance.skin end def table_head(inf) - %{ - - -
-

-
+ %{
+

+ #{inf} +

+

} end def table_end(tablefoot='') - %{
#{@vz.margin_num}#{@vz.margin_num} #{@vz.table_close} -#{tablefoot}} + %{

+#{tablefoot} +
} end def table_row(inf,h=false) bold=if h; '' @@ -109,7 +109,7 @@ module SiSU_HTML_table tablefoot=[] @@tablefoot.each {|x| tablefoot << ''} @@tablefoot=[] - if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock=table_end + if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock="

\n
" #table_end end end if @@tablehead == 1 diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 11976af9..9cc50b23 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -254,10 +254,10 @@ module SiSU_Tune def urls(data) @words=[] data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|file|ftp)\S+|image)/ - if word =~/\{.+?\}(?:(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)[;.,]?(?:\s|$)/ - m,u,d=/\{(.+?)\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)([;.,]?(?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|file|ftp)\S+|image)/.match(word).captures + @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ + if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)[;.,]?(?:\s|$)/ + m,u,d=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)([;.,]?(?:\s|$))/.match(word).captures + else m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/.match(word).captures d='' end case m @@ -276,13 +276,13 @@ module SiSU_Tune %{#{caption}} else %{#{caption}} end - word.gsub!(/\{.+?\}((?:https?|file|ftp)\S+|image)/,ins) + 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}} - word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) + word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp)\S+/,ins) end word else word @@ -313,8 +313,8 @@ module SiSU_Tune para.gsub!(/<:image\s+(\S+)\s+>/, %{}) end - if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ - @word_mode=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u) + if para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ + @word_mode=para.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u) words=urls(@word_mode) para.gsub!(/.+/m,words) end @@ -336,7 +336,7 @@ module SiSU_Tune para.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<\1>') end para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url + 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 if para =~/..\/\S+/ \ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ diff --git a/lib/sisu/v0/hub.rb b/lib/sisu/v0/hub.rb index b3815828..58ea4c4f 100644 --- a/lib/sisu/v0/hub.rb +++ b/lib/sisu/v0/hub.rb @@ -134,6 +134,7 @@ module SiSU #when /^air$/; SiSU_Air::Source.new(@opt).read # -A when /^plaintext$/; SiSU_Plaintext::Source.new(@opt).read # -a when /^wikispeak$/; SiSU_Wikispeak::Source.new(@opt).read # -g + #when /^wikispeak$/; SiSU_Wikispeak::Source.new(@opt).read # -g when /^odf$/; SiSU_ODF::Source.new(@opt).read # -o when /^xml_md_oai_pmh_dc$/; SiSU_XML_metadata::OAI_PMH.new(@opt).read # -O when /^texpdf$/; SiSU_TeX::Source.new(@opt).read # -p @@ -278,7 +279,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.mod.inspect =~/--convert|--to|--from/ require "#{SiSU_lib}/sst_convert_markup" end - if @opt.cmd =~/([AabCcDdFfgGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ \ + if @opt.cmd =~/([AabCcDdFfGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ \ and @opt.cmd =~/^-/ \ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ #and @@ -425,6 +426,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end if @opt.cmd =~/g/; op('wikispeak','wikispeak') #% -g wiki end + #if @opt.cmd =~/g/; op('wikispeak','wikispeak') #% -g wiki + #end if @opt.cmd =~/o/; op('odf','OpenDocument') #% -o opendocument end if @opt.cmd =~/x/; op('xml','xml sax') #% -x xml sax type diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index 06878094..edbb55f9 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -277,7 +277,7 @@ WOK para.gsub!(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,"#{Mx[:br_line]}.B \\1#{Mx[:br_line]}") para.gsub!(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,"#{Mx[:br_line]}.I \\1#{Mx[:br_line]}") unless para =~/#{Mx[:gr_o]}code#{Mx[:gr_c]}/ - para.gsub!(/(?:^|\s)\{(.+?)\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1 #{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") + para.gsub!(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1 #{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1#{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") @manpage[:endnotes]=extract_endnotes(para) para.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]') # endnote marker marked up @@ -332,8 +332,8 @@ WOK para.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links para.gsub!(/ /,' ') # decide on para.gsub!(/(["''])/,"\\\\\\1") # quotation marks need escape - para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - para.gsub!(/^(?:^|[^_\\])\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") + para.gsub!(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') wordlist=para.scan(/\S+/) if para =~/^#{Rx[:meta]}\s*(.+?)\Z/m # for headers d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 09c67ff6..f3e3385f 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -222,13 +222,13 @@ module SiSU_ODF end def image(para) para.gsub!(@serial,'') - m=para.scan(/(\{\s*(.+?)\}((?:https?|file|ftp)\S+|image))/) + m=para.scan(/(#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image))/) if m; m.each do |i| cont,url=i[1],i[2] cont.gsub!(/([)(\]\[])/,"\\\\\\1") cont.gsub!(/([+?])/,"\\\\\\1") # incorrect handling of + url.gsub!(/([+?])/,"\\\\\\1") - para.sub!(/\{\s*#{cont}\}#{url}/m,image_odf(i)) #watch + para.sub!(/#{Mx[:lnk_o]}\s*#{cont}\s*#{Mx[:lnk_c]}#{url}/m,image_odf(i)) #watch para.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix end m=nil @@ -242,12 +242,12 @@ module SiSU_ODF end def text_link(para) para.gsub!(@serial,'') - m=para.scan(/(\{([^}]+?)\}((?:https?|file|ftp)\S+?))([;.,]?(?=\s|$))/) #sort + m=para.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+?))([;.,]?(?=\s|$))/) #sort if m m.each do |i| txt,url,trail=i[1],i[2] txt.gsub!(/([)(\]\[])/,"\\\\\\1") - txt.gsub!(/([+?])/,"\\\\\\1") # problems with + + txt.gsub!(/([+?*])/,"\\\\\\1") # problems with + url.gsub!(/([+?])/,"\\\\\\1") # problems with + para.gsub!(/\{\s*#{txt}\}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url para.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix @@ -260,7 +260,7 @@ module SiSU_ODF para.gsub!(@serial,'') para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, '\1\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + 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 @@ -368,8 +368,8 @@ module SiSU_ODF n3=lv + 2 lv=nil if lv == 0 para=unless para=~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ - para=if para =~/\{\s*\S+?\.(?:png|jpg|gif)\s.+?\}(?:(?:https?|file|ftp):\S+|image)/; image(para) - elsif para =~/\{.+?\}(?:(?:https?|file|ftp):\S+|image)/; text_link(para) + para=if para =~/#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/; image(para) + elsif para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/; text_link(para) else para end else para @@ -485,7 +485,7 @@ module SiSU_ODF para.gsub!(/^\s*#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'') # remove empty lines para.gsub!(/(.+?)<\/a>/,'\1') para.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links -# para.gsub!(/(.+?)<\/a>/im,'\1') + #para.gsub!(/(.+?)<\/a>/im,'\1') #para.gsub!(/ /,' ') # decide on #para.gsub!(/\{(\S+?\.(?:png|jpg)) .+?\}(?:http:\/\/\S+|image)/," [ \\1 ]") #"[ #{@env.url.images_local}\/\\1 ]") #para.gsub!(/<\s]+?)([.,]?(?:\s|$))/,"\\1#{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") para.gsub!(/_((?:https?|file|ftp):\/\/\S+)/,'\1') extract_endnotes(para) @@ -322,7 +322,7 @@ WOK para.gsub!(/(.+?)<\/a>/m,'\1') para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links para.gsub!(/ /,' ') # decide on - para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") para.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') #para.gsub!(/^\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') wordlist=para.scan(/\S+/) diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index a930821e..a4e40685 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -92,10 +92,10 @@ module SiSU_Format_Shared def urls(data) @words=[] data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|file|ftp)\S+|image)/ - if word =~/\{(.+?)\}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/ - m,u,d=/\{(.+?)\}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|file|ftp)\S+|image)/.match(word).captures + @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ + if word =~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/ + m,u,d=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/.match(word).captures + else m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/.match(word).captures d='' end word=case m @@ -114,14 +114,14 @@ module SiSU_Format_Shared %{[#{png}]#{caption}} else %{[#{png}] #{caption}} end - word.gsub!(/\{.+?\}((?:https?|file|ftp)\S+|image)/,ins) + 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!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) + word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp)\S+/,ins) end else word end @@ -131,14 +131,14 @@ module SiSU_Format_Shared end def markup(para) if para !~/^#{Mx[:gr_o]}:code#{Mx[:gr_c]}/ - if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ - wm=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|\S+/) + 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[: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)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url + 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 diff --git a/lib/sisu/v0/shared_structure.rb b/lib/sisu/v0/shared_structure.rb index f7b78e0e..506b5097 100644 --- a/lib/sisu/v0/shared_structure.rb +++ b/lib/sisu/v0/shared_structure.rb @@ -9,8 +9,7 @@ * Author: Ralph Amissah * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, - 2008 Ralph Amissah All Rights Reserved. + 2007, 2008 Ralph Amissah All Rights Reserved. * License: GPL 3 or later: diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 3c34e67f..9203f0df 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -377,16 +377,16 @@ module SiSU_XML_munge para.gsub!(/#{Mx[:br_page]}\s*/,'') para.gsub!(/#{Mx[:br_page_new]}\s*/,'') para.gsub!(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''); para.gsub!(/<[-~]#>/,'') - para.gsub!(/(?:^|[^_\\])\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/, - %{[\\1] \\4}) - para.gsub!(/(?:^|[^_\\])\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/, - %{\\1}) - para.gsub!(/(^|#{Mx[:gl_c]}|\s)\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/, + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}(https?:\/\/\S+)/, + %{[\\1] \\4}) + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?#{Mx[:lnk_c]}(https?:\/\/\S+)/, + %{\\1}) + para.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/, '\1\2\4') #watch, compare html_tune para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, %{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, - '\1\2') #escaped urls not linked, deal with later + '\1\2') #escaped urls not linked, deal with later para.gsub!(/ /,' ') #para.gsub!(/ /,' ') #clean else @@ -406,7 +406,7 @@ module SiSU_XML_munge para.gsub!(/<[-~]#>/,'') para.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort para.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax - para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, "#{@dir.url.images_local}\/\\1") para.gsub!(/ /,' ') #para.gsub!(/ /,' ') #clean @@ -429,7 +429,7 @@ module SiSU_XML_munge para.gsub!(/<[-~]#>/,'') para.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort para.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax - para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, "#{@dir.url.images_local}\/\\1") para.gsub!(/ /,' ') #para.gsub!(/ /,' ') #clean diff --git a/lib/sisu/v0/sst_do_inline_footnotes.rb b/lib/sisu/v0/sst_do_inline_footnotes.rb index 5cfd38da..ba1f6379 100644 --- a/lib/sisu/v0/sst_do_inline_footnotes.rb +++ b/lib/sisu/v0/sst_do_inline_footnotes.rb @@ -475,6 +475,7 @@ module SiSU_Convert_footnotes s=s.gsub(/(\d+)<\/sup>/,'[\1]') s=s.gsub(/(?: \\;)+/,' ') s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search + s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search s=s.gsub(/\s\s+/,' ') s=s.strip end diff --git a/lib/sisu/v0/sst_to_s_xml_dom.rb b/lib/sisu/v0/sst_to_s_xml_dom.rb index 23143ed8..5976d82b 100644 --- a/lib/sisu/v0/sst_to_s_xml_dom.rb +++ b/lib/sisu/v0/sst_to_s_xml_dom.rb @@ -365,6 +365,8 @@ WOK para.gsub!(/<:pb>\s*/,'') para.gsub!(/\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, "#{dir.url.images_local}/\\1") + para.gsub!(/#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, + "#{dir.url.images_local}/\\1") para.gsub!(/ /,' ') para=SiSU_document_structure::Structure.new(@md,para).structure @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index 42d62960..b627b616 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -482,7 +482,7 @@ WOK end def http # very messy clean up ! - work area, testing - z=@para[/\\\{(.+?)\}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! + z=@para[/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! url=@para[/((?:https?|file|ftp):\S+)/im,1] if @para =~/\.(png|jpg|gif)/ image,w,x,y=z.scan(/\S+/) @@ -496,11 +496,11 @@ WOK end if image dir=SiSU_Env::Info_env.new(@md.fns) - @para.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! + @para.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! "\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}") else link=z[/(.+?)\\/im,1] - @para.gsub!(/\{.+?\}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! + @para.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! end end end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 8d951dfb..e4bd9c00 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -435,7 +435,7 @@ module SiSU_TeX end elsif x =~/code/; @@flag_alt,@@flag_code=true,true elsif @@flag_alt - if para =~ /\}(?:https?|file|ftp)/m + if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/m para=SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http end @group_collect << para #<< "\n\n" @@ -485,7 +485,7 @@ module SiSU_TeX when /^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/; mono.indent($1) when /<:=/; mono.symbol_graphic #watch when /^\s*<:image\s+/; mono.image - when /\}image/; mono.png + when /#{Mx[:lnk_c]}image/; mono.png else para.strip! para=enclose(para) unless para =~/^$/ @@ -499,7 +499,7 @@ module SiSU_TeX end para end - if para =~ /\}(?:https?|file|ftp)/ + if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/ para=if para !~/\.(?:png|jpg|gif)/ SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http else diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 0fa439f0..a3f2f7d2 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -375,12 +375,12 @@ para else tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_tex}") tell.error2 unless @md.cmd =~/q/ - @string.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! + @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! end end def image dir=SiSU_Env::Info_env.new(@md.fns) - image,m=/<:image\s+(\S+)\s+.+?width=``(\d+)''.+?>/m.match(@string).captures + image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@string).captures width=m[1] || '100' width=width.to_i*0.4 image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ @@ -397,17 +397,17 @@ para nil end if image_source - @string.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/, + @string.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/, @center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end ) - @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/, + @string.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/, @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) - else @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/,'\1}') + else @string.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}') end end def png #fc missing image check dir=SiSU_Env::Info_env.new(@md.fns) # messy clean up - z=@string[/\\\{(\S.+?)\}(?:image|png)/,1].strip if @string =~ /\\\{\S.+?\}(?:image|png)/ # match operator for z \\ fragile ! + z=@string[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @string =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile ! if z #debug 2004w14 image=z[/(\S+?\.(?:png|jpg|gif)\b)/m] image.gsub!(/\\/,'') @@ -438,29 +438,28 @@ para nil end if image_source - @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/, # fragile match operator\\ fragile ! + @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile ! "#@center_begin\n\\includegraphics*[width=#{width}pt]{#{image_source}/#{image}}#{caption}#@center_end") - else - @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,'') # fragile match operator\\ fragile ! + else @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'') end end def http_word_mode #(orientation='') # clean up ! - work area, testing dir=SiSU_Env::Info_env.new(@md.fns) @words=[] - @url_generic_rgx=/\\\{.+?\\?\}(?:https?|file|ftp):\S+/ + @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ @string.each do |word| @words << if word=~@url_generic_rgx - if word =~/\\\{(?:.+?)\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ - regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ - punctuate=/\\\{.+?\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join + if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ + regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ + punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join else - regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ + regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\S+)/ punctuate='' end z,url=regx_url.match(word).captures if word =~regx_url url=url.strip - if word =~/\{\s*\S+\.?(?:png|jpg|gif)/ \ + if word =~/#{Mx[:lnk_o]}\s*\S+\.?(?:png|jpg|gif)/ \ and word=~/\s+\d+x\d+\s+/ image,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') @@ -486,37 +485,37 @@ para "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" else '' end - elsif word =~/\{\s*(\S+\.?\.(?:png|jpg|gif))/ + elsif word =~/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/ tell=SiSU_Screen::Ansi.new(@md.cmd,%{document built without image: "#{$1}" as image dimensions not provided (& librmagick-ruby is not installed)?\n}) tell.print_grey #unless @opt.cmd =~/q/ end word=if image #most images fc etc. #% clean up ! word=if @md.fns =~/\.(?:ssm\.)?sst$/ \ and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") - word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ + word=if word =~ /(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/ "#@center_begin\\\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_local_tex}/#{image}}}#{caption} #@center_end" end word elsif @md.fns =~/\.-ss[tm]$/ \ and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") - word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ + word=if word =~ /(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/ "#@center_begin\\\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_remote_tex}/#{image}}}#{caption}#@center_end" end word elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}") - word=if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ + word=if word =~/(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/ "#@center_begin\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}#@center_end" end word else tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_local_tex},#{dir.path.image_source_remote_tex} and #{dir.path.image_source_tex}") tell.error2 unless @md.cmd =~/q/ - word='' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/ + word='' if word =~ /#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ word end else link=z.strip #[/(.+?)\\/m,1] - word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/ + word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ word end else word @@ -526,7 +525,7 @@ para @words end def http - wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) + wm=@string.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm,@ps).http_word_mode #GET PAPER SIZE AND USE IT end def title @@ -993,7 +992,7 @@ WOK string.gsub!(/\#/,'\#') string.gsub!(/\%/,'\%') string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes - if string !~/^\s*<:image|\}:image\s/ + if string !~/^\s*#{Mx[:lnk_o]}|#{Mx[:lnk_c]}image\s/ string.gsub!(/_/,'\_') end string.gsub!(/\{/,'\{') @@ -1013,11 +1012,15 @@ WOK string.gsub!(/&\S+?;/,' ') string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') - string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case - string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + '\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url + string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, + ' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case + string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + '\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code - string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start else #code-block: angle brackets special characters, note _ already escaped string.gsub!(/\\_/,'{\UseTextSymbol{OML}{>}}') @@ -1025,7 +1028,8 @@ WOK string.gsub!(/<:ee>/,'') string.gsub!(//,' ') #proposed change, insert, but may be redundant - string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~||<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') #string.gsub!(/(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') @@ -1049,7 +1053,8 @@ WOK string.gsub!(/\s+'/,' `') # open ' string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') # open ' end - string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ + string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/, + '\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ string.gsub!(/(|<\/font>)/,'') string.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') #string.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_paragraph]}|\n)\*/,' \\\\ ') @@ -1084,7 +1089,8 @@ WOK #string.gsub!(/<=asterisk>/,'{\ast}') #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' - string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic + string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/, + '^\copyright \textnormal{\1} \2') # watch likely to be problematic string end def xetex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list @@ -1153,7 +1159,7 @@ WOK string.gsub!(/\#/,'\#') string.gsub!(/\%/,'\%') string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes - if string !~/^\s*<:image|\}:image\s/ + if string !~/^\s*#{Mx[:lnk_o]}|#{Mx[:lnk_c]}image\s/ string.gsub!(/_/,'\_') end string.gsub!(/\{/,'\{') @@ -1173,11 +1179,15 @@ WOK string.gsub!(/&\S+?;/,' ') string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') - string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case - string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + '\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url + string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, + ' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case + string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + '\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code - string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start else #code-block: angle brackets special characters, note _ already escaped string.gsub!(/\\_/,'{\UseTextSymbol{OML}{>}}') @@ -1185,7 +1195,8 @@ WOK string.gsub!(/<:ee>/,'') string.gsub!(//,' ') #proposed change, insert, but may be redundant - string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~||<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') #string.gsub!(/(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') @@ -1249,7 +1260,8 @@ WOK #string.gsub!(/<=asterisk>/,'{\ast}') #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' - string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic + string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/, + '^\copyright \textnormal{\1} \2') # watch likely to be problematic string end def special_characters_curly(string) diff --git a/lib/sisu/v0/wikispeak.rb b/lib/sisu/v0/wikispeak.rb index 967387d9..2b0ba560 100644 --- a/lib/sisu/v0/wikispeak.rb +++ b/lib/sisu/v0/wikispeak.rb @@ -253,7 +253,7 @@ WOK para.gsub!(/(.+?)<\/i>/,"''\\1''") para.gsub!(/(.+?)<\/b>/,"'''\\1'''") para.gsub!(/(.+?)<\/u>/,'_\1_') - para.gsub!(/\{(.+?)\}(https?:\/\/\S+)/,'[\2 \1]') + para.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(https?:\/\/\S+)/,'[\2 \1]') para.gsub!(/(https?:\/\/\S+)/,'[\1]') para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})?/,'') para.gsub!(/<:p[bn]>/,'') # remove page breaks @@ -261,8 +261,8 @@ WOK para.gsub!(/(.+?)<\/a>/m,'\1') para.gsub!(/<:name#\S+?>/,'') # remove name links para.gsub!(/ /,' ') # decide on - para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - para.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') #para.gsub!(/^\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') wordlist=para.scan(/\S+/) if para =~/^0~(\S+)\s+(.+?)\Z/m # for headers -- cgit v1.2.3 From e25335596d5c77fd9edb8f806373a41cfdf90622 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Aug 2008 01:30:04 -0400 Subject: html, css and related markup --- lib/sisu/v0/css.rb | 516 ++++++++++++++-------------------------- lib/sisu/v0/html_format.rb | 67 +++--- lib/sisu/v0/html_format_css.rb | 54 +++-- lib/sisu/v0/html_segments.rb | 7 +- lib/sisu/v0/html_table.rb | 11 +- lib/sisu/v0/shared_html_lite.rb | 2 +- 6 files changed, 267 insertions(+), 390 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index 52de3351..f4dfc15f 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -107,6 +107,7 @@ WOK body { color: black; background: "#ffffff"; + background-color: "#ffffff"; } /* table { @@ -128,9 +129,12 @@ WOK color: #003399; text-decoration: none; } -/* a:hover { color: #000000; + background-color: #f9f9aa; + } +/* + a:hover { border-bottom: 2px solid #777777; background-color: #fff3b6; } @@ -150,6 +154,7 @@ WOK margin-left: 5%; margin-right: 1%; } + #top_band { position: absolute; top: 0; @@ -197,7 +202,16 @@ WOK margin-left: 75%; width: 20%; } - ul, li, p { + + .norm, .bold { + line-height: 150%; + margin-left: 1em; + margin-right: 2em; + margin-top: 10px; + margin-bottom: 0px; + text-indent: 0mm; + } + p, h0, h1, h2, h3, h4, h5, h6 { display: block; font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-size: 100%; @@ -205,15 +219,12 @@ WOK line-height: 150%; text-align: justify; margin-left: 1em; + margin-right: 2em; text-indent: 0mm; margin-top: 3px; margin-bottom: 3px; - /* margin-bottom:0; */ - margin-right: 2em; - /* width: 90%; */ - } - p.norm { } + p.norm { } p.i1 {margin-left: 2em;} p.i2 {margin-left: 3em;} p.i3 {margin-left: 4em;} @@ -223,40 +234,33 @@ WOK p.i7 {margin-left: 8em;} p.i8 {margin-left: 9em;} p.i9 {margin-left: 10em;} + p.code { font-family: inconsolata, andale mono, courier new, courier, monospace; font-size: 90%; text-align: left; } + p.caption { text-align: left; font-size: 80%; display: inline; } + p.endnote { - font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-size: 96%; - font-weight: normal; line-height: 120%; text-align: left; - margin-left: 1em; - text-indent: 0mm; - margin-top: 3px; - margin-bottom: 3px; margin-right: 15mm; } p.endnote_indent { - font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; font-size: 96%; - font-weight: normal; line-height: 120%; text-align: left; margin-left: 2em; - text-indent: 0mm; - margin-top: 3px; - margin-bottom: 3px; margin-right: 15mm; } + p.center { text-align: center; } @@ -272,25 +276,7 @@ WOK font-style: normal; background: #fff3b6; } - p.ocn, p.paranum { - font-size: 10px; - margin-top: 0px; - float: right; - width: 5%; - margin-bottom: 5px; - color: #777777; - margin-right: 5px; - text-align: right; - } - p.ocn_off, p.no_paranum { - display: none; - font-size: 10px; - margin-top: 0px; - margin-bottom: 5px; - color: #777777; - margin-right: 5px; - text-align: right; - } + p.small { font-size: 80%; margin-top: 0px; @@ -298,7 +284,8 @@ WOK margin-right: 6px; text-align: left; } - p.tiny { + + p.tiny, p.tiny_left, p.tiny_right, p.tiny_center { font-size: 10px; margin-top: 0px; margin-bottom: 0px; @@ -306,33 +293,23 @@ WOK margin-right: 6px; text-align: left; } + p.tiny { } p.tiny_left { - font-size: 10px; - margin-top: 0px; - margin-bottom: 0px; - color: #777777; margin-left: 0px; margin-right: 0px; text-align: left; } p.tiny_right { - font-size: 10px; - margin-top: 0px; - margin-bottom: 0px; - color: #777777; - margin-right: 5mm; + margin-right: 1em; text-align: right; } p.tiny_center { - font-size: 10px; - margin-top: 0px; - margin-bottom: 0px; - color: #777777; margin-left: 0px; margin-right: 0px; text-align: center; } - p.pane { + + p.pane, p.pane_title, p.pane_blurb, p.pane_link, p.pane_indent { font-size: 80%; margin-top: 0px; margin-bottom: 0px; @@ -340,39 +317,26 @@ WOK margin-right: 4px; text-align: left; } + p.pane { } p.pane_title { font-weight: bold; - font-size: 80%; - margin-top: 0px; margin-bottom: 0px; - margin-left: 2mm; - margin-right: 4px; - text-align: left; } p.pane_blurb { font-size: 10px; - margin-top: 0px; margin-bottom: 0px; - margin-left: 2mm; - margin-right: 4px; - text-align: left; } p.pane_link { font-size: 10px; - margin-top: 0px; margin-bottom: 0px; margin-left: 4mm; - margin-right: 4px; - text-align: left; } p.pane_indent { font-size: 10px; - margin-top: 0px; margin-bottom: 0px; margin-left: 4mm; - margin-right: 4px; - text-align: left; } + p.concordance_word { line-height: 150%; font-weight: bold; @@ -384,19 +348,17 @@ WOK font-size: 80%; color: #777777; display: inline; - margin-left: 0mm; - text-indent: 0mm; + margin-left: 0em; } p.concordance_object { font-size: 80%; - font-weight: normal; line-height: 120%; text-align: left; - margin-left: 15mm; - text-indent: 0mm; + margin-left: 3em; margin-top: 1px; margin-bottom: 3px; } + p.quickref { font-size: 10px; font-style: italic; @@ -416,6 +378,19 @@ WOK text-align: center; } + label.ocn { + width: 2%; + float: right; + top: 0; + font-size: 10px; + margin-top: 0px; + margin-bottom: 5px; + color: #777777; + margin-right: 5px; + text-align: right; + background-color: #ffffff; + } + table { } tr { } th, td { } @@ -431,76 +406,6 @@ WOK text-align: right; } - h0, h1, h2, h3, h4, h5, h6 { - display: block; - font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; - font-weight: bold; - line-height: 120%; - margin-left: 5mm; - margin-right: 5mm; - text-align: left; - margin-top: 20px; - margin-bottom: 10px; - } - h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { - text-align: center; - } - - ul { - list-style: none; - } - ul.horizontal { - list-style: none; - } - ul.vertical { - list-style: none; - } - - li { - background: url(../image/bullet_09.png) no-repeat 0px 6px; - padding-left: 20px; - display: block; - font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; - font-weight: normal; - line-height: 150%; - text-align: left; - margin-left: 1em; - text-indent: 0mm; - margin-top: 3px; - margin-bottom: 3px; - margin-right: 10mm; - } - li.bullet { - margin-left: 1em; - } - li.i1 { - margin-left: 2em; - } - li.i2 { - margin-left: 3em; - } - li.i3 { - margin-left: 4em; - } - li.i4 { - margin-left: 5em; - } - li.i5 { - margin-left: 6em; - } - li.i6 { - margin-left: 7em; - } - li.i7 { - margin-left: 8em; - } - li.i8 { - margin-left: 9em; - } - li.i9 { - margin-left: 10em; - } - #horizontal_links { background: #eeeeee; margin-left: 5%; @@ -534,6 +439,7 @@ WOK #horizontal a:hover { color: #000077; } + #document_versions { position: absolute; top: 10mm; @@ -541,6 +447,7 @@ WOK width: 12%; float: right; } + #vertical_links { position: absolute; top: 10mm; @@ -550,22 +457,10 @@ WOK float: right; } #vertical { - /* background: none; */ padding: 0 12px 0px 0px; - /* border-top: 2px solid #000077; */ - /* border-bottom: 2px solid #000077; */ - /* margin-left: 33%; */ margin-left: 2%; margin-right: 2%; } -/* - #vertical { - padding: 0 12px 0px 0px; - border-top: 2px solid #000077; - border-bottom: 2px solid #000077; - margin-left: 33%; - margin-right: 33%; - } */ #vertical li { display: block; list-style-type: none; @@ -581,10 +476,40 @@ WOK color: #000077; } - li.doc { + ul, li { + list-style-type: none; + list-style: none; + padding-left: 20px; + display: block; + font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; + font-weight: normal; + line-height: 150%; + text-align: left; + text-indent: 0mm; + margin-left: 1em; + margin-right: 2em; + margin-top: 3px; + margin-bottom: 3px; + } + + li { background: url(../image/bullet_09.png) no-repeat 0px 6px; - padding-left: 16px; - margin-left: 10px; + } + + ul { + } + li.bullet { margin-left: 1em; } + li.i1 { margin-left: 2em; } + li.i2 { margin-left: 3em; } + li.i3 { margin-left: 4em; } + li.i4 { margin-left: 5em; } + li.i5 { margin-left: 6em; } + li.i6 { margin-left: 7em; } + li.i7 { margin-left: 8em; } + li.i8 { margin-left: 9em; } + li.i9 { margin-left: 10em; } + + li.doc, li.ref, li.refcenter { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; @@ -592,72 +517,65 @@ WOK font-style: normal; text-align: left; } + li.doc { + background: url(../image/bullet_09.png) no-repeat 0px 6px; + padding-left: 16px; + margin-left: 10px; + margin-right: 0px; + } li.ref { background: none; padding-left: 0; margin-left: 0; - margin-top: 0px; - margin-bottom: 0px; color: #777777; - font-size: 8px; - font-style: normal; - text-align: left; } li.refcenter { background: url(../image/bullet_09.png) no-repeat 0px 6px; - background: none; padding-left: 20px; margin-left: 10%; font-size: 9px; - margin-top: 0px; - margin-bottom: 0px; color: #777777; text-align: center; } li.refbold { - background: url(../image/bullet_09.png) no-repeat 0px 6px; + list-style-type: none; padding-left: 16px; margin-left: 0; - margin-top: 0px; - margin-bottom: 0px; margin-right: 10mm; - font-size: 8px; font-weight: bold; - text-align: left; } - h1 { - font-size: 120%; - margin-top: 20px; - } - h2 { - font-size: 115%; - margin-top: 20px; - } - h3 { - font-size: 110%; - margin-top: 20px; - } - h4 { - font-size: 105%; - } - h5 { - font-size: 100%; - } - h6 { - font-size: 100%; - } - h0 { - font-size: 80%; - } - h1.norm, h2.norm, h3.norm { - font-size: 110%; - margin-left: 1em; - margin-right: 15mm; + h0, h1, h2, h3, h4, h5, h6 { + font-weight: bold; + line-height: 120%; text-align: left; margin-top: 20px; margin-bottom: 10px; } + h4.norm, h5.norm, h6.norm { + margin-top: 10px; + margin-bottom: 0px; + } + h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { + text-align: center; + } + h1 { font-size: 120%; } + h2 { font-size: 115%; } + h3 { font-size: 110%; } + h4 { font-size: 105%; } + h5 { font-size: 100%; } + h6 { font-size: 100%; } + h0 { font-size: 80%; } + + h1.i {margin-left: 2em;} + h2.i {margin-left: 3em;} + h3.i {margin-left: 4em;} + h4.i {margin-left: 5em;} + h5.i {margin-left: 6em;} + h6.i {margin-left: 7em;} + h7.i {margin-left: 8em;} + h8.i {margin-left: 9em;} + h9.i {margin-left: 10em;} h1.top_band { display: inline; text-align: left; @@ -708,202 +626,137 @@ WOK margin-right: 1mm; } - h4.norm, h5.norm, h6.norm { - font-size: 100%; - margin-left: 10mm; - margin-right: 15mm; - text-align: left; - margin-top: 10px; - margin-bottom: 0px; - } - - h1.i {margin-left: 10mm;} - h2.i {margin-left: 15mm;} - h3.i {margin-left: 20mm;} - h4.i {margin-left: 25mm;} - h5.i {margin-left: 30mm;} - h6.i {margin-left: 35mm;} - h7.i {margin-left: 40mm;} - h8.i {margin-left: 45mm;} - h9.i {margin-left: 50mm;} - - h1.banner { + .banner, .subbanner { font-weight: bold; text-align: center; - font-size: 120%; margin-left: 10mm; margin-right: 15mm; margin-top: 20px; margin-bottom: 10px; } + h1.banner { + font-size: 120%; + } h1.subbanner { - font-weight: bold; - text-align: center; font-size: 115%; - margin-left: 10mm; - margin-right: 15mm; - margin-top: 20px; - margin-bottom: 10px; } h2.banner { - font-weight: bold; - text-align: center; font-size: 110%; - margin-left: 10mm; - margin-right: 15mm; - margin-top: 20px; - margin-bottom: 10px; } h3.banner { - font-weight: bold; - text-align: center; color: #990000; font-size: 105%; - margin-left: 10mm; - margin-right: 15mm; - margin-top: 20px; - margin-bottom: 10px; } h4.banner { - font-weight: bold; - text-align: center; color: #ff0000; font-size: 100%; - margin-left: 10mm; - margin-right: 15mm; - margin-top: 20px; - margin-bottom: 10px; } h5.banner { - font-weight: bold; } h6.banner { - font-weight: bold; } - h1.toc { - margin-left: 10mm; - font-size: 115%; + .toc { + font-weight: normal; margin-top: 6px; margin-bottom: 6px; + } + h1.toc { + margin-left: 1em; + font-size: 115%; line-height: 150%; } h2.toc { - margin-left: 15mm; + margin-left: 2em; font-size: 110%; - margin-top: 6px; - margin-bottom: 6px; line-height: 140%; } h3.toc { - margin-left: 20mm; + margin-left: 3em; font-size: 105%; - margin-top: 6px; - margin-bottom: 6px; line-height: 120%; } h4.toc { - margin-left: 25mm; - font-weight: normal; + margin-left: 4em; font-size: 100%; - margin-top: 6px; - margin-bottom: 6px; line-height: 120%; } h5.toc { - margin-left: 30mm; - font-weight: normal; + margin-left: 5em; font-size: 95%; - margin-top: 6px; - margin-bottom: 6px; line-height: 110%; } h6.toc { - margin-left: 35mm; - font-weight: normal; + margin-left: 6em; font-size: 90%; - margin-top: 6px; - margin-bottom: 6px; line-height: 110%; } + .microtoc { + margin-top: 2px; + margin-bottom: 2px; + } + h1.microtoc { margin-left: 0mm; font-size: 115%; - margin-top: 2px; - margin-bottom: 2px; } h2.microtoc { margin-left: 5mm; font-size: 110%; - margin-top: 2px; - margin-bottom: 2px; } h3.microtoc { margin-left: 10mm; font-size: 105%; - margin-top: 2px; - margin-bottom: 2px; } h4.microtoc { margin-left: 15mm; font-weight: normal; font-size: 100%; - margin-top: 2px; - margin-bottom: 2px; } h5.microtoc { margin-left: 20mm; font-weight: normal; font-size: 95%; - margin-top: 2px; - margin-bottom: 2px; } h6.microtoc { margin-left: 25mm; font-weight: normal; font-size: 90%; - margin-top: 2px; - margin-bottom: 2px; } - h5.subtoc { - margin-left: 2em; + + .subtoc { margin-right: 34%; font-weight: normal; + } + h5.subtoc { + margin-left: 2em; font-size: 80%; margin-top: 2px; margin-bottom: 2px; } h6.subtoc { margin-left: 3em; - margin-right: 34%; - font-weight: normal; font-size: 75%; margin-top: 0px; margin-bottom: 0px; } -div.substance { + div.substance { width: 100%; background-color: #ffffff; -} -div.ocn { + } + div.ocn { width: 5%; float: right; top: 0; background-color: #ffffff; -} -div.endnote { + } + div.endnote { width: 95%; background-color: #fffffff; -} -/* -body { - font-size: 90%; - font-family: verdana, arial, sans-serif; -} -*/ -div.toc { + } + div.toc { position: absolute; float: left; margin: 0; @@ -913,56 +766,65 @@ div.toc { width: 13em; background-color: #eeeeee; margin-right:1em; -} -div.content { + } + div.content { margin: 0; padding: 0; border-left: 13em solid #ffffff; padding-left: 1em; -} -div.content:after { + } + div.content:after { content:' '; clear:both; display:block; height:0; overflow:hidden -} -div.footer { + } + div.footer { clear:left; padding: 0.5em; font-size: 80%; margin: 0; -} -div.toc ul { + } + div.toc ul { list-style: none; padding: 0; margin: 0; -} -div.toc li ul a, li ul span.currentlink -{ + } + div.toc li ul a, li ul span.currentlink + { font-weight: normal; font-size: 90%; padding-left: 2em; background-color: #eeeeee; -} -div.toc a, span.currentlink{ + } + div.toc a, span.currentlink{ display:block; text-decoration: none; padding-left: 0.5em; color: #0000aa; -} -span.currentlink { + } + + span.currentlink { text-decoration: none; background-color: #aaaaf9; -} -div.toc a:visited { + } + + div.toc a:visited { color: #0000aa; -} -div.toc a:hover { + } + div.toc a:hover { + color: #000000; background-color: #f9f9aa; -} + } + + .minitoc { + font-weight: normal; + margin-top: 2px; + margin-bottom: 2px; + } h1.minitoc, h2.minitoc, h3.minitoc { - margin-left: 0mm; + margin-left: 0em; font-weight: bold; text-align: left; font-size: 90%; @@ -970,26 +832,18 @@ div.toc a:hover { margin-bottom: 4px; } h4.minitoc { - margin-left: 0mm; - font-weight: normal; + margin-left: 0em; font-size: 90%; - margin-top: 2px; - margin-bottom: 2px; } h5.minitoc { - margin-left: 2mm; - font-weight: normal; + margin-left: 1em; font-size: 85%; - margin-top: 2px; - margin-bottom: 2px; } h6.minitoc { - margin-left: 4mm; - font-weight: normal; + margin-left: 2em; font-size: 85%; - margin-top: 2px; - margin-bottom: 2px; } + h1.c, h2.c, h3.c, h4.c, h5.c, h6.c, p.c { text-align: center } @@ -1147,8 +1001,7 @@ WOK margin-top: 2px; margin-bottom: 0px; } - p.norm { - } + p.norm { } p.h1 { font-family: #{fonts}; font-size: 120%; @@ -2095,8 +1948,7 @@ WOK margin-bottom: 0px; margin-right: 5mm } - p.norm { - } + p.norm { } p.endnote { font-size: 100%; margin-left: 20%; diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 5e261649..8b6fc28a 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -78,19 +78,15 @@ module SiSU_HTML_Format or @skin_no_ocn ocn_class='ocn_off' @paranum.gsub(/^(\d+|)$/, - %{

-   -

}) + %{}) else ocn_class='ocn' @paranum.gsub(/^(\d+|)$/, - %{

- \\1 -

}) + %{
\\1}) end end def name - %{} + %{} end def id #w3c? "tidy" complains about numbers as identifiers ! annoying %{id="o#@paranum"} @@ -414,7 +410,8 @@ WOK end def links_guide_vertical_open #??? url=(defined? @vz.url_hp) && @vz.url_hp =~/^http:\/\/\S+$/ ? @vz.url_hp : @vz.url_home - %{} end def seg_navigation_tail #this is a bug area, look up and "tidy" #nav=scroll_head_navigation_band @@ -879,7 +879,9 @@ WOK -} + + +} end def navigation_band(segtocband,seg_table_top_control) #change name to navigaion_band_banner %{ @@ -896,18 +898,21 @@ WOK #{seg_table_top_control}} end def navigation_band_bottom(segtocband,seg_table_top_control) #change name to navigaion_band_bannerless - %{
+ %{ +

-

- - -
- #{doc_types} - - #{segtocband} -
-#{seg_table_top_control} -

} + + + +
+ #{doc_types} + + #{segtocband} +
+ #{seg_table_top_control} +

+ +} end def endnote_mark %{

@@ -951,9 +956,10 @@ WOK def para_form_css(tag,attrib) # regular paragraphs shaped here ul=ulc='' ul,ulc="

    \n ","\n
" if @tag =~/li/ - %{
+ %{ +
#{@p_num.ocn_display} -#{ul}<#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} + #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> #@parablock #{ulc}
@@ -986,10 +992,11 @@ WOK
' end def no_paranum - %{
-

 

-

- #@one #@two + %{ +

+ +

+ #@one #@two

} diff --git a/lib/sisu/v0/html_format_css.rb b/lib/sisu/v0/html_format_css.rb index 106157ba..1573d107 100644 --- a/lib/sisu/v0/html_format_css.rb +++ b/lib/sisu/v0/html_format_css.rb @@ -162,22 +162,25 @@ module SiSU_HTML_Format_type @vz=SiSU_Env::Get_init.instance.skin end def endnote_body - %{
-

 

-

+ %{ +

+ +

#@one

} end def header_normal - %{
+ %{ +
#{@p_num.ocn_display} <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #@headname #@parablock -
} +
+} end def heading_body @tag,@class='p','norm' @@ -261,29 +264,36 @@ module SiSU_HTML_Format_type def navigation_toc_lev6 end def endnote_body_seg_tail #FIX - %{
+ %{ +

#@one

-
} +
+} end def endnote_body_seg_tail_indent - %{
+ %{ +

#@one

-
} +
+} end def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info - %{
+ %{ +

#@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three

-
} +
+} end def title_header - %{
+ %{ +
#@two <#@tag class="#@class"> #@one @@ -304,12 +314,14 @@ module SiSU_HTML_Format_type title_header end def title_header4 - %{
-

 

+ %{ +
+ -
} +
+} end def subtoc_lev one=if @one \ @@ -340,22 +352,26 @@ module SiSU_HTML_Format_type end #% para sisu def header4 - %{
+ %{ +
#{@p_num.ocn_display}

#{@p_num.name} #@format #@parablock

-
} +
+} end def header_sub @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') - %{
+ %{ +
#{@p_num.ocn_display} <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #{@headname} #{@parablock} -
} +
+} end def header5 @tag,@class='p','bold' diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index e632c835..5b7ede63 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -193,7 +193,7 @@ module SiSU_HTML_seg end end end - @@seg[:main] << '
' + @@seg[:main] << "\n
\n" data end def header_art(para) @@ -353,7 +353,7 @@ module SiSU_HTML_seg end if @sto and @sto.format=~/4:\S+/ para.gsub!(/^\s*4:\S+\s*|<:[-_\w\d]?(-.+?-)?>|4~!.+/m,'') #sort seg headers - @@seg[:main] << '
' + @@seg[:main] << %{\n
\n} @@seg[:main] << para @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc else @@ -368,6 +368,7 @@ module SiSU_HTML_seg @@seg[:tail] << format_head_seg.endnote_mark @@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| end + #@@seg[:tail] << '
 
' ads=SiSU_HTML_promo::Ad.new(@md) @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close end @@ -378,7 +379,7 @@ module SiSU_HTML_seg if type !~/endnote/ filename_seg << @@minitoc << @@seg[:main] else - filename_seg << @@seg[:header_endnotes] << @@minitoc << '
' << @@seg[:endnote_all] + filename_seg << @@seg[:header_endnotes] << @@minitoc << %{\n
\n} << @@seg[:endnote_all] end filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] filename_seg.flatten!.compact! diff --git a/lib/sisu/v0/html_table.rb b/lib/sisu/v0/html_table.rb index ffba4b0b..24721835 100644 --- a/lib/sisu/v0/html_table.rb +++ b/lib/sisu/v0/html_table.rb @@ -67,17 +67,18 @@ module SiSU_HTML_table @one,@parablock,@vz=one,one,SiSU_Env::Get_init.instance.skin end def table_head(inf) - %{
-

- #{inf} -

+ %{ +
+

} end def table_end(tablefoot='') %{

#{tablefoot} -
} +
+
+} end def table_row(inf,h=false) bold=if h; '' diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index a4e40685..21315d0f 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -184,7 +184,7 @@ GSUB %{

} end def ocn - %{#{@tab*1}

#@ocn

} << "\n" + %{#{@tab*1}#@ocn} << "\n" end def html_table # get rid of use html_table @new_content=[] -- cgit v1.2.3 From f42c740cbdff498cbc4e586a72086fc4cd4e794e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Aug 2008 01:31:25 -0400 Subject: html, css and related markup, touch --- lib/sisu/v0/shared_html_lite.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 21315d0f..7be46abb 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -184,7 +184,7 @@ GSUB %{

} end def ocn - %{#{@tab*1}#@ocn} << "\n" + %{#{@tab*1}} << "\n" end def html_table # get rid of use html_table @new_content=[] -- cgit v1.2.3 From 6759751b4a94ee4866c6f150b0245a3da7e98370 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Aug 2008 19:55:27 -0400 Subject: html format, consolidate html_format file, prune later; version number bumped version number bump: is necessary to re-initialize using new css for html presentation sisu -CC --- lib/sisu/v0/concordance.rb | 6 +- lib/sisu/v0/html.rb | 74 +++--- lib/sisu/v0/html_format.rb | 555 +++++++++++++++++++++++++++++++++++----- lib/sisu/v0/html_format_css.rb | 469 --------------------------------- lib/sisu/v0/html_scroll.rb | 16 +- lib/sisu/v0/html_segments.rb | 44 ++-- lib/sisu/v0/shared_structure.rb | 6 +- 7 files changed, 565 insertions(+), 605 deletions(-) delete mode 100644 lib/sisu/v0/html_format_css.rb (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index f62b20ac..3e073900 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -66,7 +66,7 @@ module SiSU_Concordance include SiSU_Env require "#{SiSU_lib}/defaults" include SiSU_Viz - require "#{SiSU_lib}/html_format_css" + require "#{SiSU_lib}/html_format" include SiSU_HTML_Format class Source def initialize(opt) @@ -120,7 +120,7 @@ module SiSU_Concordance WOK end def create - head_banner=SiSU_HTML_Format_type::Head_toc.new(@md) + head_banner=SiSU_HTML_Format::Head_toc.new(@md) < @@ -171,7 +171,7 @@ WOK class Words require "#{SiSU_lib}/defaults" include SiSU_Viz - require "#{SiSU_lib}/html_format_css" + require "#{SiSU_lib}/html_format" include SiSU_HTML_Format require "#{SiSU_lib}/sysenv" include SiSU_Screen diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 5f0d0de9..e882627c 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -65,8 +65,8 @@ module SiSU_HTML require "#{SiSU_lib}/defaults" include SiSU_Viz require "#{SiSU_lib}/html_table" - require "#{SiSU_lib}/html_format_css" - include SiSU_HTML_Format_type + require "#{SiSU_lib}/html_format" + include SiSU_HTML_Format require "#{SiSU_lib}/html_segments" require "#{SiSU_lib}/html_scroll" include SiSU_HTML_seg @@ -190,7 +190,7 @@ module SiSU_HTML end def toc @links_guide_toc=[] - format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) guide_type='horzontal' #values: horizontal or vertical @links_guide_toc << format_head_toc.links_guide_open(guide_type) if defined? @md.lnk \ @@ -201,24 +201,24 @@ module SiSU_HTML else '_top' end s_lnk_url,s_lnk_lnk=l[:url],l[:say] - lev_para_ocn=SiSU_HTML_Format_type::Format_toc.new(@md,s_lnk_url,s_lnk_lnk,target) + lev_para_ocn=SiSU_HTML_Format::Format_toc.new(@md,s_lnk_url,s_lnk_lnk,target) @links_guide_toc << lev_para_ocn.links_guide if s_lnk_lnk end end end - format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) @links_guide_toc << format_head_toc.links_guide_close #(guide_type) @links_guide_toc end end class Endnotes - include SiSU_HTML_Format_type + include SiSU_HTML_Format def initialize(data,md) @data,@md=data,md end def scroll @scr_endnotes=[] - format_head_scroll=SiSU_HTML_Format_type::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) @scr_endnotes << format_head_scroll.title_endnote @data.each do |para| pg=para.dup @@ -236,7 +236,7 @@ module SiSU_HTML endnote_array << pg.scan(/#{Mx[:en_b_o]}[\d+]+(.+?)#{Mx[:en_b_c]}/m) end endnote_array.flatten.each do |note| - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,note) + format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,note) @scr_endnotes << format_scroll.endnote_body end end @@ -314,24 +314,24 @@ WOK end def level_doc_owner_details if @md.stmp =~/\w\w/ - format_head_scroll=SiSU_HTML_Format_type::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) @@toc[:scr] << format_head_scroll.toc_owner_details end end def level_endnotes if @md.flag_endnotes - format_head_scroll=SiSU_HTML_Format_type::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) @@toc[:scr] << format_head_scroll.toc_endnote end end def level_metadata - format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) @@toc[:scr] << format_head_toc.metadata @@toc[:seg] << format_head_toc.seg_metadata @@toc[:seg_mini] << format_head_toc.mini_seg_metadata end def level_word_index - format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@d0c) + format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c) @@toc[:scr] << format_head_toc.concordance @@toc[:seg] << format_head_toc.concordance @@toc[:seg_mini] << format_head_toc.mini_concordance @@ -345,7 +345,7 @@ WOK linkname,link=$1.strip,$2 if $& if link \ and link !~/#/ #% keep eye on link - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) end title=unless para =~/Document Information/; linkname else @@ -353,7 +353,7 @@ WOK %{#{linkname}} end toc={} - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:seg]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ format_toc.lev0 else format_toc.lev1 @@ -376,7 +376,7 @@ WOK end %{#{linkname}} end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:scr]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ format_toc.lev0 else format_toc.lev1 @@ -392,9 +392,9 @@ WOK linkname,link=$1.strip,$2 if $& if link \ and link !~/#/ - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,linkname) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,linkname) toc={} toc[:seg]=format_toc.lev2 toc[:seg_mini]=format_toc.mini_lev2 @@ -404,7 +404,7 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:scr]=format_toc.lev2 toc end @@ -416,9 +416,9 @@ WOK linkname,link=$1.strip,$2 if $& if link \ and link !~/#/ - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,linkname) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,linkname) toc={} toc[:seg]=format_toc.lev3 toc[:seg_mini]=format_toc.mini_lev3 @@ -428,7 +428,7 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:scr]=format_toc.lev3 toc end @@ -439,7 +439,7 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') para[@pat_heading] linkname,link=$1.strip,$2 if $& - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) if link end para.gsub!(/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') if para =~/^#{Mx[:lv_o]}4:/ @@ -457,8 +457,8 @@ WOK %{\\1 \\2 \\3 }) end - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,seg_link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) if link + format_toc=SiSU_HTML_Format::Format_toc.new(@md,seg_link) toc={} toc[:seg]=format_toc.lev4 toc[:seg_mini]=format_toc.mini_lev4 @@ -468,7 +468,7 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} if p_num end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:scr]=format_toc.lev4 toc end @@ -482,7 +482,7 @@ WOK linkname,link=$1.strip,$2 if $& if link \ and link !~/#/ - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) end toc={} if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -493,12 +493,12 @@ WOK lnk_n_txt=%{ #{linkname} } - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,lnk_n_txt) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,lnk_n_txt) toc[:seg]=format_toc.lev5 toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:scr]=format_toc.lev5 toc end @@ -511,7 +511,7 @@ WOK linkname,link=$1.strip,$2 if $& if link \ and link !~/#/ - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) end toc={} if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -522,12 +522,12 @@ WOK lnk_n_txt=%{ #{linkname} } - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,lnk_n_txt) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,lnk_n_txt) toc[:seg]=format_toc.lev6 toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) + format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) toc[:scr]=format_toc.lev6 toc end @@ -564,14 +564,14 @@ WOK toc_shared=[] @segtoc=[] SiSU_Screen::Ansi.new(@md.cmd,'Scroll & Segtoc').txt_grey unless @md.cmd =~/q/ - format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) dochead=format_head_toc.head dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge ads=SiSU_HTML_promo::Ad.new(@md) toc_shared << dochead << ads.div.major @segtoc << format_head_toc.head << ads.div.major - toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format_type::Head_toc.method_defined? :toc_head_escript - @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format_type::Head_toc.method_defined? :toc_head_escript + toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript + @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript toc_shared << format_head_toc.scroll_head_navigation_band if @md.dc_rights rights=format_head_toc.rights @@ -588,20 +588,20 @@ WOK tmp_head=nil doc_title_endnote=@md.title.gsub(/(\*+)/,'\1') tmp_head=doc_title_endnote + "\n" - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if not @md.subtitle.nil? \ and not @md.subtitle.empty? tmp_head=@md.subtitle + "\n" - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end if @md.dc_creator creator_endnote=@md.dc_creator.gsub(/(\*+)/,%{ \\1}) tmp_head=creator_endnote + "\n" - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 8b6fc28a..87988ec1 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -55,7 +55,7 @@ - ** Description: base formatting template for html generation + ** Description: html formating, css template =end module SiSU_HTML_Format @@ -98,7 +98,8 @@ module SiSU_HTML_Format class Paragraph_id_ocn #used by table version #work area 2003w48 attr_accessor :paranum,:font,:p_num def initialize(md,paranum) - @paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,SiSU_HTML_Format::Paragraph_number.new(md,paranum) #font + @paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,Paragraph_number.new(md,paranum) #font + #@paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,SiSU_HTML_Format::Paragraph_number.new(md,paranum) #font end def txt %{

#{@p_num.name} @@ -140,7 +141,6 @@ module SiSU_HTML_Format end class Head_information include SiSU_Viz - include SiSU_HTML_Format attr_reader :md,:sfx,:pdf,:rdf,:vz def initialize(md='') @md=md @@ -184,6 +184,10 @@ module SiSU_HTML_Format #{@vz.txt_home} } end + def html_close #moved + %{ +} + end end class Widget < Head_information def initialize(md) @@ -268,6 +272,8 @@ module SiSU_HTML_Format end end end + class XML + end class Head_toc < Head_information def initialize(md) super(md) @@ -397,16 +403,30 @@ WOK #{@md.html_title} - - #{@rdf.rdftoc} - #{@rdf.metatag_html} - #{@vz.font_css_table_file} + +#{@rdf.rdftoc} +#{@rdf.metatag_html} +#{@css.html} #{@vz.color_body} - - - - #{@vz.js_top}} + + + +#{@vz.js_top}} + end + def concordance + if @md.concord_make + %{#{@vz.margin_css} +

+ + Concordance + +

+#{@vz.table_close}} + else + %{#{@vz.margin_css} +#{@vz.table_close}} + end end def links_guide_vertical_open #??? url=(defined? @vz.url_hp) && @vz.url_hp =~/^http:\/\/\S+$/ ? @vz.url_hp : @vz.url_home @@ -539,15 +559,12 @@ WOK #{@vz.table_close}} end def metadata - %{#{@vz.margin_txt_3} -#{@vz.paragraph_font_small} - - MetaData - -     - - - + %{#{@vz.margin_css} +

+ + MetaData + +

#{@vz.table_close}} end def seg_metadata @@ -602,48 +619,8 @@ WOK } end end - def html_close - %{ -} - end - class Head_scroll < Head_toc - def initialize(md) - super(md) - end - def toc_owner_details - %{#{@vz.margin_txt_3} -#{@vz.paragraph_font_small} - - Owner Details - -     - - -
-#{@vz.table_close}} - end - def table - %{
- -
- -#{@vz.paragraph_txt}} - end - def table1 - %{ -
-#{@vz.paragraph_txt}} - end - def table2 - %{ -
-#{@vz.paragraph_txt}} - end - def title_endnote - end - end class Head_seg < Head_information - def initialize(md) + def initialize(md) #(md='') super(md) end def head @@ -817,6 +794,21 @@ WOK #{@vz.table_close}} end def title_endnote(title,subtitle,creator,table_top_control) +# %{#{@vz.banner_instrument_cover_band_seg} +#

+# #{title} +#

+#

+# #{subtitle} +#

+#

+# #{creator} +#

+# +##{@vz.table_close} +#

Endnotes

} end def navigation_table %{ @@ -918,6 +910,135 @@ WOK %{

} #revisit end + def head + %{#{doc_type} + + + #{@seg_name_html[@seg_name_html_tracker]} - + #{@md.html_title} + + +#{@rdf.rdfseg} +#{@rdf.metatag_html} +#{@css.html} + +#{@vz.color_body} + + + +#{@vz.js_top}} + end + def toc_metadata + @metalink=%{./#{@md.fn[:meatadata]}} + toc_metadata + end + def title_banner(title,subtitle,creator) + %{

+ #{title} +

+

+ #{subtitle} +

+

+ #{creator} +

+

+ copy @ + + #{@vz.txt_home} + +

} + end + end + class Head_scroll < Head_toc + def initialize(md) #(md='') + super(md) + end + def toc_owner_details + %{#{@vz.margin_txt_3} +#{@vz.paragraph_font_small} + + Owner Details + +     + + + +#{@vz.table_close}} + end + def table + %{
+ +
+ +#{@vz.paragraph_txt}} + end + def table1 + %{ +
+#{@vz.paragraph_txt}} + end + def table2 + %{ +
+#{@vz.paragraph_txt}} + end +## def toc_endnote +## %{#{@vz.margin_txt_3} +## #{@vz.paragraph_font_small} +## +## Endnotes +## +## #{@vz.table_close}} +## end +# def toc_endnote +# %{#{@vz.margin_css} +#

+# +# Endnotes +# +#

+##{@vz.table_close}} +# end + def title_endnote +# %{#{@vz.margin_txt_0} +# #{@vz.paragraph_txt} +# +##{@vz.margin_num} +#   +##{@vz.table_close}} + end +# def tail +# %{
+##{@vz.margin_txt_0} +# +# +# +#
+##{@vz.banner_band} +# +#
#@tocband_scroll
+#
+#
+##{@vz.paragraph_txt} +#
+# #{@vz.credits_splash} +# #{@vz.credits_sisu} +#
+##{@vz.margin_num} +##{@vz.table_close} +# +# +# +# +# +# +# +# #{@md.title*10} +# +# +#} +# end end class Format_text_object @vz=SiSU_Env::Get_init.instance.skin @@ -941,7 +1062,8 @@ WOK #end if txt[2]=~/\d+/ @paranum=txt[2][/(\d+)/m,1] # unless paranum =~/#/ - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,@paranum) + @p_num=Paragraph_number.new(@md,@paranum) + #@p_num=SiSU_HTML_Format::Paragraph_number.new(@md,@paranum) @para_id=Paragraph_id_ocn.new(@md,@paranum) #used by table version end @headname='' @@ -1048,7 +1170,314 @@ WOK %{

#@one

\n} end end - class XML + class Format_scroll < Format_text_object + def initialize(md='',*txt) + super(md,*txt) + @vz=SiSU_Env::Get_init.instance.skin + end + def endnote_body + %{ +
+ +

+ #@one +

+
+} + end + def header_normal + %{ +
+ #{@p_num.ocn_display} + <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} + #@headname + #@parablock + +
+} + end + def heading_body + @tag,@class='p','norm' + header_normal + end + def heading_body1 + @tag,@class='h1','norm' + header_normal + end + def heading_body2 + @tag,@class='h2','norm' + header_normal + end + def heading_body3 + @tag,@class='h3','norm' + header_normal + end + def heading_body4 + @tag,@class='h4','norm' + header_normal + end + def heading_body5 + @tag,@class='h5','norm' + header_normal + end + def heading_body6 + @tag,@class='h6','norm' + header_normal + end + end + class Format_seg < Format_text_object + def initialize(md='',*txt) + super(md,*txt) + end + def navigation_toc_lev1_advert + %{#{@banner.home_button}\n +
+#@one +#@two +

} + end + def navigation_toc_lev1 + %{#{@banner.nav_toc}} + end + def navigation_toc_lev2 #change bold use css + %{

+ + +
+ + + #@one + +

+#{@vz.table_close}} + end + def navigation_toc_lev3 #change bold use css + %{

+ + +
+ + + #@one + +

+#{@vz.table_close}} + end + def navigation_toc_lev4 + %{ + +
+ +

+ #@one +

+#{@vz.table_close}} + end + def navigation_toc_lev5 + end + def navigation_toc_lev6 + end + def endnote_body_seg_tail #FIX + %{ +
+

+ #@one +

+
+} + end + def endnote_body_seg_tail_indent + %{ +
+

+ #@one +

+
+} + end + def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 + fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info + %{ +
+

+ #@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three +

+
+} + end + def title_header + %{ +
+ #@two +<#@tag class="#@class"> + #@one + +
+} + end + def title_header1 + @tag,@class='h1','banner' + title_header + end + def title_header2 + @tag,@class='h2','banner' + title_header + end + def title_header3 + @tag,@class='h3','banner' + title_header + end + def title_header4 + %{ +
+ + +
+} + end + def subtoc_lev + one=if @one \ + and @one =~/<\/?i>|/mi + @one.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text + else @one + end + note='' + if one =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream + note=$1 + note.gsub!(/[\n\s]+/m,' ') + one.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') + one.gsub!(/ \d+<\/sup> /m,'') + end + %{<#@tag class="#@class"> + + #{one} + #{note} + } + end + def subtoc_lev5 + @tag,@class='h5','subtoc' + subtoc_lev if @one + end + def subtoc_lev6 + @tag,@class='h6','subtoc' + subtoc_lev if @one + end + #% para sisu + def header4 + %{ +
+#{@p_num.ocn_display} +

#{@p_num.name} + #@format + #@parablock +

+
+} + end + def header_sub + @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') + %{ +
+ #{@p_num.ocn_display} + <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #{@headname} + #{@parablock} + +
+} + end + def header5 + @tag,@class='p','bold' + header_sub + end + def header6 + @tag,@class='p','bold' + header_sub + end + def navigation_header4 + %{ +
+

+ #@parablock +

+#{@vz.table_close}} + end + def navigation_header5 + %{

+ #@parablock +

} + end + def navigation_header6 + %{

+ #@parablock +

} + end + def navigation_center + "
#@parablock
" + end + end + class Format_toc < Format_text_object + def initialize(md='',*txt) + super(md,*txt) + end + def links_guide + #@three distinguishes between _top and external, can be used e.g. for different colour scheme + %{
  • + + #@linkname + +
  • +} + end + def lev(tag,attrib) + %{<#{tag} class="#{attrib}"> + #@one + +} + end + def lev1 + lev('h1','toc') + end + def lev2 + lev('h2','toc') + end + def lev3 + lev('h3','toc') + end + def lev4 + lev('h4','toc') + end + def lev5 + lev('h5','toc') + end + def lev6 + lev('h6','toc') + end + def lev0 #docinfo + lev('h0','toc') + end + def mini_lev1 + lev('h1','minitoc') + end + def mini_lev2 + lev('h2','minitoc') + end + def mini_lev3 + lev('h3','minitoc') + end + def mini_lev4 + lev('h4','minitoc') + end + def mini_lev5 + lev('h5','minitoc') + end + def mini_lev6 + lev('h6','minitoc') + end + def mini_lev0 #docinfo + lev('h0','minitoc') + end end end __END__ diff --git a/lib/sisu/v0/html_format_css.rb b/lib/sisu/v0/html_format_css.rb deleted file mode 100644 index 1573d107..00000000 --- a/lib/sisu/v0/html_format_css.rb +++ /dev/null @@ -1,469 +0,0 @@ -# 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 Ralph Amissah All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Ralph Amissah - - - - ** Description: html formating, css template - -=end -module SiSU_HTML_Format_type - require "#{SiSU_lib}/html_format" - include SiSU_Viz - include SiSU_HTML_Format - class Head_toc < SiSU_HTML_Format::Head_toc - def initialize(md='') - super(md) - end - def head - %{#{doc_type} - - - #{@md.html_title} - - -#{@rdf.rdftoc} -#{@rdf.metatag_html} -#{@css.html} - -#{@vz.color_body} - - - -#{@vz.js_top}} - end - def concordance - if @md.concord_make - %{#{@vz.margin_css} -

    - - Concordance - -

    -#{@vz.table_close}} - else - %{#{@vz.margin_css} -#{@vz.table_close}} - end - end - def metadata - %{#{@vz.margin_css} -

    - - MetaData - -

    -#{@vz.table_close}} - end - end - class Head_seg < SiSU_HTML_Format::Head_seg - def initialize(md='') - super(md) - end - def head - %{#{doc_type} - - - #{@seg_name_html[@seg_name_html_tracker]} - - #{@md.html_title} - - -#{@rdf.rdfseg} -#{@rdf.metatag_html} -#{@css.html} - -#{@vz.color_body} - - - -#{@vz.js_top}} - end - def toc_metadata - @metalink=%{./#{@md.fn[:meatadata]}} - toc_metadata - end - def title_banner(title,subtitle,creator) - %{

    - #{title} -

    -

    - #{subtitle} -

    -

    - #{creator} -

    -

    - copy @ - - #{@vz.txt_home} - -

    } - end - end - class Head_scroll < SiSU_HTML_Format::Head_scroll - def initialize(md='') - super(md) - end - end - class Format_scroll < SiSU_HTML_Format::Format_text_object - def initialize(md='',*txt) - super(md,*txt) - @vz=SiSU_Env::Get_init.instance.skin - end - def endnote_body - %{ -
    - -

    - #@one -

    -
    -} - end - def header_normal - %{ -
    - #{@p_num.ocn_display} - <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} - #@headname - #@parablock - -
    -} - end - def heading_body - @tag,@class='p','norm' - header_normal - end - def heading_body1 - @tag,@class='h1','norm' - header_normal - end - def heading_body2 - @tag,@class='h2','norm' - header_normal - end - def heading_body3 - @tag,@class='h3','norm' - header_normal - end - def heading_body4 - @tag,@class='h4','norm' - header_normal - end - def heading_body5 - @tag,@class='h5','norm' - header_normal - end - def heading_body6 - @tag,@class='h6','norm' - header_normal - end - end - class Format_seg < SiSU_HTML_Format::Format_text_object - def initialize(md='',*txt) - super(md,*txt) - end - def navigation_toc_lev1_advert - %{#{@banner.home_button}\n -
    -#@one -#@two -

    } - end - def navigation_toc_lev1 - %{#{@banner.nav_toc}} - end - def navigation_toc_lev2 #change bold use css - %{

    - - -
    - - - #@one - -

    -#{@vz.table_close}} - end - def navigation_toc_lev3 #change bold use css - %{

    - - -
    - - - #@one - -

    -#{@vz.table_close}} - end - def navigation_toc_lev4 - %{ - -
    - -

    - #@one -

    -#{@vz.table_close}} - end - def navigation_toc_lev5 - end - def navigation_toc_lev6 - end - def endnote_body_seg_tail #FIX - %{ -
    -

    - #@one -

    -
    -} - end - def endnote_body_seg_tail_indent - %{ -
    -

    - #@one -

    -
    -} - end - def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 - fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info - %{ -
    -

    - #@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three -

    -
    -} - end - def title_header - %{ -
    - #@two -<#@tag class="#@class"> - #@one - -
    -} - end - def title_header1 - @tag,@class='h1','banner' - title_header - end - def title_header2 - @tag,@class='h2','banner' - title_header - end - def title_header3 - @tag,@class='h3','banner' - title_header - end - def title_header4 - %{ -
    - - -
    -} - end - def subtoc_lev - one=if @one \ - and @one =~/<\/?i>|/mi - @one.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text - else @one - end - note='' - if one =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream - note=$1 - note.gsub!(/[\n\s]+/m,' ') - one.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') - one.gsub!(/ \d+<\/sup> /m,'') - end - %{<#@tag class="#@class"> - - #{one} - #{note} - } - end - def subtoc_lev5 - @tag,@class='h5','subtoc' - subtoc_lev if @one - end - def subtoc_lev6 - @tag,@class='h6','subtoc' - subtoc_lev if @one - end - #% para sisu - def header4 - %{ -
    -#{@p_num.ocn_display} -

    #{@p_num.name} - #@format - #@parablock -

    -
    -} - end - def header_sub - @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') - %{ -
    - #{@p_num.ocn_display} - <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #{@headname} - #{@parablock} - -
    -} - end - def header5 - @tag,@class='p','bold' - header_sub - end - def header6 - @tag,@class='p','bold' - header_sub - end - def navigation_header4 - %{ - +

    #{@translate.suggested_links}:

    +
    -

    - #@parablock -

    -#{@vz.table_close}} - end - def navigation_header5 - %{

    - #@parablock -

    } - end - def navigation_header6 - %{

    - #@parablock -

    } - end - def navigation_center - "
    #@parablock
    " - end - end - class Format_toc < SiSU_HTML_Format::Format_text_object - def initialize(md='',*txt) - super(md,*txt) - end - def links_guide - #@three distinguishes between _top and external, can be used e.g. for different colour scheme - %{
  • - - #@linkname - -
  • -} - end - def lev(tag,attrib) - %{<#{tag} class="#{attrib}"> - #@one - -} - end - def lev1 - lev('h1','toc') - end - def lev2 - lev('h2','toc') - end - def lev3 - lev('h3','toc') - end - def lev4 - lev('h4','toc') - end - def lev5 - lev('h5','toc') - end - def lev6 - lev('h6','toc') - end - def lev0 #docinfo - lev('h0','toc') - end - def mini_lev1 - lev('h1','minitoc') - end - def mini_lev2 - lev('h2','minitoc') - end - def mini_lev3 - lev('h3','minitoc') - end - def mini_lev4 - lev('h4','minitoc') - end - def mini_lev5 - lev('h5','minitoc') - end - def mini_lev6 - lev('h6','minitoc') - end - def mini_lev0 #docinfo - lev('h0','minitoc') - end - end -end -__END__ diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 0bbac4fa..8b1e041c 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -102,12 +102,12 @@ module SiSU_HTML_scroll end if para =~/.+?#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ paranum=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] - @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) end @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_scroll m=/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch case @sto.format when /^1:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body1 when /^2:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body2 @@ -138,20 +138,20 @@ module SiSU_HTML_scroll end elsif para =~/^#{Mx[:lv_o]}[1-9]:/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_c]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,para) + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,para) para=format_txt_obj.bold_header elsif para =~/Endnotes?/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'
    Note') + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,'
    Note') para=format_txt_obj.bold_para elsif para =~/Owner Details/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'
    Owner Details') + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,'
    Owner Details') @scr[:owner_details]=format_txt_obj.bold_para para='' elsif para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ #watch one,two=$1,$2 - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) para=format_seg.no_paranum end if para =~// \ @@ -160,7 +160,7 @@ module SiSU_HTML_scroll end if para =~/<:center>/ #rules changed now a

    (.*)/.match(para).captures - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) + format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,one,two) end para.gsub!(/^#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/^<:\S?>/,'') para.gsub!(/#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/<:\S?>/,' '); para.gsub!(//,' ') @@ -174,7 +174,7 @@ module SiSU_HTML_scroll end def tails scr_tail=[] - format_head_scroll=SiSU_HTML_Format_type::Head_toc.new(@md) + format_head_scroll=SiSU_HTML_Format::Head_toc.new(@md) ads=SiSU_HTML_promo::Ad.new(@md) scr_tail << format_head_scroll.scroll_tail << ads.div.close << ads.display << format_head_scroll.html_close scr_tail diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 5b7ede63..c3617b24 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -197,7 +197,7 @@ module SiSU_HTML_seg data end def header_art(para) - format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if para =~/^#{Mx[:lv_o]}[1-6]:/ #2004w27/5 if @@tracker < @@seg_total-1; @@seg[:dot_nav]=format_head_seg.dot_control_pre_next else @@seg[:dot_nav]=format_head_seg.dot_control_pre @@ -208,7 +208,7 @@ module SiSU_HTML_seg end def head(para) clean=/|#{Mx[:gr_o]}:.*?#{Mx[:gr_c]}|<:.*?>|#{Mx[:id_o]}~\d+;(?:[ohum]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if @@tracker < @@seg_total-1 if @@tracker == 0; @@segtocband=format_head_seg.toc_next2 #if format_head_seg.toc_next2 else @@segtocband=format_head_seg.toc_pre_next2 #if format_head_seg.toc_pre_next2 @@ -220,13 +220,13 @@ module SiSU_HTML_seg @dc_creator=%{#{@md.dc_creator}\n} if @md.dc_creator.to_s =~/\S/ @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) - @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format_type::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug + @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,@@header1,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,@@header1,@p_num.ocn_display) @@seg[:headers] << format_seg.title_header1.gsub(clean,'') @@header1.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end @@ -235,8 +235,8 @@ module SiSU_HTML_seg paranum=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,header2,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,header2,@p_num.ocn_display) @@seg[:headers] << format_seg.title_header2.gsub(clean,'') @@header2.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end @@ -245,8 +245,8 @@ module SiSU_HTML_seg paranum=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,header3,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,header3,@p_num.ocn_display) @@seg[:headers] << format_seg.title_header3.gsub(clean,'') @@header3.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end @@ -255,8 +255,8 @@ module SiSU_HTML_seg paranum=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,header4,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,header4,@p_num.ocn_display) @@seg[:headers] << format_seg.title_header4.gsub(clean,'') end @@seg[:header_endnotes]=format_head_seg.title_endnote(@md.title,@md.subtitle,@dc_creator,@@seg[:dot_nav]) @@ -264,12 +264,12 @@ module SiSU_HTML_seg end def markup(para) @debug=[] - format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if para !~/^#{Rx[:meta]}/ m=para[/.+?#{Mx[:id_o]}~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] if m paranum=m[1].to_s - @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) end if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/m \ or @@flag_alt==true @@ -293,13 +293,13 @@ module SiSU_HTML_seg if para !~/^#{Mx[:lv_o]}[1-9]:|#{Rx[:meta]}/ if para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ one,two=$1,$2 - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) para=format_seg.no_paranum end end if para[/#{Mx[:id_o]}~(\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp)#{Mx[:id_c]}$/] @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_seg - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch para=case @sto.format # work area 2003w29 ||@|def lev_segname_para_ocn| when /^4:/; @sto.seg_lev_para_ocn.header4 # work on see Split_text_object when /^5:/; @sto.seg_lev_para_ocn.header5 @@ -341,13 +341,13 @@ module SiSU_HTML_seg if para !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/ if para[/(.*)#{Mx[:id_o]}~0;(?:u|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/] #% watch u & m? one,two=$1,$2 - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) #FIX --> not that undefined, rather is not needed, should not be visited, and remove #para=format_seg.seg_no_paranum #% undefined end para.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint if para =~/ / #endnote- note- - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,para) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,para) para=format_seg.no_paranum end end @@ -363,7 +363,7 @@ module SiSU_HTML_seg end end def tail - format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) + format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if @md.flag_auto_endnotes @@seg[:tail] << format_head_seg.endnote_mark @@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| @@ -437,11 +437,11 @@ module SiSU_HTML_seg case para # series changed 2002w42 when /^#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #remove [u]? req by pg texts, revist one,two=$1,$2 - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) para=format_seg.subtoc_lev5 when /^#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ one,two=$1,$2 - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) para=format_seg.subtoc_lev6 end @@seg_subtoc_array << para @@ -466,7 +466,7 @@ module SiSU_HTML_seg e_n=note_match_seg[/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,1] try=e_n.split(/
    /) try.each do |e| - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,e) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,e) note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ format_seg.endnote_body_seg_tail_indent else format_seg.endnote_body_seg_tail @@ -478,7 +478,7 @@ module SiSU_HTML_seg m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(#-[\d*+]+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi one=note_match_seg[m,1] #note~ [a name] two=note_match_seg[m,2] #note- - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end diff --git a/lib/sisu/v0/shared_structure.rb b/lib/sisu/v0/shared_structure.rb index 506b5097..5a3993c6 100644 --- a/lib/sisu/v0/shared_structure.rb +++ b/lib/sisu/v0/shared_structure.rb @@ -62,7 +62,7 @@ module SiSU_Structure class Split_text_object include SiSU_Viz - #include SiSU_HTML_Format_type + #include SiSU_HTML_Format @@dp=nil attr_reader :format,:text,:ocn,:scroll_lev_para_ocn,:seg_lev_para_ocn,:lev_para_ocn def initialize(md,para) @@ -104,14 +104,14 @@ module SiSU_Structure def html_seg lev_segname_para_ocn @seg_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] - SiSU_HTML_Format_type::Format_seg.new(@md,@format,@text,@ocn) + SiSU_HTML_Format::Format_seg.new(@md,@format,@text,@ocn) end self end def html_scroll lev_segname_para_ocn @scroll_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] - SiSU_HTML_Format_type::Format_scroll.new(@md,@format,@text,@ocn) + SiSU_HTML_Format::Format_scroll.new(@md,@format,@text,@ocn) end self end -- cgit v1.2.3 From e2fb7c3734fd1b7ad789a5cae42a87fb16704a9a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Aug 2008 20:18:57 -0400 Subject: texpdf, fix: image dimension match (for post 0.68.0 changed middle layer representation) --- lib/sisu/v0/texpdf_format.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index a3f2f7d2..f776dd5a 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -460,7 +460,7 @@ para z,url=regx_url.match(word).captures if word =~regx_url url=url.strip if word =~/#{Mx[:lnk_o]}\s*\S+\.?(?:png|jpg|gif)/ \ - and word=~/\s+\d+x\d+\s+/ + and word=~/\s+\d+x\d+(\s+|\s*#{Mx[:lnk_c]})/ image,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') width=if z =~/(\d+)x\d*/ -- cgit v1.2.3 From afb83150d0b9876006bc100517b60be9e2fd0f56 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 16 Aug 2008 00:21:01 -0400 Subject: html css and div related --- lib/sisu/v0/css.rb | 9 ++++- lib/sisu/v0/html.rb | 7 ++-- lib/sisu/v0/html_format.rb | 78 +++++++++++++++++++++++++++++++------------- lib/sisu/v0/html_scroll.rb | 1 + lib/sisu/v0/html_segments.rb | 19 ++++++++--- lib/sisu/v0/html_tune.rb | 1 - 6 files changed, 82 insertions(+), 33 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index f4dfc15f..1eef5023 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -742,7 +742,7 @@ WOK margin-bottom: 0px; } - div.substance { + div.substance, div.main_column { width: 100%; background-color: #ffffff; } @@ -804,6 +804,9 @@ WOK padding-left: 0.5em; color: #0000aa; } + hr { + width: 90%; + } span.currentlink { text-decoration: none; @@ -843,6 +846,10 @@ WOK margin-left: 2em; font-size: 85%; } + h0.minitoc { + margin-left: 0em; + font-size: 90%; + } h1.c, h2.c, h3.c, h4.c, h5.c, h6.c, p.c { text-align: center diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index e882627c..e57b5add 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -358,8 +358,8 @@ WOK format_toc.lev0 else format_toc.lev1 end - toc[:seg_mini]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ - format_toc.lev0 + toc[:seg_mini]=if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ + format_toc.mini_lev0 else format_toc.mini_lev1 end title=if para =~/(#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/ @@ -582,6 +582,7 @@ WOK prefix_b=SiSU_Tune::Clean_html.new(prefix_b).clean end @seg_toc_band=format_head_toc.seg_head_navigation_band('pdf') #bug, vary depending on type of doc !! examine + @seg_toc_band_bottom=format_head_toc.seg_head_navigation_band_bottom('pdf') #bug, vary depending on type of doc !! examine @segtoc << @seg_toc_band toc_shared << format_head_toc.scroll_head_title_banner_open @segtoc << format_head_toc.seg_head_title_banner_open @@ -627,7 +628,7 @@ WOK @segtoc << prefix_b if @md.prefix_b #Segtoc tail added here @segtoc << "

    \n" #bugfix sort later DEBUGNOW - @segtoc << @seg_toc_band + @segtoc << @seg_toc_band_bottom ads=SiSU_HTML_promo::Ad.new(@md) @segtoc << format_head_toc.seg_navigation_tail << ads.div.close << ads.display << format_head_toc.html_close @segtoc.flatten!.compact! diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 87988ec1..1ee409ab 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -333,6 +333,25 @@ WOK
     #{firstseg}  #{@vz.table_close} +

    } + end + def seg_head_navigation_band_bottom(type='') + if type=~/pdf/ + @tocband_segtoc=make_scroll_seg_pdf + end + firstseg=%{ + #{@vz.png_nav_nxt} + } if @md.firstseg =~/\S+/ + %{ + + +
    +   + + #@tocband_segtoc + +  #{firstseg}  +#{@vz.table_close}

    } end def manifest_link(text) @@ -572,7 +591,9 @@ WOK metadata end def seg_tail - %{

     

    + %{ +

    +

     

    #{@vz.banner_band} @@ -591,11 +612,15 @@ WOK -} + + +} end def scroll_tail #debug nav=scroll_head_navigation_band - %{#{nav} + %{ +
    +#{nav} #{@vz.credits_splash} #{@vz.credits_sisu} @@ -604,11 +629,13 @@ WOK -
    } +} end def seg_navigation_tail #this is a bug area, look up and "tidy" #nav=scroll_head_navigation_band - %{

     

    + %{ +
    +

     

    #{@vz.credits_splash} #{@vz.credits_sisu} @@ -616,7 +643,9 @@ WOK -} + +
    +} end end class Head_seg < Head_information @@ -864,7 +893,9 @@ WOK } end def credit - %{#{@vz.credits_splash} + %{ +
    +#{@vz.credits_splash} #{@vz.credits_sisu} @@ -891,8 +922,7 @@ WOK end def navigation_band_bottom(segtocband,seg_table_top_control) #change name to navigaion_band_bannerless %{ -
    -

    +

    #{doc_types} @@ -902,13 +932,24 @@ WOK
    #{seg_table_top_control} -

    } end def endnote_mark -%{

    -

    } #revisit +%{ +

    +


    +

    } + end + def endnote_section_open +%{ +
    +} + end + def endnote_section_close +%{ +
    +} #revisit end def head %{#{doc_type} @@ -1177,12 +1218,9 @@ WOK end def endnote_body %{ -
    - -

    +

    #@one -

    -
    +

    } end def header_normal @@ -1279,30 +1317,24 @@ WOK end def endnote_body_seg_tail #FIX %{ -

    #@one

    -
    } end def endnote_body_seg_tail_indent %{ -

    #@one

    -
    } end def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info %{ -

    #@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three

    -
    } end def title_header diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 8b1e041c..93e30494 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -97,6 +97,7 @@ module SiSU_HTML_scroll and (para =~/^#{Mx[:lv_o]}:metadata#{Mx[:lv_c]}/ or para =~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}\s*Document Information/) @rcdc=true end + para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'


    ') if para !~/(^#{Rx[:meta]}|#{Mx[:br_endnotes]}|#{Mx[:br_eof]})/ unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/; para.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') end diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index c3617b24..c4d136b7 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -141,7 +141,9 @@ module SiSU_HTML_seg end end if @@is4 == 1 \ - or para =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ + or para =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ \ + or para =~/^#{Mx[:mk_o]}4:metadata#{Mx[:mk_c]}/ + m=para[/^#{Mx[:lv_o]}4:(metadata)#{Mx[:lv_c]}/]; @@get_hash_fn=$1 if m if newfile == 1 \ or para =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 @@ -219,7 +221,11 @@ module SiSU_HTML_seg if @@is1 == 1 @dc_creator=%{#{@md.dc_creator}\n} if @md.dc_creator.to_s =~/\S/ @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) - @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) + endnote_section_close=unless @@get_hash_fn =~/metadata/ + format_head_seg.endnote_section_close + else '' + end + @@seg[:tocband_bannerless] << endnote_section_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 @@ -364,9 +370,12 @@ module SiSU_HTML_seg end def tail format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) - if @md.flag_auto_endnotes - @@seg[:tail] << format_head_seg.endnote_mark - @@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| + if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn] + @@seg[:tail] << format_head_seg.endnote_section_open + if @@seg_endnotes[@@get_hash_fn].flatten.length > 0 + @@seg[:tail] << format_head_seg.endnote_mark + @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| + end end #@@seg[:tail] << '
     
    ' ads=SiSU_HTML_promo::Ad.new(@md) diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 9cc50b23..f06b8764 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -236,7 +236,6 @@ module SiSU_Tune para.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;') para.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
    ') - para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'


    ') # else clean '' para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') -- cgit v1.2.3 From 89d5ace0572e2ec228ef9ba6702e590309f1f086 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 16 Aug 2008 11:09:06 -0400 Subject: html segments, links to concordance file only if made, fix --- lib/sisu/v0/html.rb | 2 +- lib/sisu/v0/html_format.rb | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index e57b5add..28098f6c 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -359,7 +359,7 @@ WOK else format_toc.lev1 end toc[:seg_mini]=if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ - format_toc.mini_lev0 + format_toc.mini_tail else format_toc.mini_lev1 end title=if para =~/(#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/ diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 1ee409ab..0bfe580e 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -764,6 +764,7 @@ WOK scroll=seg='' wgt=Widget.new(@md) #dir=SiSU_Env::Info_env.new(@md.fns) + x=if @md.concord_make %{ @@ -776,6 +777,19 @@ WOK #{wgt.search} #{wgt.home}
    } + else + %{ + + + #{wgt.seg(@vz.nav_txt_toc_link)} + #{wgt.scroll(@vz.nav_txt_doc_link)} + #{wgt.pdf}#{wgt.odf} +
    + #{wgt.manifest} + #{wgt.search} + #{wgt.home} +
    } + end end def toc_pre_next3 #used with seg_doc_types in seg_nav_band #with pdf & other doc types #knxjs %{ @@ -1510,6 +1524,27 @@ WOK def mini_lev0 #docinfo lev('h0','minitoc') end + def mini_tail +# +# Document Information (metadata) +# + x=if @md.concord_make + %{ +

    + Concordance (wordlist) +

    +

    + Manifest (alternative outputs) +

    +} + else + %{ +

    + Manifest (alternative outputs) +

    +} + end + end end end __END__ -- cgit v1.2.3 From 0ec2677657a7199d5210d9e013fe62334c83f71a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 17 Aug 2008 01:18:19 -0400 Subject: html segments structure and info provided (a bit verbose), and css --- lib/sisu/v0/css.rb | 260 ++---------------------------------- lib/sisu/v0/html.rb | 5 +- lib/sisu/v0/html_format.rb | 304 ++++++++++++++++++------------------------- lib/sisu/v0/html_segments.rb | 15 ++- 4 files changed, 149 insertions(+), 435 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index 1eef5023..449f51d8 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -285,7 +285,7 @@ WOK text-align: left; } - p.tiny, p.tiny_left, p.tiny_right, p.tiny_center { + .tiny, .tiny_left, .tiny_right, .tiny_center { font-size: 10px; margin-top: 0px; margin-bottom: 0px; @@ -634,6 +634,7 @@ WOK margin-top: 20px; margin-bottom: 10px; } + h1.banner { font-size: 120%; } @@ -767,6 +768,13 @@ WOK background-color: #eeeeee; margin-right:1em; } + div.summary { + margin: 0; + padding: 0; + border-left: 13em solid #eeeeee; + padding-left: 1em; + background-color: #eeeeee; + } div.content { margin: 0; padding: 0; @@ -913,256 +921,6 @@ WOK } #column_right p { font-size:12px} #banner h1 { margin:0px; padding:10px} -WOK - end - def html_bk #stylesheet for html... check use -< */ -/* - -*/ -/* subtoc --> */ - p.subtoc4 { - font-size: x-small; - text-align: left; - line-height: 100%; - margin-left: 10%; - margin-right: 10%; - margin-top: 5px; - margin-bottom: 5px; - } - p.subtoc5 { - font-size: x-small; - text-align: left; - line-height: 100%; - margin-left: 15%; - margin-right: 10%; - margin-top: 5px; - margin-bottom: 5px; - } - p.subtoc6 { - font-size: x-small; - text-align: left; - line-height: 100%; - margin-left: 20%; - margin-right: 10%; - margin-top: 5px; - margin-bottom: 5px; - } - p.ocn { - display: block; - text-align: right; - vertical-align: super; - color: #999999; - font-size: xx-small; - margin-right: 0mm; - margin-top: 0px; - margin-bottom: 0px; - } - p.note { - display: block; - font-size: small; - font-family: #{fonts}; - font-weight: normal; - line-height: 150%; - text-align: justify; - margin-left: 10%; - margin-right: 5%; - margin-top: 4px; - margin-bottom: 0px; - } - en { - font-size: xx-small; - vertical-align: super; - } - i { font-style: italic; } - b { font-style: bold; } - u { text-decoration: underline; } - br { display: block; } WOK end def xhtml #stylesheet for xhtml diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 28098f6c..fd2294ba 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -359,7 +359,10 @@ WOK else format_toc.lev1 end toc[:seg_mini]=if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ - format_toc.mini_tail + x=if @md.concord_make + format_toc.mini_concord_tail + else format_toc.mini_tail + end else format_toc.mini_lev1 end title=if para =~/(#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/ diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 0bfe580e..4992dc6d 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -765,7 +765,7 @@ WOK wgt=Widget.new(@md) #dir=SiSU_Env::Info_env.new(@md.fns) x=if @md.concord_make - %{ + %{
    #{wgt.seg(@vz.nav_txt_toc_link)} @@ -988,7 +988,9 @@ WOK toc_metadata end def title_banner(title,subtitle,creator) - %{

    + %{ +

    +

    #{title}

    @@ -1002,7 +1004,9 @@ WOK #{@vz.txt_home} -

    } +

    +
    +} end end class Head_scroll < Head_toc @@ -1055,7 +1059,7 @@ WOK # ##{@vz.table_close}} # end - def title_endnote + def title_endnote #revisit # %{#{@vz.margin_txt_0} # #{@vz.paragraph_txt} # @@ -1063,37 +1067,6 @@ WOK #   ##{@vz.table_close}} end -# def tail -# %{
    -##{@vz.margin_txt_0} -#
    -# -# -#
    -##{@vz.banner_band} -# -#
    #@tocband_scroll
    -#
    -#
    -##{@vz.paragraph_txt} -#
    -# #{@vz.credits_splash} -# #{@vz.credits_sisu} -#
    -##{@vz.margin_num} -##{@vz.table_close} -# -# -# -# -# -# -# -# #{@md.title*10} -# -# -#} -# end end class Format_text_object @vz=SiSU_Env::Get_init.instance.skin @@ -1130,6 +1103,30 @@ WOK end @vz=SiSU_Env::Get_init.instance.skin end + def endnote_body + %{ +

    + #@one +

    +} + end + def endnote_body_indent + %{ +

    + #@one +

    +} + end + def no_paranum + %{ +
    + +

    + #@one #@two +

    +
    +} + end def para_form_css(tag,attrib) # regular paragraphs shaped here ul=ulc='' ul,ulc="
      \n ","\n
    " if @tag =~/li/ @@ -1157,26 +1154,80 @@ WOK def bullet para_form_css('li','bullet') end - def format(tag,atrib) - para_form_css(tag,atrib) + def format(tag,attrib) + para_form_css(tag,attrib) end - def dl - "
    #@one #@two
    " + + def header_normal(tag,attrib) + %{ +
    + #{@p_num.ocn_display} + <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} + #@headname + #@parablock + +
    +} end - def table_css_end # - '
    -

    -
    ' + def heading_body + header_normal('p','norm') end - def no_paranum + def heading_body1 + header_normal('h1','norm') + end + def heading_body2 + header_normal('h2','norm') + end + def heading_body3 + header_normal('h3','norm') + end + def heading_body4 + header_normal('h4','norm') + end + def heading_body5 + header_normal('h5','norm') + end + def heading_body6 + header_normal('h6','norm') + end + def title_header(tag,attrib) + %{ +
    +<#{tag} class="#{attrib}"> + #@one + +
    +} + end + def title_header1 + title_header('h1','tiny') + end + def title_header2 + title_header('h2','tiny') + end + def title_header3 + title_header('h3','tiny') + end + def title_header4 + '' + end + def title_header4_old %{
    -

    - #@one #@two -

    +
    } + end + def dl + "
    #@one #@two
    " + end + def table_css_end # + '
    +

    + ' end def gsub_body case @one @@ -1230,52 +1281,6 @@ WOK super(md,*txt) @vz=SiSU_Env::Get_init.instance.skin end - def endnote_body - %{ -

    - #@one -

    -} - end - def header_normal - %{ -
    - #{@p_num.ocn_display} - <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} - #@headname - #@parablock - -
    -} - end - def heading_body - @tag,@class='p','norm' - header_normal - end - def heading_body1 - @tag,@class='h1','norm' - header_normal - end - def heading_body2 - @tag,@class='h2','norm' - header_normal - end - def heading_body3 - @tag,@class='h3','norm' - header_normal - end - def heading_body4 - @tag,@class='h4','norm' - header_normal - end - def heading_body5 - @tag,@class='h5','norm' - header_normal - end - def heading_body6 - @tag,@class='h6','norm' - header_normal - end end class Format_seg < Format_text_object def initialize(md='',*txt) @@ -1328,20 +1333,6 @@ WOK def navigation_toc_lev5 end def navigation_toc_lev6 - end - def endnote_body_seg_tail #FIX - %{ -

    - #@one -

    -} - end - def endnote_body_seg_tail_indent - %{ -

    - #@one -

    -} end def endnote_seg_body(fn='') #FIX #url construction keep within single line... BUG WATCH 200408 fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info @@ -1351,39 +1342,7 @@ WOK

    } end - def title_header - %{ -
    - #@two -<#@tag class="#@class"> - #@one - -
    -} - end - def title_header1 - @tag,@class='h1','banner' - title_header - end - def title_header2 - @tag,@class='h2','banner' - title_header - end - def title_header3 - @tag,@class='h3','banner' - title_header - end - def title_header4 - %{ -
    - - -
    -} - end - def subtoc_lev + def subtoc_lev(tag,attrib) one=if @one \ and @one =~/<\/?i>|/mi @one.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text @@ -1396,50 +1355,44 @@ WOK one.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') one.gsub!(/ \d+<\/sup> /m,'') end - %{<#@tag class="#@class"> - - #{one} - #{note} - } + %{<#{tag} class="#{attrib}"> + #{one} #{note} + } end def subtoc_lev5 - @tag,@class='h5','subtoc' - subtoc_lev if @one + subtoc_lev('h5','subtoc') if @one end def subtoc_lev6 - @tag,@class='h6','subtoc' - subtoc_lev if @one + subtoc_lev('h6','subtoc') if @one end #% para sisu - def header4 - %{ -
    -#{@p_num.ocn_display} -

    #{@p_num.name} - #@format - #@parablock -

    -
    -} - end - def header_sub + def header_sub(tag,attrib) @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') %{
    - #{@p_num.ocn_display} - <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} #{@headname} + #{@p_num.ocn_display} + <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headname} #{@parablock} - +
    } end def header5 - @tag,@class='p','bold' - header_sub + header_sub('p','bold') end def header6 - @tag,@class='p','bold' - header_sub + header_sub('p','bold') + end + def header4 + %{ +
    + #{@p_num.ocn_display} +

    #{@p_num.name} + #@format + #@parablock +

    +
    +} end def navigation_header4 %{ @@ -1528,22 +1481,21 @@ WOK # # Document Information (metadata) # - x=if @md.concord_make - %{ -

    - Concordance (wordlist) -

    + %{

    Manifest (alternative outputs)

    } - else - %{ + end + def mini_concord_tail + %{ +

    + Concordance (wordlist) +

    Manifest (alternative outputs)

    } - end end end end diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index c4d136b7..db387105 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -221,11 +221,11 @@ module SiSU_HTML_seg if @@is1 == 1 @dc_creator=%{#{@md.dc_creator}\n} if @md.dc_creator.to_s =~/\S/ @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) - endnote_section_close=unless @@get_hash_fn =~/metadata/ - format_head_seg.endnote_section_close + conditional_div_close=unless @@get_hash_fn =~/metadata/ #watch + '' else '' end - @@seg[:tocband_bannerless] << endnote_section_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) + @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 @@ -270,6 +270,7 @@ module SiSU_HTML_seg end def markup(para) @debug=[] + para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'') format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if para !~/^#{Rx[:meta]}/ m=para[/.+?#{Mx[:id_o]}~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] @@ -386,9 +387,9 @@ module SiSU_HTML_seg filename_seg=[] filename_seg << @@seg[:title] << @@seg[:tocband_banner] if type !~/endnote/ - filename_seg << @@minitoc << @@seg[:main] + filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] else - filename_seg << @@seg[:header_endnotes] << @@minitoc << %{\n
    \n} << @@seg[:endnote_all] + filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
    \n} << @@seg[:endnote_all] #<< '
    ' end filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] filename_seg.flatten!.compact! @@ -477,8 +478,8 @@ module SiSU_HTML_seg try.each do |e| format_seg=SiSU_HTML_Format::Format_seg.new(@md,e) note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ - format_seg.endnote_body_seg_tail_indent - else format_seg.endnote_body_seg_tail + format_seg.endnote_body_indent + else format_seg.endnote_body end @@seg_endnotes_array << note_match end -- cgit v1.2.3 From 0c15db877ebd266b5f25af1aa1b185eb9ec392f6 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 17 Aug 2008 18:17:30 -0400 Subject: html document structure, div markers, watch --- lib/sisu/v0/html_format.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 4992dc6d..8fcd1e25 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -614,6 +614,8 @@ WOK
    + + } end def scroll_tail #debug @@ -629,7 +631,10 @@ WOK -} + + + +} end def seg_navigation_tail #this is a bug area, look up and "tidy" #nav=scroll_head_navigation_band @@ -645,6 +650,8 @@ WOK + + } end end @@ -918,6 +925,8 @@ WOK + + } end def navigation_band(segtocband,seg_table_top_control) #change name to navigaion_band_banner -- cgit v1.2.3 From d74651a9c0102cc55a6b495eb4e2f12d3fca7795 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 17 Aug 2008 23:17:25 -0400 Subject: rsync, replace --delete-after with --delete apparently not all versions of rsync accept more specific option --- lib/sisu/v0/sysenv.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index a259d991..ed0012e2 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -712,6 +712,7 @@ module SiSU_Env end def scp program='scp' + puts "scp -Cr #@input #@output" if @cmd =~/[vVM]/ if program_found?(program); system("scp -Cr #@input #@output") else puts "\tWARN: #{program} not found" end @@ -725,6 +726,7 @@ module SiSU_Env end msg='' msg=" && echo 'OK: #@input -> #@output'" unless @cmd =~/q/ + puts "rsync -az#{vb} #{action} #@input #@output" if @cmd =~/[vVM]/ system("rsync -az#{vb} #{action} #@input #@output #{msg}") else puts "\tWARN: #{program} not found" end @@ -2469,7 +2471,8 @@ WOK and remote_gen !~/\/\//) \ and @@flag_remote==true \ and @opt.cmd !~/U/ - System_call.new(local_gen,remote_gen,@opt.cmd).rsync('--delete-after') + delete_extra_files='--delete' # '--delete-after' + System_call.new(local_gen,remote_gen,@opt.cmd).rsync(delete_extra_files) if FileTest.file?("#{local_src}/#{src_txt}") System_call.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync if defined? @md.ec[:image] and not @md.ec[:image].empty? @@ -2569,10 +2572,11 @@ WOK and @rc['permission_set']['remote_base_site'] \ and @@flag_remote==true \ and @opt.cmd !~/U/ + delete_extra_files='--delete' # '--delete-after' puts "begin rsync_base_sync: #{local} -> #{remote}" - System_call.new("#{local}/_sisu/image_sys/",remote).rsync('--delete-after') - System_call.new("#{local}/_sisu/image/",remote).rsync('--delete-after') - System_call.new("#{local}/#{@env.path.style}/",remote).rsync('--delete-after') + System_call.new("#{local}/_sisu/image_sys/",remote).rsync(delete_extra_files) + System_call.new("#{local}/_sisu/image/",remote).rsync(delete_extra_files) + System_call.new("#{local}/#{@env.path.style}/",remote).rsync(delete_extra_files) elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_base_sync: #{local} -> #{remote}" @@ -2589,7 +2593,8 @@ WOK remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." if @@flag_remote #if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] #and @@flag_remote==true and @opt.cmd !~/U/ - System_call.new(local,remote).rsync('--delete-after') + delete_extra_files='--delete' # '--delete-after' + System_call.new(local,remote).rsync(delete_extra_files) elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_sitemaps: #{local} -> #{remote}" -- cgit v1.2.3 From 5787bd8ec03e93e90dd90d5fbcb66bdb49a07a84 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 18 Aug 2008 23:41:37 -0400 Subject: a bit of a cleanup, and change reference to null to ordinary --- lib/sisu/v0/html_format.rb | 67 +++++++--------------------------------- lib/sisu/v0/html_scroll.rb | 4 +-- lib/sisu/v0/html_segments.rb | 6 ++-- lib/sisu/v0/manpage.rb | 19 ------------ lib/sisu/v0/odf.rb | 20 ------------ lib/sisu/v0/plaintext.rb | 19 ------------ lib/sisu/v0/shared_structure.rb | 2 +- lib/sisu/v0/shared_txt.rb | 3 +- lib/sisu/v0/sst_to_s_xml_dom.rb | 21 +------------ lib/sisu/v0/sst_to_s_xml_node.rb | 50 +----------------------------- lib/sisu/v0/sst_to_s_xml_sax.rb | 21 +------------ lib/sisu/v0/wikispeak.rb | 2 +- lib/sisu/v0/xhtml.rb | 2 +- lib/sisu/v0/xml.rb | 2 +- lib/sisu/v0/xml_dom.rb | 2 +- 15 files changed, 24 insertions(+), 216 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 8fcd1e25..af36dc30 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -79,6 +79,9 @@ module SiSU_HTML_Format ocn_class='ocn_off' @paranum.gsub(/^(\d+|)$/, %{}) + elsif @paranum.to_i == 0 + @paranum.gsub(/^(\d+|)$/, + %{}) else ocn_class='ocn' @paranum.gsub(/^(\d+|)$/, @@ -798,51 +801,6 @@ WOK
    } end end - def toc_pre_next3 #used with seg_doc_types in seg_nav_band #with pdf & other doc types #knxjs - %{ - - -\n} + @manifest[:html] << %{\n} end def output_tests if FileTest.file?("#@base_path/#{@md.fn[:toc]}")==true @@ -568,16 +569,26 @@ SiSU manifest: #{@md.title} #{minitoc.to_s}
    -

    #{@md.dc_title}

    +

    #{@translate.manifest_description}

    +

    #{@md.dc_title}

    #{@md.dc_creator}

    +

    +  Document, Available Filetypes +

    +

    +  Document Metadata +

    +

    +      (metadata suggested links (if any) +

    - - #{@vz.png_nav_previous} - - - - #{@vz.png_nav_toc} - - - - #{@vz.png_nav_next} - -#{@vz.table_close}} - end - def toc_next3 #used with seg_doc_types in seg_nav_band #with pdf & other doc types #knxjs - %{ - - -
    - - #{@vz.png_nav_toc} - - - - #{@vz.png_nav_next} - -#{@vz.table_close}} - end - def toc_pre3 #used with seg_doc_types in seg_nav_band #with pdf and other doc types #knxjs - # note endnotes is now two back, with insertion between end of text and metadata, but what happens where no endnote? - %{ - -
    - - #{@vz.png_nav_previous} - - - #{@vz.png_nav_toc} - -#{@vz.table_close}} - end def title_endnote(title,subtitle,creator,table_top_control) # %{#{@vz.banner_instrument_cover_band_seg} #

    @@ -1088,19 +1046,12 @@ WOK @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/ #problem introduced @one_stripped=@one.gsub(rgx,'\1') if @one =~rgx #problem introduced - @link,@linkname=txt[0],txt[1] - @format,parablock=txt[0],txt[1] - @parablock=parablock - ##performance hit does not justify action: - #@parablock=if parablock=~/\S+/ and parablock !~/ + if @one + %{<#{tag} class="#{attrib}"> #@one } + else '' + end end def lev1 lev('h1','toc') diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 93e30494..01720862 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -108,7 +108,7 @@ module SiSU_HTML_scroll @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_scroll m=/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ #watch case @sto.format when /^1:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body1 when /^2:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body2 @@ -127,7 +127,7 @@ module SiSU_HTML_scroll when /^(?:b|bold)$/; para=@sto.scroll_lev_para_ocn.bold when /^(?:verse|group|alt)$/; para=@sto.scroll_lev_para_ocn.para when /^code$/; para=@sto.scroll_lev_para_ocn.code - when /null/ # see whether u can improve + when /ordinary/ # see whether u can improve if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ format_txt_obj.gsub_body para=@sto.scroll_lev_para_ocn.para diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index db387105..7a4a4fb6 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -306,7 +306,7 @@ module SiSU_HTML_seg end if para[/#{Mx[:id_o]}~(\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp)#{Mx[:id_c]}$/] @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_seg - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ #watch para=case @sto.format # work area 2003w29 ||@|def lev_segname_para_ocn| when /^4:/; @sto.seg_lev_para_ocn.header4 # work on see Split_text_object when /^5:/; @sto.seg_lev_para_ocn.header5 @@ -323,7 +323,7 @@ module SiSU_HTML_seg @sto.seg_lev_para_ocn.para when /^code$/ @sto.seg_lev_para_ocn.code - when /null/ + when /ordinary/ if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \ and para !~/^#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ format_txt_obj.gsub_body @@ -349,8 +349,6 @@ module SiSU_HTML_seg if para[/(.*)#{Mx[:id_o]}~0;(?:u|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/] #% watch u & m? one,two=$1,$2 format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) -#FIX --> not that undefined, rather is not needed, should not be visited, and remove - #para=format_seg.seg_no_paranum #% undefined end para.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint if para =~/ / #endnote- note- diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index edbb55f9..fb6f6b2e 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -369,25 +369,6 @@ WOK when /^(6):(\S*)/ manpage_structure(para,$1,@sto.ocn,$2) @sto.lev_para_ocn.heading_body6 - #when /^(i1)$/ - # #formatMono.gsubBody - # #para=@sto[:lev_para_ocn].scrIndent1 - #when /^(i2)$/ - # formatMono.gsubBody - # para=@sto[:lev_para_ocn].scrIndent2 - #when /^(center)$/ - # para.gsub!(/(.+)/, - # %{
    (\\1)
    }) - # para=@sto[:lev_para_ocn].scrPara - #when /^(b|bold)$/ - # para.gsub!(/(.+)/, - # %{(\\1)}) - # para=@sto[:lev_para_ocn].scrPara - #when /null/ # see whether u can improve - # if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) - # #formatMono.gsubBody - # #para=@sto[:lev_para_ocn].scrPara - # end else manpage_structure(para,nil,nil,nil) #watch may be problematic para diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index f3e3385f..9fb6b51e 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -533,26 +533,6 @@ module SiSU_ODF when /^(6):(\S*)/ odf_structure(para,$1,@sto.ocn,$2) para - #@sto.lev_para_ocn.heading_body6 - #when /^(i1)$/ - # #formatMono.gsubBody - # #para=@sto[:lev_para_ocn].scrIndent1 - #when /^(i2)$/ - # formatMono.gsubBody - # para=@sto[:lev_para_ocn].scrIndent2 - #when /^(center)$/ - # para.gsub!(/(.+)/, - # %{
    (\\1)
    }) - # para=@sto[:lev_para_ocn].scrPara - #when /^(b|bold)$/ - # para.gsub!(/(.+)/, - # %{(\\1)}) - # para=@sto[:lev_para_ocn].scrPara - #when /null/ # see whether u can improve - # if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) - # #formatMono.gsubBody - # #para=@sto[:lev_para_ocn].scrPara - # end else odf_structure(para,nil,nil,nil) #watch may be problematic para end diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 6378c2d5..9a246e49 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -360,25 +360,6 @@ WOK when /^(6):(\S*?)/ plaintext_structure(para,$1,@sto.ocn,$2) @sto.lev_para_ocn.heading_body6 - #when /^(i1)$/ - # #formatMono.gsubBody - # #para=@sto[:lev_para_ocn].scrIndent1 - #when /^(i2)$/ - # formatMono.gsubBody - # para=@sto[:lev_para_ocn].scrIndent2 - #when /^(center)$/ - # para.gsub!(/(.+)/, - # %{
    (\\1)
    }) - # para=@sto[:lev_para_ocn].scrPara - #when /^(b|bold)$/ - # para.gsub!(/(.+)/, - # %{(\\1)}) - # para=@sto[:lev_para_ocn].scrPara - #when /null/ # see whether u can improve - # if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) - # #formatMono.gsubBody - # #para=@sto[:lev_para_ocn].scrPara - # end else plaintext_structure(para,nil,nil,nil) #watch may be problematic para diff --git a/lib/sisu/v0/shared_structure.rb b/lib/sisu/v0/shared_structure.rb index 5a3993c6..cdfe9bf3 100644 --- a/lib/sisu/v0/shared_structure.rb +++ b/lib/sisu/v0/shared_structure.rb @@ -67,7 +67,7 @@ module SiSU_Structure attr_reader :format,:text,:ocn,:scroll_lev_para_ocn,:seg_lev_para_ocn,:lev_para_ocn def initialize(md,para) @md,@para=md,para - @format,@ocn='null','null' + @format,@ocn='ordinary','ordinary' #@format,@ocn=nil,nil @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern end diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb index 484a5f05..41d6d815 100644 --- a/lib/sisu/v0/shared_txt.rb +++ b/lib/sisu/v0/shared_txt.rb @@ -228,8 +228,7 @@ module SiSU_text_parts_flatfile attr_reader :format,:text,:ocn,:lev_para_ocn def initialize(md,para) @md,@para=md,para - @format,@ocn='null','null' - #@format,@ocn=nil,nil + @format,@ocn='ordinary','ordinary' @@dl ||=SiSU_Env::Info_env.new.digest.length end def lev_segname_para_ocn diff --git a/lib/sisu/v0/sst_to_s_xml_dom.rb b/lib/sisu/v0/sst_to_s_xml_dom.rb index 5976d82b..efb60a88 100644 --- a/lib/sisu/v0/sst_to_s_xml_dom.rb +++ b/lib/sisu/v0/sst_to_s_xml_dom.rb @@ -386,7 +386,7 @@ WOK @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc if para !~/^(?:%\s|0~|@\S+?:)/ - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ + format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_clean(para) @@ -412,25 +412,6 @@ WOK xml_clean(para) xml_structure($1,para,$2) para=@sto.lev_para_ocn.heading_body6 - #when /^(i1)$/i - # #format_scroll.gsubBody - # #para=@sto.lev_para_ocn.scrIndent1 - #when /^(i2)$/i - # format_scroll.gsubBody - # para=@sto.lev_para_ocn.scrIndent2 - #when /^(center)$/i - # para.gsub!(/(.+)/, - # %{
    (\\1)
    }) - # para=@sto.lev_para_ocn.scrPara - #when /^(b|bold)$/i - # para.gsub!(/(.+)/, - # %{(\\1)}) - # para=@sto.lev_para_ocn.scrPara - #when /null/ # see whether u can improve - # if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) - # #format_scroll.gsubBody - # #para=@sto.lev_para_ocn.scrPara - # end else if para =~ /<:verse>/ para=poem_structure(para) diff --git a/lib/sisu/v0/sst_to_s_xml_node.rb b/lib/sisu/v0/sst_to_s_xml_node.rb index ed7f4b10..d9451149 100644 --- a/lib/sisu/v0/sst_to_s_xml_node.rb +++ b/lib/sisu/v0/sst_to_s_xml_node.rb @@ -440,54 +440,6 @@ WOK end end end - #obj.each do |o| - # para=o.txt unless o.txt =~/^%% / #comments are lost, consider - # if para - # para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - # para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - # para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - # para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') - # para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_paragraph]}/,'
    ') - # if @rcdc==false \ - # and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) - # if para !~/(^0~|^@\S+?:|^\s*$||)/ - # @rcdc=true - # end - # @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para - # unless @rcdc - # format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ - # case @sto.format - # when /^(1):(\S*)/ - # node_structure(o,para,$1,$2) - # when /^(2):(\S*)/ - # node_structure(o,para,$1,$2) - # when /^(3):(\S*)/ - # node_structure(o,para,$1,$2) - # when /^(4):(\S*)/ # work on see Split_text_object - # node_structure(o,para,$1,$2) - # when /^(5):(\S*)/ - # node_structure(o,para,$1,$2) - # when /^(6):(\S*)/ - # node_structure(o,para,$1,$2) - # else - # if para =~ /<:verse>/ - # node_structure(o,para) - # elsif para =~ /<:group>/ - # node_structure(o,para) - # elsif para =~ /<:code>/ - # node_structure(o,para) - # elsif para =~/|)/ @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ + format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_clean(para) diff --git a/lib/sisu/v0/sst_to_s_xml_sax.rb b/lib/sisu/v0/sst_to_s_xml_sax.rb index 4b3ca7c8..e6864405 100644 --- a/lib/sisu/v0/sst_to_s_xml_sax.rb +++ b/lib/sisu/v0/sst_to_s_xml_sax.rb @@ -293,7 +293,7 @@ WOK if para !~/(^0~|^@\S+?:|^\s*$||)/ @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ + format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_clean(para) @@ -319,25 +319,6 @@ WOK xml_clean(para) xml_structure(para,$1,$2) para=@sto.lev_para_ocn.heading_body6 - #when /^(i1)$/i - # #format_scroll.gsubBody - # #para=@sto[:lev_para_ocn].scrIndent1 - #when /^(i2)$/i - # format_scroll.gsubBody - # para=@sto[:lev_para_ocn].scrIndent2 - #when /^(center)$/i - # para.gsub!(/(.+)/, - # %{
    (\\1)
    }) - # para=@sto[:lev_para_ocn].scrPara - #when /^(b|bold)$/i - # para.gsub!(/(.+)/, - # %{(\\1)}) - # para=@sto[:lev_para_ocn].scrPara - #when /null/ # see whether u can improve - # if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/) - # #format_scroll.gsubBody - # #para=@sto[:lev_para_ocn].scrPara - # end else if para =~ /<:verse>/ para=poem_structure(para) diff --git a/lib/sisu/v0/wikispeak.rb b/lib/sisu/v0/wikispeak.rb index 2b0ba560..0e8d3989 100644 --- a/lib/sisu/v0/wikispeak.rb +++ b/lib/sisu/v0/wikispeak.rb @@ -105,7 +105,7 @@ module SiSU_Wikispeak attr_reader :format,:lev,:text,:ocn,:lev_para_ocn def initialize(para) @para=para - @format,@ocn='null','null' + @format,@ocn='ordinary','ordinary' @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern end def lev_segname_para_ocn diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 067ed8a8..593d26c4 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -289,7 +289,7 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ + format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_structure(para,$1,@sto.ocn,$2) diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 9f897266..2531a962 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -313,7 +313,7 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ + format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_structure(para,$1,@sto.ocn,$2) diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index 9bcb15ec..38ba0a87 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -371,7 +371,7 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ + format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_markup(para) -- cgit v1.2.3 From 08c69d074001507d64cd5960c8679ec91a5a8353 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 23 Aug 2008 12:01:59 -0400 Subject: pass Hash to Format classes; some match tuning in dal --- lib/sisu/v0/concordance.rb | 4 +- lib/sisu/v0/dal.rb | 2 +- lib/sisu/v0/dal_syntax.rb | 32 ++-- lib/sisu/v0/db_import.rb | 30 ++-- lib/sisu/v0/html.rb | 99 +++++++----- lib/sisu/v0/html_format.rb | 242 +++++++++++++---------------- lib/sisu/v0/html_scroll.rb | 30 ++-- lib/sisu/v0/html_segments.rb | 67 ++++---- lib/sisu/v0/manpage.rb | 18 +-- lib/sisu/v0/manpage_format.rb | 25 ++- lib/sisu/v0/odf.rb | 61 +++++--- lib/sisu/v0/odf_format.rb | 100 +++++++----- lib/sisu/v0/plaintext.rb | 3 +- lib/sisu/v0/plaintext_format.rb | 26 +++- lib/sisu/v0/shared_html_lite.rb | 85 ++++++----- lib/sisu/v0/shared_structure.rb | 43 ++++-- lib/sisu/v0/shared_txt.rb | 46 ------ lib/sisu/v0/texinfo.rb | 40 +++-- lib/sisu/v0/texinfo_format.rb | 330 +++++++++++++++++++++------------------- lib/sisu/v0/texpdf.rb | 32 ++-- lib/sisu/v0/texpdf_format.rb | 318 +++++++++++++++++++++----------------- lib/sisu/v0/xhtml.rb | 33 ++-- lib/sisu/v0/xml.rb | 26 ++-- lib/sisu/v0/xml_dom.rb | 25 ++- lib/sisu/v0/xml_format.rb | 57 ++++--- 25 files changed, 961 insertions(+), 813 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 3e073900..8fe8c4ed 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -240,6 +240,7 @@ WOK and toy !~/^0$/ for word in line.scan(@rgx_scanlist) #%take in word or other match #word.gsub!(@rxp_clean,'') + word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'') word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') @@ -274,7 +275,8 @@ WOK word.gsub!(/^\(?[a-zA-Z]\)$/,'') word.gsub!(/^\d+(st|nd|rd|th)$/,'') word.gsub!(/^(\d+\.?)+$/, '') - word.gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') + word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') + word.gsub!(/:name#\S+/,'') word.gsub!(/^\S$/,'') word=nil if word =~/^\S$/ word=nil if word =~/^\s*$/ #watch diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index cf6d8e09..3187a538 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -614,7 +614,7 @@ module SiSU_DAL @subnumber=0 if para =~/#{Mx[:lv_o]}#{no1}:/ end if para =~/^#{Mx[:lv_o]}[1-6]:[\w-]*#{Mx[:lv_c]}/ \ - and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s+[\d.]+)\s/ \ + and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s*[\d.]+)\s/ \ and para !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ if para =~/^#{Mx[:lv_o]}#{no1}:/ t_no1+=1; t_no2=0; t_no3=0 diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 35f0582a..98c8cf51 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -240,7 +240,19 @@ module SiSU_Syntax end 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}") + if @md.subtitle and not @md.subtitle.empty? + if line =~/(?:by\s+)?(?:@creator|@author)/ + 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}") + else + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") + end + else + if line =~/(?:by\s+)?(?:@creator|@author)/ + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.title},
    \\2#{@md.dc_creator}") + else + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s*$/,"\\1 #{@md.title}") + end + end line.gsub!(/^(1~\??) @title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") # 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 @@ -285,16 +297,16 @@ module SiSU_Syntax #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 + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics # depreciated ^ - 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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\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 diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index addd1ae1..52bb3ad2 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -402,7 +402,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_minus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_minus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -443,7 +444,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -482,7 +484,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -521,7 +524,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -570,11 +574,14 @@ module SiSU_DB_import if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end @col[:body]=if txt=~/#{Mx[:gr_o]}T[h]?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/ #watch - SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).html_table + txt_obj={:txt =>txt,:col =>@col} + SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).html_table elsif txt=~/^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/ - SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).indent($1) + txt_obj={:txt =>txt,:col =>@col} + SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).indent($1) else - SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).norm + txt_obj={:txt =>txt,:col =>@col} + SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).norm end special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @@ -593,7 +600,8 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote + txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} + body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) @@ -633,7 +641,8 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote + txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} + body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) @@ -674,7 +683,8 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote + txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} + body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index fd2294ba..2dc75d60 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -201,7 +201,8 @@ module SiSU_HTML else '_top' end s_lnk_url,s_lnk_lnk=l[:url],l[:say] - lev_para_ocn=SiSU_HTML_Format::Format_toc.new(@md,s_lnk_url,s_lnk_lnk,target) + txt_obj={:lnk_url =>s_lnk_url,:lnk_txt =>s_lnk_lnk,:target =>target} + lev_para_ocn=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) @links_guide_toc << lev_para_ocn.links_guide if s_lnk_lnk end end @@ -236,7 +237,8 @@ module SiSU_HTML endnote_array << pg.scan(/#{Mx[:en_b_o]}[\d+]+(.+?)#{Mx[:en_b_c]}/m) end endnote_array.flatten.each do |note| - format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,note) + txt_obj={:txt =>note} + format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,txt_obj) @scr_endnotes << format_scroll.endnote_body end end @@ -318,12 +320,17 @@ WOK @@toc[:scr] << format_head_scroll.toc_owner_details end end +#not used --> def level_endnotes if @md.flag_endnotes format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) @@toc[:scr] << format_head_scroll.toc_endnote end end + def level_concordance + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + @@toc[:seg_mini] << format_head_toc.mini_seg_concordance + end def level_metadata format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) @@toc[:scr] << format_head_toc.metadata @@ -336,6 +343,7 @@ WOK @@toc[:seg] << format_head_toc.concordance @@toc[:seg_mini] << format_head_toc.mini_concordance end +# <-- not used def level_1 para=@data unless para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -353,7 +361,8 @@ WOK %{
    #{linkname}} end toc={} - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:seg]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ format_toc.lev0 else format_toc.lev1 @@ -379,7 +388,8 @@ WOK end %{#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ format_toc.lev0 else format_toc.lev1 @@ -392,12 +402,13 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') end para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,linkname) + txt_obj={:txt =>linkname} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev2 toc[:seg_mini]=format_toc.mini_lev2 @@ -407,7 +418,8 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev2 toc end @@ -416,12 +428,13 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') para.gsub(/(.*?)<\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,linkname) + txt_obj={:txt =>linkname} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev3 toc[:seg_mini]=format_toc.mini_lev3 @@ -431,7 +444,8 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev3 toc end @@ -441,8 +455,8 @@ WOK unless para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ para.gsub!(@pat_strip_heading_name,'\1') para[@pat_heading] - linkname,link=$1.strip,$2 if $& - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) if link + linkname,ocn=$1.strip,$2 if $& + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn end para.gsub!(/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') if para =~/^#{Mx[:lv_o]}4:/ @@ -460,8 +474,9 @@ WOK %{\\1 \\2 \\3 }) end - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) if link - format_toc=SiSU_HTML_Format::Format_toc.new(@md,seg_link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn + txt_obj={:txt =>seg_link} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev4 toc[:seg_mini]=format_toc.mini_lev4 @@ -471,7 +486,8 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} if p_num end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev4 toc end @@ -482,10 +498,10 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') end para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end toc={} if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -493,15 +509,17 @@ WOK para.gsub!(m,'') title=linkname else - lnk_n_txt=%{ + lnk_n_txt=%{ #{linkname} } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,lnk_n_txt) + txt_obj={:txt =>lnk_n_txt} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:seg]=format_toc.lev5 toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev5 toc end @@ -511,10 +529,10 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') end para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end toc={} if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -522,15 +540,17 @@ WOK para.gsub!(m,'') title=linkname else - lnk_n_txt=%{ + lnk_n_txt=%{ #{linkname} } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,lnk_n_txt) + txt_obj={:txt =>lnk_n_txt} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:seg]=format_toc.lev6 toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev6 toc end @@ -592,20 +612,23 @@ WOK tmp_head=nil doc_title_endnote=@md.title.gsub(/(\*+)/,'\1') tmp_head=doc_title_endnote + "\n" - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) + txt_obj={:txt =>tmp_head} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if not @md.subtitle.nil? \ and not @md.subtitle.empty? tmp_head=@md.subtitle + "\n" - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) + txt_obj={:txt=>tmp_head} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end if @md.dc_creator creator_endnote=@md.dc_creator.gsub(/(\*+)/,%{ \\1}) tmp_head=creator_endnote + "\n" - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) + txt_obj={:txt =>tmp_head} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index af36dc30..1d82ddfe 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -61,10 +61,9 @@ module SiSU_HTML_Format include SiSU_Viz class Paragraph_number - def initialize(md,paranum) - @md=md - @paranum=paranum[/(\d+)/m,1] - @paranum ||='' + def initialize(md,ocn) + @md,@ocn=md,ocn[/(\d+)/m,1] + @ocn ||='' vz=SiSU_Env::Get_init.instance.skin @skin_no_ocn=if defined? vz.ocn_display_off \ and vz.ocn_display_off == true @@ -77,75 +76,31 @@ module SiSU_HTML_Format or @md.mod.inspect =~/--no-ocn/ \ or @skin_no_ocn ocn_class='ocn_off' - @paranum.gsub(/^(\d+|)$/, + @ocn.gsub(/^(\d+|)$/, %{}) - elsif @paranum.to_i == 0 - @paranum.gsub(/^(\d+|)$/, - %{}) + elsif @ocn.to_i == 0 + @ocn.gsub(/^(\d+|)$/, + %{}) else ocn_class='ocn' - @paranum.gsub(/^(\d+|)$/, - %{}) + @ocn.gsub(/^(\d+|)$/, + %{}) end end def name - %{} + %{} end def id #w3c? "tidy" complains about numbers as identifiers ! annoying - %{id="o#@paranum"} + %{id="o#{@ocn}"} end def goto - %{} - end - end - class Paragraph_id_ocn #used by table version #work area 2003w48 - attr_accessor :paranum,:font,:p_num - def initialize(md,paranum) - @paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,Paragraph_number.new(md,paranum) #font - #@paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,SiSU_HTML_Format::Paragraph_number.new(md,paranum) #font - end - def txt - %{

    #{@p_num.name} - } - end - def txt_00 - %{

    #{@p_num.name} - } - end - def font_citation - %{} - end - def endnote - %{

    #{@p_num.name} - } - end - def table - %{

    #{@p_num.name} - } - end - def tiny - %{

    #{@p_num.name} - } - end - def small - %{

    #{@p_num.name} - } # keep but not used? - end - def font_tiny - %{} - end - def font_small - %{} - end - def header_ - %{

    #{@p_num.name} - } + %{} end end class Head_information include SiSU_Viz attr_reader :md,:sfx,:pdf,:rdf,:vz - def initialize(md='') + def initialize(md) @md=md @sfx,@pdf=@md.sfx,@md.pdf @rdf=SiSU_XML_tags::RDF.new(md) @@ -1038,27 +993,39 @@ WOK class Format_text_object @vz=SiSU_Env::Get_init.instance.skin @@dp=nil - attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped - def initialize(md='',*txt) - @md,@one,@two,@three=md,txt[0],txt[1],txt[2] - rgx=/^#{Mx[:lv_o]}\d:\S*?#{Mx[:lv_c]}/ - @one_stripped=@one.gsub(rgx,'') if @one =~rgx - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern - rgx=/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/ #problem introduced - @one_stripped=@one.gsub(rgx,'\1') if @one =~rgx #problem introduced - @format,@parablock=txt[0],txt[1] - @one.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') if @one - @parablock.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') if @parablock - if txt[2]=~/\d+/ - @paranum=txt[2][/(\d+)/m,1] # unless paranum =~/#/ - @p_num=Paragraph_number.new(@md,@paranum) - @para_id=Paragraph_id_ocn.new(@md,@paranum) #used by table version + attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @ocn =t_o[:ocn] || nil + @ocn_display =t_o[:ocn_display] || nil + @headname =t_o[:headname] || nil + @trailer =t_o[:trailer] || nil + @endnote_part_a =t_o[:endnote_part_a] || nil + @endnote_part_b =t_o[:endnote_part_b] || nil + @lnk_url =t_o[:lnk_url] || nil + @lnk_txt =t_o[:lnk_txt] || nil + @format =t_o[:format] || nil + @target =t_o[:target] || nil #occasionally passed but not used + else + if @md.cmd =~/M/ + p t_o.class + p caller + end + end + if @txt and not @txt.empty? + @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + end + if @ocn and @ocn=~/\d+/ #WATCH FIX + @p_num=Paragraph_number.new(@md,@ocn) end - @headname='' - if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ - headname=$1 #format[/\d~(\S+)/m,1] - @headname=if headname =~/^[a-zA-Z]/; %{} #consider: h_#{headname} - else %{} + if @format and not @format.empty? + if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ + headname=$1 #format[/\d~(\S+)/m,1] + @headname=if headname =~/^[a-zA-Z]/; %{} #consider: h_#{headname} + else %{} + end end end @vz=SiSU_Env::Get_init.instance.skin @@ -1066,14 +1033,14 @@ WOK def endnote_body %{

    - #@one + #{@txt}

    } end def endnote_body_indent %{

    - #@one + #{@txt}

    } end @@ -1082,7 +1049,7 @@ WOK

    - #@one #@two + #{@txt}

    } @@ -1094,7 +1061,7 @@ WOK
    #{@p_num.ocn_display} #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> - #@parablock + #{@txt} #{ulc}
    } @@ -1123,8 +1090,7 @@ WOK
    #{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #@headname - #@parablock + #{@headname}#{@txt}
    } @@ -1154,7 +1120,7 @@ WOK %{
    <#{tag} class="#{attrib}"> - #@one + #{@txt}
    } @@ -1176,13 +1142,13 @@ WOK
    } end - def dl - "
    #@one #@two
    " + def dl #check :trailer + "
    #{@txt} #{@trailer}
    " end def table_css_end # '

    @@ -1190,66 +1156,66 @@ WOK ' end def gsub_body - case @one + case @txt when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ - @one.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') - @one.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') + @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') + @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/ - @one.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') - @one.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') + @txt.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') + @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') when /^\s*\d{1,3}\.\s/ - @one.gsub!(/^\s*(\d+\.)/,'\1') + @txt.gsub!(/^\s*(\d+\.)/,'\1') when /^\s*[A-Z]\.\s/ - @one.gsub!(/^\s*([A-Z]\.)/,'\1') + @txt.gsub!(/^\s*([A-Z]\.)/,'\1') end end def bold_para %{#{@vz.margin_txt_0}

    - #@one + #{@txt}

    #{@vz.margin_num_css}     #{@vz.table_close}} end def bold_header - @one.gsub!(/[1-9]~(\S+)/,'') - @one.gsub!(/[1-9]~/,'') - @one.gsub!(/#{Mx[:id_o]}~0;[um]\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}\s*$/i,'') #watch & do differently + @txt.gsub!(/[1-9]~(\S+)/,'') + @txt.gsub!(/[1-9]~/,'') + @txt.gsub!(/#{Mx[:id_o]}~0;[um]\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}\s*$/i,'') #watch & do differently %{

    - #@one + #{@txt}

    #{@vz.margin_num_css}     #{@vz.table_close}} end def toc_head_copy_at - %{

    #@one

    \n} + %{

    #{@txt}

    \n} end def center - %{

    #@one

    \n} + %{

    #{@txt}

    \n} end def bold - %{

    #@one

    \n} + %{

    #{@txt}

    \n} end def center_bold - %{

    #@one

    \n} + %{

    #{@txt}

    \n} end end class Format_scroll < Format_text_object - def initialize(md='',*txt) - super(md,*txt) + def initialize(md,txt) + super(md,txt) @vz=SiSU_Env::Get_init.instance.skin end end class Format_seg < Format_text_object - def initialize(md='',*txt) - super(md,*txt) + def initialize(md,txt) + super(md,txt) end def navigation_toc_lev1_advert %{#{@banner.home_button}\n
    -#@one +#{@txt} #@two

    } end @@ -1263,7 +1229,7 @@ WOK

    - #@one + #{@txt}

    #{@vz.table_close}} @@ -1275,7 +1241,7 @@ WOK
    - #@one + #{@txt}

    #{@vz.table_close}} @@ -1286,7 +1252,7 @@ WOK

    - #@one + #{@txt}

    #{@vz.table_close}} end @@ -1298,41 +1264,41 @@ WOK fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info %{

    - #@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three + #{@endnote_part_a}#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#{@endnote_part_b}

    } end def subtoc_lev(tag,attrib) - one=if @one \ - and @one =~/<\/?i>|/mi - @one.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text - else @one + txt=if @txt \ + and @txt =~/<\/?i>|/mi + @txt.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text + else @txt end note='' - if one =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream + if txt =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream note=$1 note.gsub!(/[\n\s]+/m,' ') - one.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') - one.gsub!(/ \d+<\/sup> /m,'') + txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') + txt.gsub!(/ \d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> - #{one} #{note} + #{txt} #{note} } end def subtoc_lev5 - subtoc_lev('h5','subtoc') if @one + subtoc_lev('h5','subtoc') if @txt end def subtoc_lev6 - subtoc_lev('h6','subtoc') if @one + subtoc_lev('h6','subtoc') if @txt end #% para sisu def header_sub(tag,attrib) - @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') + @txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') %{
    #{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headname} - #{@parablock} + #{@txt}
    } @@ -1348,8 +1314,8 @@ WOK
    #{@p_num.ocn_display}

    #{@p_num.name} - #@format - #@parablock + #{@t_o[:format]} + #{@txt}

    } @@ -1358,42 +1324,40 @@ WOK %{

    - #@parablock + #{@txt}

    #{@vz.table_close}} end def navigation_header5 %{

    - #@parablock + #{@txt}

    } end def navigation_header6 %{

    - #@parablock + #{@txt}

    } end def navigation_center - "
    #@parablock
    " + "
    #{@txt}
    " end end class Format_toc < Format_text_object - def initialize(md='',*txt) - super(md,*txt) - @link,@linkname=@one,@two + def initialize(md,txt) + super(md,txt) end def links_guide - #@three distinguishes between _top and external, can be used e.g. for different colour scheme %{
  • - - #@linkname + + #{@lnk_txt}
  • } end def lev(tag,attrib) - if @one + if @txt %{<#{tag} class="#{attrib}"> - #@one + #{@txt} } else '' diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 01720862..9286df10 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -102,13 +102,16 @@ module SiSU_HTML_scroll unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/; para.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') end if para =~/.+?#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - paranum=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + ocn=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_scroll m=/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ #watch + if @sto.format =~/i[1-9]|ordinary/ #watch + txt_obj={:txt =>@sto.text} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + end case @sto.format when /^1:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body1 when /^2:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body2 @@ -139,30 +142,33 @@ module SiSU_HTML_scroll end elsif para =~/^#{Mx[:lv_o]}[1-9]:/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_c]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,para) + txt_obj={:txt =>para} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) para=format_txt_obj.bold_header elsif para =~/Endnotes?/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,'
    Note') + txt_obj={:txt =>'
    Note'} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) para=format_txt_obj.bold_para elsif para =~/Owner Details/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) @scr[:owner_details]=format_txt_obj.bold_para para='' elsif para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ #watch - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + cont=if $2.empty? + $1 + else "#{$1} #{$2}" #watch, check desired where $2 is other than space + end + txt_obj={:txt =>cont} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.no_paranum end if para =~// \ and para =~/^(?:\^~\d+\s|)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though para='' end - if para =~/<:center>/ #rules changed now a

    (.*)/.match(para).captures - format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,one,two) - end para.gsub!(/^#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/^<:\S?>/,'') para.gsub!(/#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/<:\S?>/,' '); para.gsub!(//,' ') para.strip! diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 7a4a4fb6..b457fe5c 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -228,41 +228,45 @@ module SiSU_HTML_seg @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') - paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,@@header1,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>@@header1,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header1.gsub(clean,'') @@header1.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is2 == 1 header2=@@header2 - paranum=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,header2,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>header2,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header2.gsub(clean,'') @@header2.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is3 == 1 header3=@@header3 - paranum=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,header3,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>header3,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header3.gsub(clean,'') @@header3.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is4 == 1 header4=@@header4 - paranum=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,header4,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>header4,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header4.gsub(clean,'') end @@seg[:header_endnotes]=format_head_seg.title_endnote(@md.title,@md.subtitle,@dc_creator,@@seg[:dot_nav]) @@ -275,8 +279,8 @@ module SiSU_HTML_seg if para !~/^#{Rx[:meta]}/ m=para[/.+?#{Mx[:id_o]}~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] if m - paranum=m[1].to_s - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + ocn=m[1].to_s + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/m \ or @@flag_alt==true @@ -299,14 +303,18 @@ module SiSU_HTML_seg end if para !~/^#{Mx[:lv_o]}[1-9]:|#{Rx[:meta]}/ if para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + cont="#{$1} #{$2}" #check where $2 is other than space + txt_obj={:txt =>cont} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.no_paranum end end if para[/#{Mx[:id_o]}~(\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp)#{Mx[:id_c]}$/] @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_seg - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ #watch + if @sto.format =~/i[1-9]|ordinary/ #watch + txt_obj={:txt =>@sto.text} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + end para=case @sto.format # work area 2003w29 ||@|def lev_segname_para_ocn| when /^4:/; @sto.seg_lev_para_ocn.header4 # work on see Split_text_object when /^5:/; @sto.seg_lev_para_ocn.header5 @@ -348,11 +356,13 @@ module SiSU_HTML_seg if para !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/ if para[/(.*)#{Mx[:id_o]}~0;(?:u|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/] #% watch u & m? one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + txt_obj={:txt =>$1.strip,:trailing =>$2.strip} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) end para.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint if para =~/ / #endnote- note- - format_seg=SiSU_HTML_Format::Format_seg.new(@md,para) + txt_obj={:txt =>para} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.no_paranum end end @@ -444,12 +454,12 @@ module SiSU_HTML_seg para.gsub!(/ <\/a>/,' ') case para # series changed 2002w42 when /^#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #remove [u]? req by pg texts, revist - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + txt_obj={:txt =>$1.strip,:ocn =>$2} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.subtoc_lev5 when /^#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + txt_obj={:txt =>$1.strip,:ocn =>$2} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.subtoc_lev6 end @@seg_subtoc_array << para @@ -474,7 +484,8 @@ module SiSU_HTML_seg e_n=note_match_seg[/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,1] try=e_n.split(/
    /) try.each do |e| - format_seg=SiSU_HTML_Format::Format_seg.new(@md,e) + txt_obj={:txt =>e} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ format_seg.endnote_body_indent else format_seg.endnote_body @@ -484,9 +495,11 @@ module SiSU_HTML_seg try.join('
    ') #% creation of separate end segment/page of all endnotes referenced back to reference segment m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(#-[\d*+]+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi - one=note_match_seg[m,1] #note~ [a name] - two=note_match_seg[m,2] #note- - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + endnote_part_a=note_match_seg[m,1] + endnote_part_b=note_match_seg[m,2] + txt_obj={:endnote_part_a =>endnote_part_a,:endnote_part_b =>endnote_part_b} + + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index fb6f6b2e..77d6e408 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -66,7 +66,7 @@ module SiSU_manpage include SiSU_Param include SiSU_Viz require "#{SiSU_lib}/manpage_format" - include Format + include SiSU_Manpage_format require "#{SiSU_lib}/shared_txt" require "#{SiSU_lib}/shared_structure" pwd=Dir.pwd @@ -343,9 +343,9 @@ WOK if para !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change paranum=para[@regx,3] - @p_num=Format::Paragraph_number.new(paranum) + @p_num=SiSU_Manpage_format::Paragraph_number.new(paranum) end - @sto=SiSU_Structure::Split_text_object.new(@md,para).txt + @sto=SiSU_Structure::Split_text_object.new(@md,para).manpage ### problem in scroll, it appears tables are getting paragraph numbers m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m \ @@ -387,10 +387,6 @@ WOK #@@manpage[:owner_details]=formatMono.bold_para #para='' elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum end if (para =~/
    / \ and para =~/^(-\{{2}~\d+|)/) # -endnote @@ -399,18 +395,14 @@ WOK case para when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ if para =~/.*<:#>.*$/m - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(txt_obj) para=format_text.scr_indent_one_no_paranum end end if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end para.gsub!(/\s(\[)/m,' \ \1') if para #manpages use this para.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})/,"\n\n") if para para.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') if para #manpages use this diff --git a/lib/sisu/v0/manpage_format.rb b/lib/sisu/v0/manpage_format.rb index 02fbf216..28756455 100644 --- a/lib/sisu/v0/manpage_format.rb +++ b/lib/sisu/v0/manpage_format.rb @@ -58,7 +58,7 @@ ** Description: manpage formatting template =end -module Format +module SiSU_Manpage_format require "#{SiSU_lib}/param" include SiSU_Param include SiSU_Viz @@ -78,19 +78,28 @@ module Format end class Format_text_object @@dp=nil - def initialize(one,two,three) - one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=one,two,three + def initialize(md,t_o) + @md,@t_o=md,t_o + if @t_o.class == Hash + @txt =@t_o[:txt] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + #@txt.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ rgx=/^#{Mx[:lv_o]}[1-6-]:/ - @one.gsub!(rgx,'') if @one =~rgx + @txt.gsub!(rgx,'') if @txt =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ - @one.gsub!(rgx,'\1') if @one =~rgx - @link,@linkname=one,two + @txt.gsub!(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#{@txt} " end def heading_body1 end diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 9fb6b51e..d21a8628 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -249,7 +249,7 @@ module SiSU_ODF txt.gsub!(/([)(\]\[])/,"\\\\\\1") txt.gsub!(/([+?*])/,"\\\\\\1") # problems with + url.gsub!(/([+?])/,"\\\\\\1") # problems with + - para.gsub!(/\{\s*#{txt}\}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url + para.gsub!(/#{Mx[:lnk_o]}\s*#{txt}#{Mx[:lnk_c]}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url para.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix end m=nil @@ -358,11 +358,29 @@ module SiSU_ODF end def table(para) # if para =~/#{Mx[:gr_o]}Th?.+/ # tables come as single block - table=SiSU_ODF_format::Table.new(@md,para) + txt_obj={:table =>para} + table=SiSU_ODF_format::Table.new(@md,txt_obj) para=table.table_split end end - def odf_structure(para='',lv='',ocn='',hname='') #% Used to extract the structure of a document + def odf_structure(md,t_o) + @md,@t_o=md,t_o + @md,@t_o=md,t_o + if t_o.class == Hash + para =t_o[:txt] || nil + lv =t_o[:lv] || nil + ocn =t_o[:ocn] || nil + hname =t_o[:h_name] || nil + #@h_name =t_o[:h_name] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #@one,@two,@three=one,two,three + p t_o.class + p caller + end lv=lv.to_i n=lv - 1 n3=lv + 2 @@ -515,31 +533,35 @@ module SiSU_ODF and para=~/\S+/ para=case @sto.format when /^(1):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(2):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(3):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(4):(\S+)/ # work on see Split_text_object - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) # work on see SiSU_text_parts::Split_text_object para when /^(5):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(6):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para - else odf_structure(para,nil,nil,nil) #watch may be problematic + else + txt_obj={:txt =>para} + odf_structure(@md,txt_obj) #watch may be problematic para end - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=SiSU_ODF_format::Format_text_object.new(one,two) - para=format_text.seg_no_paranum end if para =~// \ and para =~/^(-\{{2}~\d+|)/ # -endnote @@ -548,17 +570,14 @@ module SiSU_ODF if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/) # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=SiSU_ODF_format::Format_text_object.new(one,two) - para=format_text.center - end else if para =~ /^(4)~(\S+)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para elsif para =~/#{Mx[:id_o]}~(\d+);m\d+;[mdv]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - odf_structure(para,nil,nil,nil) #watch may be problematic + txt_obj={:txt =>para} + odf_structure(@md,txt_obj) #watch may be problematic para end end diff --git a/lib/sisu/v0/odf_format.rb b/lib/sisu/v0/odf_format.rb index 05e4a918..fe94bf5b 100644 --- a/lib/sisu/v0/odf_format.rb +++ b/lib/sisu/v0/odf_format.rb @@ -78,19 +78,28 @@ module SiSU_ODF_format end class Format_text_object @@dp=nil - def initialize(one,two,three) - one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=one,two,three + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #@one,@two,@three=one,two,three + p t_o.class + p caller + end rgx=/^#{Mx[:lv_o]}[1-6-]:/ - @one.gsub!(rgx,'') if @one =~rgx + @txt.gsub!(rgx,'') if @txt =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ - @one.gsub!(rgx,'\1') if @one =~rgx - @link,@linkname=one,two + @txt.gsub!(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#@txt " end def heading_body1 #%{#@two} @@ -116,8 +125,21 @@ module SiSU_ODF_format @@tablefoot=[] #watch @@fns='' @@dp=nil - def initialize(md,one) - @md,@one,@parablock,@vz=md,one,one,SiSU_Env::Get_init.instance.skin + def initialize(md,t_o) + @md,@t_o,@vz=md,t_o,SiSU_Env::Get_init.instance.skin + if t_o.class == Hash + @txt =t_o[:txt] || nil + @table =t_o[:table] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + if @md.cmd =~/M/ + p t_o.class + p caller + end + end if @md.fns != @@fns @@table_counter=0 @@fns=@md.fns @@ -177,58 +199,60 @@ module SiSU_ODF_format %{#@br} end def table - @parablock='' if @parablock =~/^/,1] + @txt='' if @txt =~/^/,1] @@tablefoot << m if m - @parablock.gsub!(//,'') - @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u - @@table_counter+=1 if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u - if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1,true) - elsif @parablock =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1) + @txt.gsub!(//,'') + @@tablehead=1 if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u + @@table_counter+=1 if @txt =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1,true) + elsif @txt =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1) end - if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ tablefoot=[] @@tablefoot.each {|x| tablefoot << ''} @@tablefoot=[] - if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock=table_end + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @txt=table_end end end if @@tablehead == 1 - if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) + if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) end - if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) + if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) end - if @parablock =~/#{Mx[:tc_c]}/ - @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) + if @txt =~/#{Mx[:tc_c]}/ + @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) end @@tablehead=0 end - @parablock + @txt else - if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) end - if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) + if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) end - if @parablock =~/#{Mx[:tc_c]}/ - @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close) + if @txt =~/#{Mx[:tc_c]}/ + @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close) end - @parablock + @txt end - @parablock + @txt end def table_split @new_content=[] - @one.split(/\s*#{Mx[:tc_o]}/).each do |parablock| + @table.split(/\s*#{Mx[:tc_o]}/).each do |parablock| table=if parablock =~/#{Mx[:gr_o]}/ - Table.new(@md,"#{parablock}") + txt_obj={:txt =>parablock} + Table.new(@md,txt_obj) else - Table.new(@md,"#{Mx[:tc_o]}#{parablock}") + txt_obj={:txt =>"#{Mx[:tc_o]}#{parablock}"} + Table.new(@md,txt_obj) end @new_content << table.table end diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 9a246e49..132f2997 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -388,7 +388,8 @@ WOK case para when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ if para =~/.*<:#>.*$/m - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) para=format_text.scr_indent_one_no_paranum end end diff --git a/lib/sisu/v0/plaintext_format.rb b/lib/sisu/v0/plaintext_format.rb index e957d3a3..ddac2e32 100644 --- a/lib/sisu/v0/plaintext_format.rb +++ b/lib/sisu/v0/plaintext_format.rb @@ -78,19 +78,30 @@ module Format end class Format_text_object @@dp=nil - def initialize(one,two,three) - one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=one,two,three + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @lnk_url =t_o[:lnk_url] || nil + @lnk_txt =t_o[:lnk_txt] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #@one,@two,@three=one,two,three + p t_o.class + p caller + end rgx=/^#{Rx[:lv]}/ - @one.gsub!(rgx,'') if @one =~rgx + @txt.gsub!(rgx,'') if @txt =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ - @one.gsub!(rgx,'\1') if @one =~rgx - @link,@linkname=one,two + @txt.gsub!(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#{@txt} " end def heading_body1 end @@ -109,4 +120,3 @@ module Format end end __END__ - diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 7be46abb..7a23be0b 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -65,20 +65,34 @@ module SiSU_Format_Shared class CSS_Format require "#{SiSU_lib}/defaults" @@fns=nil - def initialize(md,content=nil,col=nil,en=nil) - content.gsub!(/<:i[12]>/,'') - @md,@content=md,content - @id=@ocn=col[:id] - @ocnd,@ocns=col[:ocnd],col[:ocns] - @notenumber=en - @lv=col[:lev].to_s + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] #|| nil #s/@content/@txt/ + @col =t_o[:col] #|| nil + @notenumber =t_o[:endnote_nr] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #content.gsub!(/<:i[1-9]>/,'') + #@md,@content=md,content + p t_o.class + p caller + end + + @txt.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/,'') + @id=@ocn=@col[:id] + @ocnd,@ocns=@col[:ocnd],@col[:ocns] + @lv=@col[:lev].to_s @@hname=if @md.fns != @@fns @@fns=@md.fns '' end - @hname=if col[:seg] \ - and not col[:seg].to_s.empty? - @@hname=col[:seg].to_s + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? + @@hname=@col[:seg].to_s else @@hname end @tab="\t" @@ -87,7 +101,7 @@ module SiSU_Format_Shared @@tablehead,@@tablefoot=[],[] @vz=SiSU_Env::Get_init.instance.skin @env=SiSU_Env::Info_env.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" + @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" end def urls(data) @words=[] @@ -147,48 +161,48 @@ module SiSU_Format_Shared para end def paragraph - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def endnote #used only by db - @content=markup(@content) + @txt=markup(@txt) < -#{@tab*2}
    #@notenumber. #@content +#{@tab*1}

    +#{@tab*2}#{@notenumber}. #{@txt} #{@tab*1}

    GSUB end def lev_toc_hname - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def lev_toc - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def lev4_plus - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def lev4_minus - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def norm_comment - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} end def norm - @content=markup(@content) - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} + @txt=markup(@txt) + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} end def indent(t) - @content=markup(@content) - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} + @txt=markup(@txt) + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} end def para_table %{

    } end def ocn - %{#{@tab*1}} << "\n" + %{#{@tab*1}} << "\n" end def html_table # get rid of use html_table @new_content=[] - @content.split(/\n/).each do |parablock| + @txt.split(/\n/).each do |parablock| m=parablock[//,1] @@tablefoot</,'') @@ -233,27 +247,27 @@ GSUB @new_content.join end end - class CSS_Format_generic #does CSS_Format in one definition, needs to be told about class, despite brevity of generic, easier to see structure with CSS_Format - def initialize(css_class='',content='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) + 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" - @class=css_class - @content=content + @attrib=attrib + @txt=txt @lv=@notenumber=lv.to_s - #@ocn=ocn.to_s + #{@ocn}=ocn.to_s @hname=hname.to_s @id=@ocn=id end def paragraph - css_class=%{class="#@class" } + attrib=%{class="#{@attrib}" } if @ocn - id=%{id="#@ocn" } + id=%{id="#{@ocn}" } type=%{type="substantive" } else id=%{id="none" } type=%{type="comment" } end - header=%{header="#@hname" } if @hname - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + header=%{header="#{@hname}" } if @hname + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def para paragraph @@ -261,4 +275,3 @@ GSUB end end __END__ - diff --git a/lib/sisu/v0/shared_structure.rb b/lib/sisu/v0/shared_structure.rb index cdfe9bf3..47b8ff0d 100644 --- a/lib/sisu/v0/shared_structure.rb +++ b/lib/sisu/v0/shared_structure.rb @@ -70,6 +70,7 @@ module SiSU_Structure @format,@ocn='ordinary','ordinary' #@format,@ocn=nil,nil @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @id_block="#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" end def lev_segname_para_ocn if @para =~/^#{Mx[:lv_o]}\d:.+?#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -94,7 +95,7 @@ module SiSU_Structure if @para !~/#{Mx[:id_o]}~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$|^$/ #added 2002w06 @text=@para[/(.+?)/m,1] end - if @para[/^#{Mx[:lv_o]}(\d):\S*?#{Mx[:lv_c]}\s+(.+)/m] + if @para[/^#{Mx[:lv_o]}(\d):\S*?#{Mx[:lv_c]}\s*(.+)/m] @format,@text=$1,$2 end end @@ -104,14 +105,16 @@ module SiSU_Structure def html_seg lev_segname_para_ocn @seg_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] - SiSU_HTML_Format::Format_seg.new(@md,@format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_HTML_Format::Format_seg.new(@md,txt_obj) end self end def html_scroll lev_segname_para_ocn @scroll_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] - SiSU_HTML_Format::Format_scroll.new(@md,@format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_HTML_Format::Format_scroll.new(@md,txt_obj) end self end @@ -119,18 +122,24 @@ module SiSU_Structure require "#{SiSU_lib}/shared_xml" lev_segname_para_ocn @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - SiSU_XML_format::Format_scroll.new(@md,@format,@text,"x#@ocn") + txt_obj={:txt =>@text,:format =>@format,:ocn =>"x#@ocn"} + SiSU_XML_format::Format_scroll.new(@md,txt_obj) else - SiSU_XML_format::Format_scroll.new(@md,@format,@text,"#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") + id_block="#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_XML_format::Format_scroll.new(@md,txt_obj) end self end def odt lev_segname_para_ocn @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - SiSU_ODF_format::Format_text_object.new(format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_ODF_format::Format_text_object.new(@md,txt_obj) else - SiSU_ODF_format::Format_text_object.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") + id_block="#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_ODF_format::Format_text_object.new(@md,txt_obj) end self @@ -139,9 +148,25 @@ module SiSU_Structure lev_segname_para_ocn #format=@format.dup @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - Format::Format_text_object.new(@format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_Plaintext_format::Format_text_object.new(@md,txt_obj) else - Format::Format_text_object.new(@format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") + id_block="#{Mx[:id_o]}~\d+;[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_Plaintext_format::Format_text_object.new(@md,txt_obj) + end + self + end + def manpage #check + lev_segname_para_ocn + #format=@format.dup + @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_Manpage_format::Format_text_object.new(@md,txt_obj) + else + id_block="#{Mx[:id_o]}~\d+;[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_Manpage_format::Format_text_object.new(@md,txt_obj) end self end diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb index 41d6d815..198b8ce8 100644 --- a/lib/sisu/v0/shared_txt.rb +++ b/lib/sisu/v0/shared_txt.rb @@ -222,50 +222,4 @@ module SiSU_text_utils end end end -module SiSU_text_parts_flatfile - class Split_text_object - @@dl=nil - attr_reader :format,:text,:ocn,:lev_para_ocn - def initialize(md,para) - @md,@para=md,para - @format,@ocn='ordinary','ordinary' - @@dl ||=SiSU_Env::Info_env.new.digest.length - end - def lev_segname_para_ocn - if @para =~/^(?:#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}|<:.+?>).+?#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}.*/ - if /^(#{Mx[:lv_o]}([1-6]):(\S+?)#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @format,segname,@text,@ocn=$1,$2,$3,$4 - @format="#@format~#{segname}" # - elsif /^(#{Mx[:lv_o]}([1-6]):#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @format,@text,@ocn=$1,$2,$3 - elsif /<:(.+?)>\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @format,@text,@ocn=$1,$2,$3 - elsif /^(#{Mx[:lv_o]}([1-6]):(\S+?)#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(0);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @@alt_id_count+=1 - @format,segname,@text,@ocn=$1,$2,$3,"x#{@@alt_id_count}" - @format="#@format~#{segname}" # - elsif /^(#{Mx[:lv_o]}([1-6]):#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(0);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @@alt_id_count+=1 - @format,@text,@ocn=$1,$2,"x#{@@alt_id_count}" - end - else - if /(.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @text,@ocn=$1,$2 - end - if @para !~/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}|^$/ #added 2002w06 - @text=/(.+?)/m.match(@para)[1] - end - if /^(#{Mx[:lv_o]}([1-9]):\S*?#{Mx[:lv_c]})\s*(.+)/m.match(@para) - @format,@text=$1,$2 - end - end - @lev_para_ocn=if @para =~/.+<~\d+>/ #hmmm, watch - Format::ParaSiSU.new(@md,@format,@text,@ocn) - else Format::ParaSiSU.new(@md,@format,@text,'<~0>') - end - self - end - end -end __END__ - diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index adcba123..3edf67e4 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -65,7 +65,7 @@ module SiSU_TexInfo include SiSU_Viz #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags) require "#{SiSU_lib}/texinfo_format" - include TexInfoFormat + include SiSU_Texinfo_format @tex_file=[] @@tex_backslash="\\\\" @@tabular="{tabular}" @@ -82,7 +82,6 @@ module SiSU_TexInfo @opt=opt @env=SiSU_Env::Info_env.new(@opt.fns) @st={ 'tex'=>{} } - @tex=TexInfoFormat::Texinfo.new @vz=SiSU_Env::Get_init.instance.skin end def directories @@ -129,7 +128,7 @@ module SiSU_TexInfo end class Texinfo_make include SiSU_Param - include TexInfoFormat + include SiSU_Texinfo_format @@tex_1='(?:.+?)+~' #?? debug @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" @@ -138,7 +137,7 @@ module SiSU_TexInfo @data,@md=data,md #fns @env=SiSU_Env::Info_env.new(@md.fns) @st={ 'tex'=>{} } - #@tex=TexInfoFormat::Texinfo.new + #@tex=SiSU_Texinfo_format::Texinfo.new @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern end @@ -165,7 +164,8 @@ module SiSU_TexInfo end para.gsub!(/<:p[bn]>/,'') para.gsub!(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') - do_mono=TexInfoFormat::Texinfo.new(para,@md) + txt_obj={:txt =>para} + do_mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) @tex_file << do_mono.spec_char end data=@tex_file.delete_if {|x| x =~ /^0(?:\\)+~/m} @@ -244,7 +244,8 @@ module SiSU_TexInfo @@tableheader=0 data.each do |para| if para =~ /#{Mx[:tc_p]}|#{Mx[:gr_o]}T/ui - do_mono=TexInfoFormat::Texinfo.new(para,@md) + txt_obj={:txt =>para} + do_mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) para=do_mono.longtable # using longtable latex package end @tex_file << para @@ -256,8 +257,10 @@ module SiSU_TexInfo @row_break='\\\\\\' @break_page="#@row_break\n#@row_break \n" md={} - @tex_file << TexInfoFormat::Texinfo.new('',@md).head - mono=TexInfoFormat::Texinfo.new(@md.title,@md) + txt_obj={:txt =>''} + @tex_file << SiSU_Texinfo_format::Texinfo.new(@md,txt_obj).head + txt_obj={:txt =>@md.title} + mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) @tex_file << mono.topnode texinfo_menu=[] n_menu,n_submenu=0,0 @@ -265,10 +268,12 @@ module SiSU_TexInfo data.each do |para| para.gsub!(/\s*<:name#example>\s*/,' ') if para =~ /^#{Mx[:lv_o]}[1-3]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ - toc=TexInfoFormat::Texinfo.new($1,@md) + txt_obj={:txt =>$1} + toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) texinfo_menu << toc.menu elsif para =~ /^#{Mx[:lv_o]}[4-6]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ - toc=TexInfoFormat::Texinfo.new($1,@md) + txt_obj={:txt =>$1} + toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) texinfo_menu << toc.menu case para when /^#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.+?)\s*$/ @@ -297,7 +302,8 @@ module SiSU_TexInfo n_menu,n_submenu=0,0 @@do_submenu,@@do_subsubmenu=1,1 data.each do |para| - mono=TexInfoFormat::Texinfo.new(para,@md) + txt_obj={:txt =>para} + mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) case para when /^#{Mx[:lv_o]}1:/; mono.level1 when /^#{Mx[:lv_o]}2:/; mono.level2 @@ -310,14 +316,16 @@ module SiSU_TexInfo n_submenu+=1 @@do_subsubmenu=1 if @@do_submenu==1 - menu=TexInfoFormat::Texinfo.new(@submenu[n_menu],@md) + txt_obj={:txt =>@submenu[n_menu]} + menu=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) para="#{menu.submenu}#{mono.level5}" @@do_submenu=0 else mono.level5 end when /^#{Mx[:lv_o]}6:/; if @@do_submenu==1 - menu=TexInfoFormat::Texinfo.new(@subsubmenu[n_menu],@md) + txt_obj={:txt =>@submenu[n_menu]} + menu=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) para="#{menu.subsubmenu}#{mono.level6}" @@do_subsubmenu=0 else @@ -391,7 +399,7 @@ module SiSU_TexInfo if para =~/#{Mx[:id_o]}\\~(\d+);\w\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/ \ and para !~ /#{Mx[:br_eof]}/ parablock,paranum=/(.+?)#{Mx[:id_o]}\\~(\d+);\w\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/im.match(para)[1,2] - do_duo=TexInfoFormat::DuoTex.new(parablock,paranum) ###is BUG + do_duo=SiSU_Texinfo_format::DuoTex.new(parablock,paranum) ###is BUG para=do_duo.paraNum if parablock end @tex_file << para @@ -400,7 +408,8 @@ module SiSU_TexInfo end def tail data=@data - tex=TexInfoFormat::Texinfo.new('',@md) + txt_obj={:txt =>''} + tex=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) data << tex.dublincore data << tex.tail end @@ -428,4 +437,3 @@ module SiSU_TexInfo end end __END__ - diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index b627b616..cdfa6a75 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -58,7 +58,7 @@ ** Description: texinfo formatting template =end -module TexInfoFormat +module SiSU_Texinfo_format @@table_pg_break_counter=1 require "#{SiSU_lib}/param" include SiSU_Param @@ -69,9 +69,19 @@ module TexInfoFormat @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" @@dp=nil - def initialize(data=nil,md=nil,three=nil) - @para=@one=data - @md=md + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + #@h_name =t_o[:h_name] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern end @@ -79,12 +89,12 @@ module TexInfoFormat t=Time.now year=t.year filename=%{#{@md.fns}}[/(.+?)\.\w\w\d\d$/,1] - title=Texinfo.new(@md.title).spec_char + title=spec_char_string(@md.title) title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") title.gsub!(/\$/,"\\$") title.gsub!(/[,]\s*/,' - ') if @md.subtitle - subtitle=Texinfo.new(@md.subtitle).spec_char + subtitle=spec_char_string(@md.subtitle) subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") subtitle.gsub!(/\$/,"\\$") subtitle.gsub!(/[,]\s*/,' - ') @@ -150,42 +160,42 @@ WOK "#{head}#{titlepage}" end def topnode - @one=Texinfo.new(@one).spec_char - @one=@one.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") - @one.gsub!(/\$/,"\\$") - @one.gsub!(/[,]\s*/,' - ') + txt=spec_char_string(@txt) + txt=txt.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") + txt.gsub!(/\$/,"\\$") + txt.gsub!(/[,]\s*/,' - ') "@c %% 4\n" + "@ifnottex\n" + "@node Top\n" + - "@top #@one\n\n" + + "@top #{txt}\n\n" + "@insertcopying\n" + "@end ifnottex\n\n" + "@menu\n" end def dublincore - title=Texinfo.new(@md.title).spec_char if @md.title - subtitle=Texinfo.new(@md.subtitle).spec_char if @md.subtitle + title=spec_char_string(@md.title) if @md.title + subtitle=spec_char_string(@md.subtitle) if @md.subtitle dc_title="#{title} - #{subtitle}" - dc_creator=Texinfo.new(@md.dc_creator).spec_char if @md.dc_creator - dc_subject=Texinfo.new(@md.dc_subject).spec_char if @md.dc_subject - dc_description=Texinfo.new(@md.dc_description).spec_char if @md.dc_description - dc_publisher=Texinfo.new(@md.dc_publisher).spec_char if @md.dc_publisher - dc_contributor=Texinfo.new(@md.dc_contributor).spec_char if @md.dc_contributor - dc_date=Texinfo.new(@md.dc_date).spec_char if @md.dc_date - dc_date_created=Texinfo.new(@md.dc_date_created).spec_char if @md.dc_date_created - dc_date_issued=Texinfo.new(@md.dc_date_issued).spec_char if @md.dc_date_issued - dc_date_available=Texinfo.new(@md.dc_date_available).spec_char if @md.dc_date_available - dc_date_valid=Texinfo.new(@md.dc_date_valid).spec_char if @md.dc_date_valid - dc_date_modified=Texinfo.new(@md.dc_date_modified).spec_char if @md.dc_date_modified - dc_type=Texinfo.new(@md.dc_type).spec_char if @md.dc_type - dc_format=Texinfo.new(@md.dc_format).spec_char if @md.dc_format - dc_identifier=Texinfo.new(@md.dc_identifier).spec_char if @md.dc_identifier - dc_source=Texinfo.new(@md.dc_source).spec_char if @md.dc_source - dc_language=Texinfo.new(@md.dc_language[:name]).spec_char if @md.dc_language[:name] - #language_original=Texinfo.new(@md.language_original[:name]).spec_char if @md.language_original[:name] - dc_relation=Texinfo.new(@md.dc_relation).spec_char if @md.dc_relation - dc_coverage=Texinfo.new(@md.dc_coverage).spec_char if @md.dc_coverage - dc_rights=Texinfo.new(@md.dc_rights).spec_char if @md.dc_rights + dc_creator=spec_char_string(@md.dc_creator) if @md.dc_creator + dc_subject=spec_char_string(@md.dc_subject) if @md.dc_subject + dc_description=spec_char_string(@md.dc_description) if @md.dc_description + dc_publisher=spec_char_string(@md.dc_publisher) if @md.dc_publisher + dc_contributor=spec_char_string(@md.dc_contributor) if @md.dc_contributor + dc_date=spec_char_string(@md.dc_date) if @md.dc_date + dc_date_created=spec_char_string(@md.dc_date_created) if @md.dc_date_created + dc_date_issued=spec_char_string(@md.dc_date_issued) if @md.dc_date_issued + dc_date_available=spec_char_string(@md.dc_date_available) if @md.dc_date_available + dc_date_valid=spec_char_string(@md.dc_date_valid) if @md.dc_date_valid + dc_date_modified=spec_char_string(@md.dc_date_modified) if @md.dc_date_modified + dc_type=spec_char_string(@md.dc_type) if @md.dc_type + dc_format=spec_char_string(@md.dc_format) if @md.dc_format + dc_identifier=spec_char_string(@md.dc_identifier) if @md.dc_identifier + dc_source=spec_char_string(@md.dc_source) if @md.dc_source + dc_language=spec_char_string(@md.dc_language[:name]) if @md.dc_language[:name] + #language_original=spec_char_string(@md.language_original[:name]) if @md.language_original[:name] + dc_relation=spec_char_string(@md.dc_relation) if @md.dc_relation + dc_coverage=spec_char_string(@md.dc_coverage) if @md.dc_coverage + dc_rights=spec_char_string(@md.dc_rights) if @md.dc_rights dc_title="Title: #{dc_title}\n\n" if dc_title dc_creator="Creator: #{dc_creator}\n\n" if dc_creator dc_subject="Subject: #{dc_subject}\n\n" if dc_subject @@ -244,140 +254,144 @@ WOK para end def menu - para=clean(@para) + para=clean(@txt) para=para.gsub(/@footnote\{.+?\}\s+/,'') "* #{para}::" end def level1 - @para.gsub!(/#{Mx[:lv_o]}1:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}1:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level2 - @para.gsub!(/#{Mx[:lv_o]}2:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}2:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level3 - @para.gsub!(/#{Mx[:lv_o]}3:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}3:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,"\\1 \\3\n\\2") #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,'\1 \3 \2') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level4 - @para.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level5 - @para.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level6 - @para.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def submenu - @para=@para.join("\n") - @para.gsub!(/[5]\\+~\S+/,'') - para=clean(@para) + @txt=@txt.join("\n") + @txt.gsub!(/[5]\\+~\S+/,'') + para=clean(@txt) para="@menu\n#{para}\n@end menu\n\n" - @para.gsub!(/.+/m,"#{para}") + @txt.gsub!(/.+/m,"#{para}") end def subsubmenu - @para=@para.join("\n") - @para.gsub!(/[6]\\+~\S+/,'') - para=clean(@para) + @txt=@txt.join("\n") + @txt.gsub!(/[6]\\+~\S+/,'') + para=clean(@txt) para="@menu\n#{para}\n@end menu\n\n" - @para.gsub!(/.+/m,"#{para}") + @txt.gsub!(/.+/m,"#{para}") end def indent1 - @para.gsub!(/<:i1>(.*)/,'\1') + @txt.gsub!(/<:i1>(.*)/,'\1') end def indent2 - @para.gsub!(/<:i2>(.*)/,'\1') + @txt.gsub!(/<:i2>(.*)/,'\1') + end + def spec_char_string(txt) # special characters + txt_obj={:txt =>txt} + SiSU_Texinfo_format::Texinfo.new(@md,txt_obj).spec_char end def spec_char # special characters - @para.gsub!(/#{Mx[:br_eof]}/i,'') - @para.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') - @para.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); @para.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') - @para.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); @para.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - @para.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - @para.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - @para.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - @para.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - @para.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - @para.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - @para.gsub!(/&atild;<\/font><\/sup>/,' ') - @para.gsub!(/\\/,'\\backslash ') - @para.gsub!(/<:pb>/,'\\newpage') - @para.gsub!(/\\backslash copyright/,'\\copyright ') - @para.gsub!(/\^/,'\\wedge ') - @para.gsub!(/(\$)/,"\\$") - @para.gsub!(/\~/,'\\~') - @para.gsub!(/%/,"\\%") - #if @para !~ /^\s*<:image|\}:image\s/ - # @para.gsub!(/_/,'\_') + @txt.gsub!(/#{Mx[:br_eof]}/i,'') + @txt.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') + @txt.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); @txt.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') + @txt.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); @txt.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') + @txt.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + @txt.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') + @txt.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') + @txt.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') + @txt.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') + @txt.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') + @txt.gsub!(/&atild;<\/font><\/sup>/,' ') + @txt.gsub!(/\\/,'\\backslash ') + @txt.gsub!(/<:pb>/,'\\newpage') + @txt.gsub!(/\\backslash copyright/,'\\copyright ') + @txt.gsub!(/\^/,'\\wedge ') + @txt.gsub!(/(\$)/,"\\$") + @txt.gsub!(/\~/,'\\~') + @txt.gsub!(/%/,"\\%") + #if @txt !~ /^\s*<:image|\}:image\s/ + # @txt.gsub!(/_/,'\_') #end - @para.gsub!(/_(https?:\/\/)/,'\1') - @para.gsub!(/§/i,'\S') - @para.gsub!(/£/i,'\pounds') - @para.gsub!(/å/i,'\aa') - @para.gsub!(/æ/i,'\ae') - @para.gsub!(/ø/i,'\o') - @para.gsub!(/Å/i,'\AA') - @para.gsub!(/Æ/i,'\AE') - @para.gsub!(/Ø/i,'\O') - @para.gsub!(//i,' ') - @para.gsub!(/<\/a>/i,' ') - @para.gsub!(/<:ee>/i,'') - @para.gsub!(//i,' ') - @para.gsub!(/(.+?)<\/b>/,'\*\1\*') - @para.gsub!(/(.+?)<\/i>/,'\/\1\/') - @para.gsub!(/(.+?)<\/u>/,'\_\1\_') - @para.gsub!(/@/i,'@@') - @para.gsub!(/\{/,'@{'); @para.gsub!(/\}/,'@}') - #@para.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @para.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') - @para.gsub!(/  /,' ') # ~ character for hardspace - @para.gsub!(/ /,' ') # ~ character for hardspace - @para.gsub!(/&(\S+?);/,' ') - @para.gsub!(/&/,'<=and>') - @para.gsub!(/(\s+&\s+)/,' and ') - @para.gsub!(/(\&)/,"\\&") - @para.gsub!(/"(.+?)"/,"`\\1'") # open & close " - @para.gsub!(/\s+"/," `") # open " - @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " - @para.gsub!(/"(\s|\.|,|:|;)/,"'\\1") # close " - @para.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1") # close " - @para.gsub!(/"(\.|,)/,"'") # close " - @para.gsub!(/\s+'/," `") # open ' - @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' - @para.gsub!(/(|<\/font>)/,'') - @para.gsub!(/\s*(\S+?)<\/sup>/,'^\1') - @para.gsub!(/(|<\/sup>)/,'') - @para + @txt.gsub!(/_(https?:\/\/)/,'\1') + @txt.gsub!(/§/i,'\S') + @txt.gsub!(/£/i,'\pounds') + @txt.gsub!(/å/i,'\aa') + @txt.gsub!(/æ/i,'\ae') + @txt.gsub!(/ø/i,'\o') + @txt.gsub!(/Å/i,'\AA') + @txt.gsub!(/Æ/i,'\AE') + @txt.gsub!(/Ø/i,'\O') + @txt.gsub!(//i,' ') + @txt.gsub!(/<\/a>/i,' ') + @txt.gsub!(/<:ee>/i,'') + @txt.gsub!(//i,' ') + @txt.gsub!(/(.+?)<\/b>/,'\*\1\*') + @txt.gsub!(/(.+?)<\/i>/,'\/\1\/') + @txt.gsub!(/(.+?)<\/u>/,'\_\1\_') + @txt.gsub!(/@/i,'@@') + @txt.gsub!(/\{/,'@{'); @txt.gsub!(/\}/,'@}') + #@txt.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @txt.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') + @txt.gsub!(/  /,' ') # ~ character for hardspace + @txt.gsub!(/ /,' ') # ~ character for hardspace + @txt.gsub!(/&(\S+?);/,' ') + @txt.gsub!(/&/,'<=and>') + @txt.gsub!(/(\s+&\s+)/,' and ') + @txt.gsub!(/(\&)/,"\\&") + @txt.gsub!(/"(.+?)"/,"`\\1'") # open & close " + @txt.gsub!(/\s+"/," `") # open " + @txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " + @txt.gsub!(/"(\s|\.|,|:|;)/,"'\\1") # close " + @txt.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1") # close " + @txt.gsub!(/"(\.|,)/,"'") # close " + @txt.gsub!(/\s+'/," `") # open ' + @txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' + @txt.gsub!(/(|<\/font>)/,'') + @txt.gsub!(/\s*(\S+?)<\/sup>/,'^\1') + @txt.gsub!(/(|<\/sup>)/,'') + @txt end def longtable @end_table="\\end{longtable}" @row_break='\\\\\\' - if @para[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] #CHECK !> closure + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] #CHECK !> closure no_of_cols,cols_width=$1,$2 - @@tableheader=1 if @para =~ /#{Mx[:gr_o]}Th/i + @@tableheader=1 if @txt =~ /#{Mx[:gr_o]}Th/i @w=cols_width.split(/;\s+/) @@number_of_cols=no_of_cols @colW=[] @@ -390,31 +404,31 @@ WOK @colW=@colW.join @@start_table="\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{longtable}[hb]#@colW\n" - @para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") end - if @para =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @para.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table") end - @para.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader==1 - if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u tablefoot=para[/\/,1] - @para.gsub!(/\/,'') - @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, + @txt.gsub!(/\/,'') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&") - @para.gsub!(/&>\s*$/, + @txt.gsub!(/&>\s*$/, " #@row_break \\hline\\endhead #@row_break") - @para="#@para \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot + @txt="#{@txt} \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader=0 @@number_of_cols=0 end else - if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @para.gsub!(/&>\s*$/," #@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") + @txt.gsub!(/&>\s*$/," #@row_break") end end - @para + @txt end def scopedtable # some features related to headers have been incorporated in longtable @@ -423,7 +437,7 @@ WOK @end_table="\\end{tabular}" @row_break='\\\\\\\\' @break_page="#@row_break\n#@row_break \n" - if @para[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] no_of_cols,cols_width=$1,$2 @w=cols_width.split(/;\s+/) @colW=[] @@ -432,59 +446,59 @@ WOK @colW << "p{#{col_w}cm}" if col_w end @@start_table="\\begin{tabular}{#@colW}\n" - @para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") end - if @para =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @para.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") @@table_pg_break_counter=1 end - if @para =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u if @@table_pg_break_counter==28 # taken from 34 ideal for portrait to 28 which suits landscape - @para = + @txt = "\n\n#@end_table \n" + "#@break_page" + "#{@@start_table}\n" @@table_pg_break_counter=1 else - @para.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 - tablefoot=@para[/\/] - @para.gsub!(/\/,'') + tablefoot=@txt[/\/] + @txt.gsub!(/\/,'') end end - if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @para.gsub!(/&>\s*$/,"#@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") + @txt.gsub!(/&>\s*$/,"#@row_break") end - @para + @txt end def graphics dir=SiSU_Env::Info_env.new(@md.fns) - @para.gsub!(/<::\s+(\S+?)\s+>/i, #watch + @txt.gsub!(/<::\s+(\S+?)\s+>/i, #watch "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}") end def image dir=SiSU_Env::Info_env.new(@md.fns) width="100" - width=@para[/<:image.+?width=``(\d+)''.+?>/im,1] + width=@txt[/<:image.+?width=``(\d+)''.+?>/im,1] width=width.to_i*0.4 - @para.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, + @txt.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\2}}") - @para.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, + @txt.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\1}") end def png # very messy clean up ! - work area, testing - z=@para[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! + z=@txt[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! image,w,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') - @para.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"") # fragile match operator\\ fragile ! + @txt.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"") # fragile match operator\\ fragile ! end def http # very messy clean up ! - work area, testing - z=@para[/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! - url=@para[/((?:https?|file|ftp):\S+)/im,1] - if @para =~/\.(png|jpg|gif)/ + z=@txt[/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! + url=@txt[/((?:https?|file|ftp):\S+)/im,1] + if @txt =~/\.(png|jpg|gif)/ image,w,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') width=200 @@ -496,11 +510,11 @@ WOK end if image dir=SiSU_Env::Info_env.new(@md.fns) - @para.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! "\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}") else link=z[/(.+?)\\/im,1] - @para.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! end end end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index e4bd9c00..c5ee2092 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -382,8 +382,10 @@ module SiSU_TeX @md.papersize_array.each do |ps| @@tableheader={ ps => { :p => 0, :l => 0 }} para,para_p=@para.dup,@para.dup #visit - format_l=SiSU_TeX_Pdf::Format_text_object.new(md,para,ps) - format_p=SiSU_TeX_Pdf::Format_text_object.new(md,para_p,ps) + txt_obj={:txt =>para,:paper_size =>ps} + format_l=SiSU_TeX_Pdf::Format_text_object.new(md,txt_obj) + txt_obj={:txt =>para_p,:paper_size =>ps} + format_p=SiSU_TeX_Pdf::Format_text_object.new(md,txt_obj) @block[ps]={ :l => format_l.longtable_landscape, :p => format_p.longtable_portrait @@ -411,7 +413,8 @@ module SiSU_TeX end def markup_common(para) tex_f=nil - mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) + txt_obj={:txt =>para} + mono=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj) if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/ \ or @@flag_alt if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/ @@ -436,7 +439,8 @@ module SiSU_TeX elsif x =~/code/; @@flag_alt,@@flag_code=true,true elsif @@flag_alt if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/m - para=SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http + txt_obj={:txt =>para,:paper_size =>'a4'} + para=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http end @group_collect << para #<< "\n\n" end @@ -501,11 +505,13 @@ module SiSU_TeX end if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/ para=if para !~/\.(?:png|jpg|gif)/ - SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http + txt_obj={:txt =>para,:paper_size =>'a4'} + SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http else @block={} @md.papersize_array.each do |ps| - image=SiSU_TeX_Pdf::Format_text_object.new(@md,para,ps).http + txt_obj={:txt =>para,:paper_size =>ps} + image=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http @block[ps]={ :l => image, :p => image @@ -524,8 +530,10 @@ module SiSU_TeX title=@md.title.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex subtitle=@md.subtitle.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') if @md.subtitle #no line splitting in heading neither html nor latex @md.papersize_array.each do |ps| - orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,ps,'portrait',"#{home}: - #{title} #{subtitle}") - orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,ps,'landscape',"#{home}: - #{title} #{subtitle}") + txt_obj={:txt =>"#{home}: - #{title} #{subtitle}",:paper_size =>ps,:orientation =>'portrait'} + orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) + txt_obj={:txt =>"#{home}: - #{title} #{subtitle}",:paper_size =>ps,:orientation =>'landscape'} + orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation end @@ -544,8 +552,9 @@ WOK #end @copymark='' #check and remove as now is superflous x={} - x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_landscape - x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_portrait + txt_obj={:title =>@md.title,:subtitle =>@md.subtitle} + x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_landscape + x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_portrait @tex_file << x x=nil if @md.dc_creator @@ -680,7 +689,8 @@ WOK paranum=if ocn; para[m,2] else '' end - do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,parablock,paranum) + txt_obj={:txt =>parablock,:ocn =>paranum} + do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj) para=do_duo.para_num if parablock elsif para =~/^#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #2005 this is added for tables, rationalise m=/#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/m diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index f776dd5a..55a9473f 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -78,8 +78,24 @@ module SiSU_TeX_Pdf } @@sys=SiSU_Env::System_call.new @@dp=nil - def initialize(md,string,string1=nil) - @md,@string,@string1=md,string,string1 + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @title =t_o[:title] || nil + @subtitle =t_o[:subtitle] || nil + @ps =t_o[:paper_size] || nil + @ocn =t_o[:ocn] || nil + @words =t_o[:words] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + if defined? @md.image \ and @md.image =~/center/ @center_begin,@center_end='\begin{center}','\end{center}' @@ -90,12 +106,11 @@ module SiSU_TeX_Pdf @tx=SiSU_Env::Get_init.instance.tex @url_brace=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine - @ps=string1 if string1=~/(?:a4|letter|legal|book|a5|b5)/i end def longtable_landscape @end_table='\end{longtable}' @row_break='\\\\\\' - if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] no_of_cols,cols_width,ocn=$1,$2,$3 tw=case @ps when /a4/i; @tx.a4.landscape.w #European default, SiSU default @@ -106,7 +121,7 @@ module SiSU_TeX_Pdf else @tx.a4.landscape.w #default currently A4 end textwidth=(tw.to_i/2) - 24 - @@tableheader[@ps][:l]=1 if @string =~/#{Mx[:gr_o]}Th/ + @@tableheader[@ps][:l]=1 if @txt =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) @@number_of_cols=no_of_cols ||=@@number_of_cols #@@number_of_cols=0 unless @@number_of_cols.to_i > 0 @@ -122,36 +137,36 @@ module SiSU_TeX_Pdf @colW=@colW.join @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) end - if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end - @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader[@ps][:l] == 1 - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u - tablefoot=@string[/\/,1] - @string.gsub!(/\/,'') - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') - @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") - @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u + tablefoot=@txt[/\/,1] + @txt.gsub!(/\/,'') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') + @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") + @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader[@ps][:l]=0 #@@tableheader[@ps][:l],@@number_of_cols=0,0 end else - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') - @string.gsub!(/&\s*$/," #@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') + @txt.gsub!(/&\s*$/," #@row_break") end end - @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string - else @string + @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt + else @txt end end def longtable_portrait @end_table='\end{longtable}' @row_break='\\\\\\' - if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] no_of_cols,cols_width,ocn=$1,$2,$3 tw=case @ps when /a4/i; @tx.a4.portrait.w #European default, SiSU default @@ -162,7 +177,7 @@ module SiSU_TeX_Pdf else @tx.a4.portrait.w #default currently A4 end textwidth=tw.to_i - 20 - @@tableheader[@ps][:p]=1 if @string =~/#{Mx[:gr_o]}Th/ + @@tableheader[@ps][:p]=1 if @txt =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) @@number_of_cols=no_of_cols ||=@@number_of_cols @colW=[] @@ -178,30 +193,30 @@ module SiSU_TeX_Pdf @colW=@colW.join @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") end - if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end - @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader[@ps][:p] == 1 - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - tablefoot=@string[/\/,1] - @string.gsub!(/\/,'') - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') - @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") - @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + tablefoot=@txt[/\/,1] + @txt.gsub!(/\/,'') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') + @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") + @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader[@ps][:p]=0 #@@tableheader[@ps][:p],@@number_of_cols=0,0 end else - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') - @string.gsub!(/&\s*$/," #@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') + @txt.gsub!(/&\s*$/," #@row_break") end end - @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string - else @string + @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt + else @txt end end def scopedtable @@ -210,7 +225,7 @@ module SiSU_TeX_Pdf @end_table="\\end{tabular}" @row_break='\\\\\\\\' @break_page="#@row_break\n#@row_break \n" - if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] no_of_cols,cols_width=$1,$2 @w=cols_width.split(/;\s*/) @colW=[] @@ -219,28 +234,28 @@ module SiSU_TeX_Pdf @colW << "p{#{col_w}cm}" if col_w end @start_table="\\begin{tabular}{#@colW}\n" - @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") end - if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") @@table_pg_break_counter=1 end - if @string =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u if @@table_pg_break_counter == 28 # taken from 34 ideal for portrait to 28 which suits landscape - @string="\n\n#@end_table \n#@break_page#@start_table\n" + @txt="\n\n#@end_table \n#@break_page#@start_table\n" @@table_pg_break_counter=1 else - @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 - tablefoot=@string[/\/,1] - @string.gsub!(/\/,'') + tablefoot=@txt[/\/,1] + @txt.gsub!(/\/,'') end end - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") - @string.gsub!(/&\s*$/,"#@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") + @txt.gsub!(/&\s*$/,"#@row_break") end - @string + @txt end def heading_major(para,lev) #\emph{ title=@md.title @@ -264,90 +279,90 @@ module SiSU_TeX_Pdf para end def level1 - heading_major(@string,1) + heading_major(@txt,1) end def level2 - heading_major(@string,2) + heading_major(@txt,2) end def level3 - heading_major(@string,3) + heading_major(@txt,3) end def level4 - @string.strip! if @string - @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') - cont_ln=@string.dup + @txt.strip! if @txt + @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') + cont_ln=@txt.dup cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{@@tex_backslash*2}/,"#{@@tex_backslash*4}") # added w42 cont_ln.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 title=@md.title - @string.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') - if @string =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ + @txt.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') + if @txt =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ # watch exclusion removes endnotes marker from pdf 2003w03 - @string.gsub!(/.+/m,'') + @txt.gsub!(/.+/m,'') end - if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! + if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - if @string !~/#{Mx[:lv_o]}4:/ - @string.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} + if @txt !~/#{Mx[:lv_o]}4:/ + @txt.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") else - @string.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} + @txt.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") end - @string.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1') + @txt.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1') end def level5 - # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@string*, same for next section 2002w46 - @string.strip! if @string - @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') - cont_ln=@string.dup + # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 + @txt.strip! if @txt + @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') + cont_ln=@txt.dup cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa - @string.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') - if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! + @txt.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') + if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - if @string !~/#{Mx[:lv_o]}5:/ - @string.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} + if @txt !~/#{Mx[:lv_o]}5:/ + @txt.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") else - @string.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, + @txt.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") end - @string.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1') + @txt.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1') end def level6 - # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@string*, same for previous section 2002w46 - @string.strip! if @string - @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') - cont_ln=@string.dup + # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46 + @txt.strip! if @txt + @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') + cont_ln=@txt.dup cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - @string.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') - if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! + @txt.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') + if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - @string.gsub!(/(#{@md.lv6}.*)\n?$/m, - "\\subsubsection*{\\1}") if (@string !~/#{Mx[:lv_o]}6:/) - @string.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, + @txt.gsub!(/(#{@md.lv6}.*)\n?$/m, + "\\subsubsection*{\\1}") if (@txt !~/#{Mx[:lv_o]}6:/) + @txt.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, '\subsubsection*{\1}') - @string.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') + @txt.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') #end BUGWATCH end def indent(lev) @@ -362,25 +377,25 @@ para when /8/; '70mm' when /9/; '80mm' end - @string.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, + @txt.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, "\\begin{ParagraphIndent}{#{indent}}\\1 \\end{ParagraphIndent}}") end def symbol_graphic dir=SiSU_Env::Info_env.new(@md.fns) - image='c_' + /<:=\s*(\S+?)\s*>/m.match(@string).captures.join + '.png' #watch + image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch if FileTest.file?("#{dir.path.image_source_tex}/#{image}") - @string.gsub!(/<:=\s*(\S+?)\s*>/, + @txt.gsub!(/<:=\s*(\S+?)\s*>/, "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}") else tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_tex}") tell.error2 unless @md.cmd =~/q/ - @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! end end def image dir=SiSU_Env::Info_env.new(@md.fns) - image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@string).captures + image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@txt).captures width=m[1] || '100' width=width.to_i*0.4 image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ @@ -397,17 +412,17 @@ para nil end if image_source - @string.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/, + @txt.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/, @center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end ) - @string.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/, + @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/, @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) - else @string.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}') + else @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}') end end def png #fc missing image check dir=SiSU_Env::Info_env.new(@md.fns) # messy clean up - z=@string[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @string =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile ! + z=@txt[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @txt =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile ! if z #debug 2004w14 image=z[/(\S+?\.(?:png|jpg|gif)\b)/m] image.gsub!(/\\/,'') @@ -438,18 +453,18 @@ para nil end if image_source - @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile ! "#@center_begin\n\\includegraphics*[width=#{width}pt]{#{image_source}/#{image}}#{caption}#@center_end") - else @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'') + else @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'') end end def http_word_mode #(orientation='') # clean up ! - work area, testing dir=SiSU_Env::Info_env.new(@md.fns) - @words=[] + @w=[] @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ - @string.each do |word| - @words << if word=~@url_generic_rgx + @words.each do |word| + @w << if word=~@url_generic_rgx if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join @@ -521,20 +536,21 @@ para else word end end - @words=@words.join - @words + @txt=@w.join + @txt end def http - wm=@string.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) - @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm,@ps).http_word_mode #GET PAPER SIZE AND USE IT + wm=@txt.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) + txt_obj={:words =>wm,:paper_size =>@ps} + @txt=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http_word_mode #GET PAPER SIZE AND USE IT end def title - @string=SiSU_TeX_Pdf::Special_characters.new(@md,@string).special_characters_safe - if @string1 - @string1=SiSU_TeX_Pdf::Special_characters.new(@md,@string1).special_characters_safe - @string1.gsub!(/\$/,"\\$") - "\n\\title{#@string#{@@tex_backslash*2} \\textbf{\\normalsize #@string1}\\normalsize}" - else "\n\\title{#@string}" + @txt=SiSU_TeX_Pdf::Special_characters.new(@md,@title).special_characters_safe + if @subtitle + @subtitle=SiSU_TeX_Pdf::Special_characters.new(@md,@subtitle).special_characters_safe + @subtitle.gsub!(/\$/,"\\$") + "\n\\title{#@title#{@@tex_backslash*2} \\textbf{\\normalsize #@subtitle}\\normalsize}" + else "\n\\title{#@txt}" end end def title_landscape @@ -547,33 +563,49 @@ para paranumber_display=if @md.markup.inspect =~/no_ocn/ \ or @md.mod.inspect =~/--no-ocn/ '' - else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering + else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@ocn\\end{tiny}}}" #ocn object citation numbering end - if @string !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ - @string.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect + if @txt !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ + @txt.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect else - if (@string =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect - @string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect - #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect - #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect - @string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? - #@string.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? + if (@txt =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect + @txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect + #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect + #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect + @txt.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? + #@txt.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? else - @string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") - #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") - #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") + @txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") + #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") + #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") end end - @string + @txt end end class Format_head - def initialize(md,ps,layout=nil,string1=nil) - @md,@ps,@layout,@string1=md,ps,layout,string1 + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + #@title =t_o[:title] || nil + @subtitle =t_o[:subtitle] || nil + @ps =t_o[:paper_size] || nil + @ocn =t_o[:ocn] || nil + @layout=t_o[:orientation] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + @tx=SiSU_Env::Get_init.instance.tex @url_brace=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine - @ps=@string if @string=~/(?:a4|letter|legal|book|a5|b5)/i + @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i end def language @lang=if @md.dc_language[:code] @@ -786,7 +818,7 @@ WOK \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, #{color.strip} - pdftitle={#@string1}, + pdftitle={#{@txt}}, % pdftitle={Untitled}, pdfauthor={LM-sisu-scribe}, pdfsubject={law}, @@ -820,7 +852,7 @@ WOK \\definecolor{myblue}{rgb}{0,0,0.5} \\definecolor{mywhite}{rgb}{1,1,1} WOK - elsif @string =~/dvi/ + elsif @txt =~/dvi/ <') #unless @string=~/<:code>/ # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>') # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>') # \ SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX @@ -1095,7 +1127,7 @@ WOK end def xetex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list #p @@utf_8.list - #string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) + #string=Iconv.conv('ISO-8859-1', 'UTF-8', @txt) word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/ para_array=[] string=if word @@ -1138,7 +1170,7 @@ WOK string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX - string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/ # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>') # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>') # \ SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX @@ -1275,33 +1307,33 @@ WOK string end def special_characters #special characters - some substitutions are sequence sensitive, rearrange with care. - string=@string + string=@txt case @tex2pdf when /pdf/ string=pdftex_special_characters_1(string) unless string.nil? - string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@string) + string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@txt) string=pdftex_special_characters_2(string) unless string.nil? string=pdftex_special_characters_3(string) unless string.nil? when /xe/ string=xetex_special_characters_1(string) unless string.nil? - string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@string) + string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@txt) string=xetex_special_characters_2(string) unless string.nil? #issues with xetex string=xetex_special_characters_3(string) unless string.nil? end - @string=string + @txt=string end def special_characters_safe #special characters - some substitutions are sequence sensitive, rearrange with care. - string=@string + string=@txt case @tex2pdf when /pdf/ - string=pdftex_special_characters_1(@string) unless string.nil? - string=pdftex_special_characters_2(@string) unless string.nil? - #special_characters_3(@string) + string=pdftex_special_characters_1(@txt) unless string.nil? + string=pdftex_special_characters_2(@txt) unless string.nil? + #special_characters_3(@txt) when /xe/ - string=xetex_special_characters_1(@string) unless string.nil? - string=xetex_special_characters_2(@string) unless string.nil? # remove this to start with, causes issues + string=xetex_special_characters_1(@txt) unless string.nil? + string=xetex_special_characters_2(@txt) unless string.nil? # remove this to start with, causes issues end - @string=string + @txt=string end end class Use_TeX diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 593d26c4..95da5d2d 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -289,7 +289,8 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + txt_obj={:txt =>@sto.text} + format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_structure(para,$1,@sto.ocn,$2) @@ -342,26 +343,29 @@ WOK and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ elsif para =~/(MetaData)/ \ and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'
    MetaData') + txt_obj={:txt =>'
    MetaData'} + format_scroll=Format_scroll.new(@md,txt_obj) para=format_scroll.bold_para elsif para =~/(Owner Details)/ \ and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_scroll=Format_scroll.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_scroll=Format_scroll.new(@md,txt_obj) @@xml[:owner_details]=format_scroll.bold_para para='' - elsif para =~/(.*)<:#>(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum - end - if para =~// \ - and para =~/^(-\{{2}~\d+|)/ # -endnote - para='' + #elsif para =~/(.*)<:#>(.*)/ + # one,two=$1,$2 + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end + #if para =~// \ + #and para =~/^(-\{{2}~\d+|)/ # -endnote + # para='' + #end para=case para when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ if para =~/.*<:#>.*$/ - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end else para @@ -369,11 +373,6 @@ WOK if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 2531a962..1fc6d221 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -313,7 +313,8 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + txt_obj={:txt =>@sto.text} + format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_structure(para,$1,@sto.ocn,$2) @@ -362,17 +363,20 @@ WOK and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ elsif para =~/(MetaData)/ \ and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'
    MetaData') + txt_obj={:txt =>'
    MetaData'} + format_scroll=Format_scroll.new(@md,txt_obj) para=format_scroll.bold_para elsif para =~/(Owner Details)/ \ and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_scroll=Format_scroll.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_scroll=Format_scroll.new(@md,txt_obj) @@xml[:owner_details]=format_scroll.bold_para para='' - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum + #elsif para =~/(.*)(.*)/ + # one,two=$1,$2 + # #txt_obj={:txt =>@sto.txt} + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end if para =~// \ and para =~/^(-\{{2}~\d+|)/ # -endnote @@ -380,18 +384,14 @@ WOK end if para =~/.*<:#>.*$/ #investigate removal para=if para =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index 38ba0a87..b2bc0de7 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -371,7 +371,8 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + txt_obj={:txt =>@sto.text} + format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_markup(para) @@ -438,17 +439,19 @@ WOK #para=format_scroll.boldPara elsif para =~/(MetaData)/ \ and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'
    MetaData') + txt_obj={:txt =>'
    MetaData'} + format_scroll=Format_scroll.new(@md,txt_obj) para=format_scroll.bold_para elsif para =~/(Owner Details)/ \ and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_scroll=Format_scroll.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_scroll=Format_scroll.new(@md,txt_obj) @@xml[:owner_details]=format_scroll.bold_para para='' - elsif para =~/(.*)<:#>(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum + #elsif para =~/(.*)<:#>(.*)/ + # one,two=$1,$2 + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end if para =~// \ and para =~/^(-\{{2}~\d+|)/ # -endnote @@ -456,18 +459,14 @@ WOK end if para =~/.*<:#>.*$/ para=if para =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml_format.rb b/lib/sisu/v0/xml_format.rb index 20eb6736..a801f9d2 100644 --- a/lib/sisu/v0/xml_format.rb +++ b/lib/sisu/v0/xml_format.rb @@ -282,64 +282,74 @@ WOK end class Format_text_object @@dp=nil - attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped - def initialize(md,*txt) - @md=md - txt[0].gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=txt[0],txt[1],txt[2] - @format,@parablock=txt[0],txt[1] - if txt[2]=~/\d+/ - @paranum=/(\d+)/m.match(txt[2])[1] + attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @format =t_o[:format] || nil + @lnk_url =t_o[:lnk_url] || nil + @lnk_txt =t_o[:lnk_txt] || nil + @ocn =t_o[:ocn] || nil + #@h_name =t_o[:h_name] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + if @t_o[:ocn]=~/\d+/ + @paranum=/(\d+)/m.match(@t_o[:ocn])[1] @headname='' #if txt[2]=~/\d+/ - m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(format) + m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(@format) headname=m[1] if m @headname=%{} unless headname.nil? @p_num=SiSU_XML_format::Paragraph_number.new(@md,@paranum) end - #{ rgx=/^[1-6-]~{1,2}/ #watch - link=txt[0].gsub(rgx,'') if @one =~rgx + @lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/~\{\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}\}~/ - link=txt[0].gsub(rgx,'\1') if txt[0] =~rgx - @link,@linkname=link,txt[1] + @lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#{@txt} " end end class Format_scroll < Format_text_object - def initialize(*txt) - super(*txt) + def initialize(md,t_o) + super(md,t_o) end def heading_body - %{

    #{@p_num.name}#@headname#@parablock

    } + + %{

    #{@p_num.name}#{@headname}#{@txt}

    } + %{

    #{@p_num.display}

    \n} end def heading_body1 - %{

    #{@p_num.name}#@headname#@parablock

    } + + %{

    #{@p_num.name}#{@headname}#{@txt}

    } + %{

    #{@p_num.display}

    \n} end def heading_body2 - %{

    #{@p_num.name}#@headname#@parablock

    } + + %{

    #{@p_num.name}#{@headname}#{@txt}

    } + %{

    #{@p_num.display}

    \n} end def heading_body3 - %{

    #{@p_num.name}#@headname#@parablock

    } + + %{

    #{@p_num.name}#{@headname}#{@txt}

    } + %{

    #{@p_num.display}

    \n} end def heading_body4 - %{

    #{@p_num.name}#@headname#@parablock

    } + + %{

    #{@p_num.name}#{@headname}#{@txt}

    } + %{

    #{@p_num.display}

    \n} end def heading_body5 - %{
    #{@p_num.name}#@headname#@parablock
    } + + %{
    #{@p_num.name}#{@headname}#{@txt}
    } + %{

    #{@p_num.display}

    \n} end def heading_body6 - %{
    #{@p_num.name}#@headname#@parablock
    } + + %{
    #{@p_num.name}#{@headname}#{@txt}
    } + %{

    #{@p_num.display}

    \n} end end @@ -347,4 +357,3 @@ WOK end end __END__ - -- cgit v1.2.3 From 2a93f7b9fa048ffba2692cf53c407a943f54505c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 23 Aug 2008 22:12:15 -0400 Subject: minitoc added to concordance and manifest; dal, precision in endnote matching --- lib/sisu/v0/concordance.rb | 19 ++++++++++++------- lib/sisu/v0/dal.rb | 12 ++++++------ lib/sisu/v0/dal_syntax.rb | 11 ++++++----- lib/sisu/v0/html.rb | 4 ++-- lib/sisu/v0/manifest.rb | 21 +++++++++++++++++---- lib/sisu/v0/odf.rb | 18 +++++++++--------- lib/sisu/v0/param.rb | 2 +- lib/sisu/v0/plaintext.rb | 22 +++++++++++----------- lib/sisu/v0/plaintext_format.rb | 2 +- 9 files changed, 65 insertions(+), 46 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 8fe8c4ed..485f3df5 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -68,6 +68,7 @@ module SiSU_Concordance include SiSU_Viz require "#{SiSU_lib}/html_format" include SiSU_HTML_Format + require "#{SiSU_lib}/html_minitoc" class Source def initialize(opt) @opt=opt @@ -105,22 +106,23 @@ module SiSU_Concordance #revisit, both requires (html & shared_xml) needed for stand alone operation (sisu -w [filename]) require "#{SiSU_lib}/shared_xml" require "#{SiSU_lib}/html" - def initialize(lnk,env,md) - @env,@md=env,md + def initialize(particulars) + @particulars,@md=particulars,particulars.md + @data=SiSU_HTML::Source::Html_environment.new(particulars).tuned_file_instructions @vz=SiSU_Env::Get_init.instance.skin - file_array=@env.read_source_file(@md.fns) txt_path=%{#{@md.dir_out}} SiSU_Env::Info_skin.new(@md).select @md_title=@md.title @fnb=@md.fnb @lex_button=%{SiSU home -->} - @lnk=lnk @doc_details =<
     

    #{@md.dc_title}

    #{@md.dc_creator}

    WOK end def create head_banner=SiSU_HTML_Format::Head_toc.new(@md) +minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet +toc='
    ' + minitoc.to_s + '
    ' < @@ -140,6 +142,8 @@ WOK #{@vz.js_top} #{head_banner.concordance_navigation_band('pdf')} + #{toc} +
    #@doc_details

    Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
    [For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]

    (The word listing/index is Case sensitive: Capitalized words appear before lower case)

    @@ -148,7 +152,7 @@ WOK [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.]

    - (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#@fnb/concordance.html#your_word ] + (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ]

    WOK end @@ -177,6 +181,7 @@ WOK include SiSU_Screen @@dp=nil def initialize(particulars) + @particulars=particulars begin @vz=SiSU_Env::Get_init.instance.skin @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array @@ -308,7 +313,7 @@ WOK end scr='Full Text scroll: doc#  ' seg='' - @file_index_all << SiSU_Concordance::Source::Doc_title.new('toc',@env,@md).create + @file_index_all << SiSU_Concordance::Source::Doc_title.new(@particulars).create for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html if keyword !~ @rxp_excluded0 @@ -321,7 +326,7 @@ WOK # special cases endnotes and header levels 1 - 3 end credits=@vz.credits_sisu - @file_index_all << "#{credits}\n" # footer + @file_index_all << %{
    #{credits}
    \n} # footer tell=SiSU_Screen::Ansi.new(@md.cmd,@md.fns,"#{@env.path.output_tell}/#{@md.fn[:concordance]}") tell.flow if @md.cmd =~/[MV]/ end diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 3187a538..a8bf1cd0 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -237,7 +237,7 @@ module SiSU_DAL para.gsub!(/<~#>|~#\s*/,"#{Mx[:fa_o]}~##{Mx[:fa_c]}") para.gsub!(/-#\s*/,"#{Mx[:fa_o]}-##{Mx[:fa_c]}#{Mx[:fa_o]}~##{Mx[:fa_c]}") #para.gsub!(/(#\{{3} arch-tag:|0\{{3}~cvs)\s+/, "0{{~rcs ") #KEEP ... ENABLE WIDER USE OF REVISION CONTROL - para.gsub!(/(#{Mx[:en_a_o]} )\s+/,'\1'); para.gsub!(/(~\{ )\s+/,'\1') + para.gsub!(/(#{Mx[:en_a_o]})\s*/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') para.gsub!(/ \/\//,"#{Mx[:br_line]}") #added 2004w29 para.gsub!(/
    /,"#{Mx[:br_line]}") #needed by xml, xhtml etc. #para.gsub!(/

    /,'

    ') #consider @@ -852,7 +852,7 @@ module SiSU_DAL unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ case para # auto-numbered endnotes --> - when /#{Mx[:en_a_o]}\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ + when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+].+?#{Mx[:en_b_c]}/ para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) word_mode=endnote_call_number(word_mode) @@ -876,15 +876,15 @@ module SiSU_DAL case word when /#{Mx[:en_a_o]}/ unless word =~/#{Mx[:en_a_o]}[*+]+/ - word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@@endnote_counter} ") + word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@@endnote_counter}") @@endnote_counter+=1 end when /#{Mx[:en_b_o]}/ if word =~/#{Mx[:en_b_o]}[+]/ - word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@@endnote_counter_dag} ") + word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@@endnote_counter_dag}") @@endnote_counter_dag+=1 else - word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@@endnote_counter_asterisk} ") + word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@@endnote_counter_asterisk}") @@endnote_counter_asterisk+=1 end when /~\^|<:e>/ @@ -1127,7 +1127,7 @@ module SiSU_DAL end def strip_clean_extra_spaces(s) # dal output tuned s=s.dup - s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') + s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ s=s.gsub(/ [ ]+/,' ') s=s.gsub(/^ [ ]+/,'') s=s.gsub(/ [ ]+$/,'') diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 98c8cf51..8e439870 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -238,8 +238,9 @@ module SiSU_Syntax line=line_array.join(' ') line=line.strip end - 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!(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]) + line.gsub!(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]) #default if markup does not specify + line.gsub!(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) if @md.subtitle and not @md.subtitle.empty? if line =~/(?:by\s+)?(?:@creator|@author)/ 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}") @@ -286,11 +287,11 @@ module SiSU_Syntax 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#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]} \\3 \\4 #{Mx[:en_a_c]}") # watch + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\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#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]} \\3 #{Mx[:en_a_c]} ") + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\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 @@ -322,7 +323,7 @@ module SiSU_Syntax 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!(/<[: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 diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 2dc75d60..e73157bd 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -155,7 +155,7 @@ module SiSU_HTML def tuned_file_instructions @tell=SiSU_Screen::Ansi.new(@md.cmd) if @md - @md.sfx='' + #@md.sfx='' @md.sfx='' if @md.cmd =~/z/ if @md.cmd =~/h/ \ or @md.fns =~/\~[a-z]{2,3}\.s?/ #multilingual document protection is a bit arbitrary, (needed by existing server configuration), add configuration overide... @@ -275,7 +275,7 @@ module SiSU_HTML when /^\s*#{Mx[:lv_o]}4:\S+/; Toc.new(para_toc,@md).level_4 when /^\s*#{Mx[:lv_o]}5:\S*/; Toc.new(para_toc,@md).level_5 when /^\s*#{Mx[:lv_o]}6:\S*/; Toc.new(para_toc,@md).level_6 - when /^\s*4~!/; Toc.new(para_toc).level_crosslink + when /^\s*4~!/; Toc.new(para_toc).level_crosslink else end if @@firstseg.nil? \ diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index 6bdfdae4..104d3fc9 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -60,13 +60,21 @@ =end module SiSU_Manifest require "#{SiSU_lib}/sysenv" - require "#{SiSU_lib}/i18n" include SiSU_Env + require "#{SiSU_lib}/i18n" + require "#{SiSU_lib}/particulars" + include SiSU_Particulars + require "#{SiSU_lib}/html_minitoc" + require "#{SiSU_lib}/html" + include SiSU_HTML_Format + require "#{SiSU_lib}/param" include SiSU_Param include SiSU_Viz class Source def initialize(opt) @opt=opt + @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @data=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions l=SiSU_Env::Standardise_language.new.file_to_language(@opt.fns) @doc_language=l[:l] end @@ -83,16 +91,16 @@ module SiSU_Manifest tell.green_hi_blue unless @opt.cmd =~/q/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}") tell.grey_tab if @opt.cmd =~/v/i - Output_Info.new(@md).check_output + Output_Info.new(@md,@data).check_output rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error ensure end end private class Output_Info [],:html=>[] } - @md,@fns=md + @md,@fns,@data=md,md.fns,data @env=SiSU_Env::Info_env.new(@md.fns) @fnb=@md.fnb @base_url,@base_url_src,@base_url_pod="#{@env.url.root}/#@fnb","#{@env.url.src_txt}","#{@env.url.src_pod}" @@ -523,6 +531,8 @@ module SiSU_Manifest end def check_output begin + minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet + toc='

    ' + minitoc.to_s + '
    ' id,file='','' vz=SiSU_Env::Get_init.instance.skin banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \ @@ -555,6 +565,8 @@ SiSU manifest: #{@md.title} #{banner_table} +#{toc} +

    #{@md.dc_title}

    #{@md.dc_creator}

    @@ -600,6 +612,7 @@ WOK language_versions @manifest[:html] <<< + #{vz.credits_splash} #{vz.credits_sisu} diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index d21a8628..03a94ce6 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -128,7 +128,7 @@ module SiSU_ODF end # Used for extraction of endnotes from paragraphs def extract_endnotes(para='') - notes=para.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)\s*#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/) + notes=para.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)\s*#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/)[1] @n=[] notes.each do |n| #high cost to deal with
    appropriately within odf, consider n=n.dup.to_s @@ -283,24 +283,24 @@ module SiSU_ODF end def footnote(para) @astx||=10000 - para.gsub!(/#{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_a_c]}|#{Mx[:en_a_c]})/,'\1') + para.gsub!(/#{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') #para.gsub!(/
    <:i[1-9]>/,'
    ') - if para =~/#{Mx[:en_a_o]}\d+\s+/ + if para =~/#{Mx[:en_a_o]}\d+\s+/ para=para.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'\1 \2') end - if para=~/#{Mx[:en_b_o]}[*+]\d+\s/ #editor notes, squre bracket series - asterisk=para.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/) + if para=~/#{Mx[:en_a_o]}[*+]+\s/ + asterisk=para.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/) asterisk.each do |x| a=x[0].gsub(/([*+])/,"\\\\\\1") - para=para.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{\\1 \\2}) + para=para.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{\\1 \\2}) @astx+=1 end end - if para=~/#{Mx[:en_a_o]}[*+]+\s/ - asterisk=para.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/) + if para=~/#{Mx[:en_b_o]}[*+]\d+\s/ + asterisk=para.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/) asterisk.each do |x| a=x[0].gsub(/([*+])/,"\\\\\\1") - para=para.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{\\1 \\2}) + para=para.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{\\1 \\2}) @astx+=1 end end diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 43b2d862..3cfbf1e5 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -195,7 +195,7 @@ module SiSU_Param end @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general @sfx_src=@fns[m,2] - @sfx=nil + @sfx='.html' # #@sfx=nil watch @flag_auto_heading_num=false if @fns =~ /(?:-|ssm\.)?sst$/ #watch @env_out_root=@env.path.output diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 132f2997..9d25ed73 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -66,7 +66,7 @@ module SiSU_Plaintext include SiSU_Param include SiSU_Viz require "#{SiSU_lib}/plaintext_format" - include Format + include SiSU_Plaintext_format require "#{SiSU_lib}/shared_txt" require "#{SiSU_lib}/shared_structure" pwd=Dir.pwd @@ -334,7 +334,7 @@ WOK if para !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change paranum=para[@regx,3] - @p_num=Format::Paragraph_number.new(paranum) + @p_num=SiSU_Plaintext_format::Paragraph_number.new(paranum) end @sto=SiSU_Structure::Split_text_object.new(@md,para).txt ### problem in scroll, it appears tables are getting paragraph numbers @@ -378,10 +378,10 @@ WOK #@plaintext[:owner_details]=formatMono.bold_para #para='' elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! check - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum + #elsif para =~/(.*)(.*)/ + # one,two=$1,$2 + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end para='' if (para =~// \ and para =~/^(-\{{2}~\d+|)/) # -endnote @@ -396,11 +396,11 @@ WOK if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end + #if para =~/<:center>/ + # one,two=/(.*)<:center>(.*)/.match(para)[1,2] + # format_text=Format_text_object.new(one,two) + # para=format_text.center + #end para.gsub!(/#{Mx[:id_o]}.+?#{Mx[:id_c]}/,' ') if para ## Clean Prepared Text para.gsub!(//,' ') if para ## Clean Prepared Text para.gsub!(/<:\S+>/,' ') if para ## Clean Prepared Text diff --git a/lib/sisu/v0/plaintext_format.rb b/lib/sisu/v0/plaintext_format.rb index ddac2e32..cada3425 100644 --- a/lib/sisu/v0/plaintext_format.rb +++ b/lib/sisu/v0/plaintext_format.rb @@ -58,7 +58,7 @@ ** Description: plaintext formatting template =end -module Format +module SiSU_Plaintext_format require "#{SiSU_lib}/param" include SiSU_Param include SiSU_Viz -- cgit v1.2.3 From f1fe4547034011194e913ffd70820e1c4f39d6ba Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 24 Aug 2008 12:48:32 -0400 Subject: minitoc added, used by manifest and concordance; html css div sorting a earlier commit relies on minitoc prior to its addition, this fixes that issue html css divs, need to be watched across different html output --- lib/sisu/v0/css.rb | 4 +- lib/sisu/v0/defaults.rb | 3 +- lib/sisu/v0/html_format.rb | 4 +- lib/sisu/v0/html_minitoc.rb | 241 +++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v0/html_segments.rb | 10 +- lib/sisu/v0/manifest.rb | 8 +- 6 files changed, 256 insertions(+), 14 deletions(-) create mode 100644 lib/sisu/v0/html_minitoc.rb (limited to 'lib') diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index 449f51d8..b5b08698 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -743,7 +743,7 @@ WOK margin-bottom: 0px; } - div.substance, div.main_column { + div.substance { width: 100%; background-color: #ffffff; } @@ -775,7 +775,7 @@ WOK padding-left: 1em; background-color: #eeeeee; } - div.content { + div.content, div.main_column { margin: 0; padding: 0; border-left: 13em solid #ffffff; diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 821893fc..491be5ff 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -1628,12 +1628,11 @@ WOK end def credits_sisu %{
    -

    #{widget_sisu} #{widget_way_better} -

    } +
    } end def credits_splash end diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 1d82ddfe..a73f3533 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -837,9 +837,7 @@ WOK - - - + } end def navigation_band(segtocband,seg_table_top_control) #change name to navigaion_band_banner diff --git a/lib/sisu/v0/html_minitoc.rb b/lib/sisu/v0/html_minitoc.rb new file mode 100644 index 00000000..44ed57d2 --- /dev/null +++ b/lib/sisu/v0/html_minitoc.rb @@ -0,0 +1,241 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + minitoc + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end + module SiSU_HTML_minitoc + require "#{SiSU_lib}/html_tune" + include SiSU_Tune + class Toc_mini + @@seg_mini=nil + @@seg_url='' + @@dp,@@firstseg=nil,nil + def initialize(md,data) + @md,@data=md,data + @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @pat_heading=/^#{Mx[:lv_o]}[1-6]:\S*?#{Mx[:lv_c]}\s*(.*)#{Mx[:id_o]}~(\d+);(?:[hm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + @pat_strip_heading_name=/(.+?)<\/a>/ + @tell=SiSU_Screen::Ansi.new(@md.cmd) if @md + end + def songsheet + SiSU_Screen::Ansi.new(@md.cmd,'Toc').txt_grey unless @md.cmd =~/q/ + toc=nil + @toc=[] + @data.each do |txt| + if txt =~/^(?:#{Mx[:lv_o]}[1-6]:|4~!)/ + txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,'') #remove endnotes from toc + txt.gsub!(/ \d+<\/sup> <\/a>/,'') + txt.gsub!(@pat_strip_heading_name,'\1') + txt.gsub(/(.*?)<\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect + toc=case txt + when /^\s*#{Mx[:lv_o]}1:\S*/; Toc_mini.new(@md,txt).level_1 + when /^\s*#{Mx[:lv_o]}2:\S*/; Toc_mini.new(@md,txt).level_2 + when /^\s*#{Mx[:lv_o]}3:\S*/; Toc_mini.new(@md,txt).level_3 + when /^\s*#{Mx[:lv_o]}4:\S+/; Toc_mini.new(@md,txt).level_4 + when /^\s*#{Mx[:lv_o]}5:\S*/; Toc_mini.new(@md,txt).level_5 + when /^\s*#{Mx[:lv_o]}6:\S*/; Toc_mini.new(@md,txt).level_6 + when /^\s*4~!/; Toc.new(txt).level_crosslink + else + end + @toc << toc + end + end + @toc + end + protected + def level_concordance + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + @@seg_mini << format_head_toc.mini_seg_concordance + end + def level_metadata + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + @@seg_mini << format_head_toc.mini_seg_metadata + end + def level_word_index + format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c) + @@seg_mini << format_head_toc.mini_concordance + end + def level_1 + txt=@data + unless txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt.gsub!(@pat_strip_heading_name,'\1') + end + txt[@pat_heading] + linkname,ocn=$1.strip,$2 if $& + title=unless txt =~/Document Information/; linkname + else + link='metadata' + %{#{linkname}} + end + toc={} + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + toc_mini=if txt =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ + format_toc.mini_tail + else format_toc.mini_lev1 + end + toc_mini + end + def level_2 + txt=@data + unless txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt.gsub!(@pat_strip_heading_name,'\1') + end + txt[@pat_heading] + linkname,ocn=$1.strip,$2 if $& + txt_obj={:txt =>linkname} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + toc_mini=format_toc.mini_lev2 + toc_mini + end + def level_3 + txt=@data + txt[@pat_heading] + linkname,ocn=$1.strip,$2 if $& + txt_obj={:txt =>linkname} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + toc_mini=format_toc.mini_lev3 + toc_mini + end + def level_4 + txt=@data + unless txt =~/~metadata/ + unless txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt.gsub!(@pat_strip_heading_name,'\1') + txt[@pat_heading] + linkname,ocn=$1.strip,$2 if $& + end + txt.gsub!(/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') + if txt =~/^#{Mx[:lv_o]}4:/ + seg_link=txt.gsub(/^\s*#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}\s*(.+?)$/, + %{ + \\2 + }) + if seg_link =~/(#{Mx[:id_o]}\~\d+;(?:\w|[0-6]:\d+);\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/m + m=/#{$1}/m + seg_link.gsub!(m,'') + end + @@seg_url=txt[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?$/,1] + elsif txt =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ + seg_link=txt.gsub(/^\s*(#{@md.lv4}\s+)\s*(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/, + %{\\1 \\2 \\3 }) + end + txt_obj={:txt =>seg_link} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + toc_mini=format_toc.mini_lev4 + toc_mini + end + end + def level_5 + txt=@data + if txt !~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt.gsub!(@pat_strip_heading_name,'\1') + end + txt[@pat_heading] + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + end + toc={} + if txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + m=/#{$1}/ + txt.gsub!(m,'') + title=linkname + else + lnk_n_txt=%{ + #{linkname} + } + txt_obj={:txt =>lnk_n_txt} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + toc_mini=format_toc.mini_lev5 + end + toc_mini + end + def level_6 + txt=@data + if txt !~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt.gsub!(@pat_strip_heading_name,'\1') + end + txt[@pat_heading] + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + end + toc={} + if txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + m=/#{$1}/ + txt.gsub!(m,'') + title=linkname + else + lnk_n_txt=%{ + #{linkname} + } + txt_obj={:txt =>lnk_n_txt} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + toc_mini=format_toc.mini_lev6 + end + toc_mini + end + end + end +__END__ + diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index b457fe5c..11c95755 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -221,11 +221,11 @@ module SiSU_HTML_seg if @@is1 == 1 @dc_creator=%{#{@md.dc_creator}\n} if @md.dc_creator.to_s =~/\S/ @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) - conditional_div_close=unless @@get_hash_fn =~/metadata/ #watch + conditional_div_close=if @@get_hash_fn =~/metadata/ #watch '' else '' end - @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) + @@seg[:tocband_bannerless] << conditional_div_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') ocn=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 @@ -380,11 +380,13 @@ module SiSU_HTML_seg def tail format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn] - @@seg[:tail] << format_head_seg.endnote_section_open + @@seg[:tail] << '
    ' if @@seg_endnotes[@@get_hash_fn].flatten.length > 0 @@seg[:tail] << format_head_seg.endnote_mark @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| end + @@seg[:tail] << '
    ' + @@seg[:tail] << '' #this div closes div class content end #@@seg[:tail] << '
     
    ' ads=SiSU_HTML_promo::Ad.new(@md) @@ -397,7 +399,7 @@ module SiSU_HTML_seg if type !~/endnote/ filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] else - filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
    \n} << @@seg[:endnote_all] #<< '
    ' + filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
    \n} << @@seg[:endnote_all] #<< '
    ' << '' end filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] filename_seg.flatten!.compact! diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index 104d3fc9..ffd99695 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -532,7 +532,6 @@ module SiSU_Manifest def check_output begin minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet - toc='
    ' + minitoc.to_s + '
    ' id,file='','' vz=SiSU_Env::Get_init.instance.skin banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \ @@ -565,7 +564,9 @@ SiSU manifest: #{@md.title} #{banner_table} -#{toc} +
    +#{minitoc.to_s} +

    #{@md.dc_title}

    #{@md.dc_creator}

    @@ -613,8 +614,9 @@ WOK @manifest[:html] <<<
    -#{vz.credits_splash} +
    #{vz.credits_sisu} +
    WOK -- cgit v1.2.3 From c6d41d9367afc974fe60ca27cb890568609b5f12 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 27 Aug 2008 00:43:43 -0400 Subject: texpdf: paper use dimensions url and urlbreaks removal of a maths package gives back typeface changes like bold better representation of tilde changelog update --- lib/sisu/v0/defaults.rb | 22 +++++++++++----------- lib/sisu/v0/texpdf.rb | 1 + lib/sisu/v0/texpdf_format.rb | 36 +++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 28 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 491be5ff..801b6434 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -2095,10 +2095,10 @@ WOK end def landscape def w - 262 + 250 end def h - 168 + 160 end def img_px 348 @@ -2113,7 +2113,7 @@ WOK 166 end def h - 216 + 212 end def img_px 468 @@ -2122,7 +2122,7 @@ WOK end def landscape def w - 242 + 234 end def h 166 @@ -2149,7 +2149,7 @@ WOK end def landscape def w - 314 + 306 end def h 166 @@ -2167,7 +2167,7 @@ WOK 140 end def h - 210 + 204 end def img_px 356 @@ -2176,10 +2176,10 @@ WOK end def landscape def w - 216 + 208 end def h - 136 + 130 end def img_px 280 @@ -2194,7 +2194,7 @@ WOK 112 end def h - 170 + 162 end def img_px 280 @@ -2203,10 +2203,10 @@ WOK end def landscape def w - 176 + 164 end def h - 110 + 100 end def img_px 230 diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index c5ee2092..19e0a119 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -542,6 +542,7 @@ module SiSU_TeX \\tolerance=500 \\makeatother \\makeatother +\\sloppy \\begin{document} WOK sisu_rc_footnote=if @md.sc_info; @tex.doc_sc_info_footnote_full diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 55a9473f..58dca26e 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -701,7 +701,7 @@ WOK def tex_head_paper_landscape(d) </,' ') string.gsub!(/<\/a>/,' ') string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, - '\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url + '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, - ' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case + ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, - '\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, - "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start + "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start else #code-block: angle brackets special characters, note _ already escaped string.gsub!(/\\_/,'{\UseTextSymbol{OML}{>}}') @@ -1103,7 +1105,7 @@ WOK #string.gsub!(/<=gt>/,'\>') string.gsub!(/<=underscore>/,'\_') string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text - string.gsub!(/<=tilde>/,'{\~~}') + string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') #string.gsub!(/<=caret>/,'\^{}') @@ -1212,14 +1214,14 @@ WOK string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, - '\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url + '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, - ' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case + ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, - '\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, - "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start + "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start else #code-block: angle brackets special characters, note _ already escaped string.gsub!(/\\_/,'{\UseTextSymbol{OML}{>}}') @@ -1274,7 +1276,7 @@ WOK #string.gsub!(/<=gt>/,'\>') string.gsub!(/<=underscore>/,'\_') string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text - string.gsub!(/<=tilde>/,'{\~~}') + string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') #string.gsub!(/<=caret>/,'\^{}') -- cgit v1.2.3 From 602a7b497284baa85bac466ba5c4e28ec9e7c554 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 27 Aug 2008 23:38:37 -0400 Subject: texpdf: landscape tables in two column text fixed; footnote margin increased --- lib/sisu/v0/texpdf_format.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 58dca26e..b193a345 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -124,7 +124,6 @@ module SiSU_TeX_Pdf @@tableheader[@ps][:l]=1 if @txt =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) @@number_of_cols=no_of_cols ||=@@number_of_cols - #@@number_of_cols=0 unless @@number_of_cols.to_i > 0 @colW=[] @colW << '{' w.each do |x| @@ -137,7 +136,7 @@ module SiSU_TeX_Pdf @colW=@colW.join @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") end if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") @@ -151,11 +150,10 @@ module SiSU_TeX_Pdf @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader[@ps][:l]=0 - #@@tableheader[@ps][:l],@@number_of_cols=0,0 end else if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u - @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') @txt.gsub!(/&\s*$/," #@row_break") end end @@ -184,8 +182,7 @@ module SiSU_TeX_Pdf @colW << '{' w.each do |x| x.strip! - x=(x.to_i * textwidth)/100 - #x=(x.to_i/100.0 * 160) + x=(x.to_i * textwidth)/100 #x=(x.to_i/100.0 * 160) col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil? @colW << "p{#{col_w}mm}" if col_w end @@ -193,21 +190,20 @@ module SiSU_TeX_Pdf @colW=@colW.join @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) end if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader[@ps][:p] == 1 - if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u tablefoot=@txt[/\/,1] @txt.gsub!(/\/,'') @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader[@ps][:p]=0 - #@@tableheader[@ps][:p],@@number_of_cols=0,0 end else if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u @@ -904,7 +900,7 @@ WOK \\makeatletter #{endnotes} \\usepackage[multiple,marginal]{footmisc} -% \\setlength\\footnotemargin{40pt} +\\setlength\\footnotemargin{-20pt} \\usepackage[para]{manyfoot} \\DeclareNewFootnote{A} %\\DeclareNewFootnote[para]{A} -- cgit v1.2.3 From c01a2c64c26396b5e61f49c272010794937d0c60 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 27 Aug 2008 23:41:14 -0400 Subject: texpdf, footnotes align left (ragged), footnote numbers removed from margin --- lib/sisu/v0/texpdf_format.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index b193a345..04dae4d8 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -899,8 +899,8 @@ WOK \\setcounter{tocdepth}{4} \\makeatletter #{endnotes} -\\usepackage[multiple,marginal]{footmisc} -\\setlength\\footnotemargin{-20pt} +\\usepackage[multiple,ragged]{footmisc} +\\setlength\\footnotemargin{12pt} \\usepackage[para]{manyfoot} \\DeclareNewFootnote{A} %\\DeclareNewFootnote[para]{A} -- cgit v1.2.3 From a0012a41b4aa49cdf05d9f5f55a67673bf4c8bb2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 28 Aug 2008 23:19:32 -0400 Subject: texpdf: removed space at beginning of paragraph; grouped text url fix --- lib/sisu/v0/texpdf.rb | 2 +- lib/sisu/v0/texpdf_format.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 19e0a119..f86d8729 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -72,7 +72,7 @@ module SiSU_TeX @@tabular="{tabular}" @@column_instruct=@@squigle_close=@@tex_line_mode=@@tex_word_mode=@@line_mode='' @@tex_debug_counter=@@table_pagebreak_counter=@@tex_footnote_call_counter=@@tex_table_flag=@@tex_counter=@@tex_column=@@tex_columns=@@tex_columns=@@counting=0 - @@tex_pattern_margin_number=/\\\\begin\\\{tiny\\\}~\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+/ + @@tex_pattern_margin_number=/\\\\begin\\\{tiny\\\}\\\\hspace\\\{0mm\\\}\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+/ #@@tex_pattern_margin_number="\\\\marginpar.+?\s+" @@n=@@tableheader=@@rights=nil @@date ||=SiSU_Env::Info_date.new diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 04dae4d8..c224d4aa 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -68,7 +68,7 @@ module SiSU_TeX_Pdf @@sys=SiSU_Env::System_call.new @@tex_backslash="\\\\" @@tilde='\\\\\\~' #?? debug crazy - @@tex_pattern_margin_number=/\\begin\{tiny\}~\\end\{tiny\}\{\\marginpar.+?\}\}\}/ + @@tex_pattern_margin_number=/\\begin\{tiny\}\\hspace\{0mm\}\\end\{tiny\}\{\\marginpar.+?\}\}\}/ @@tableheader={ 'a4' => { :p => 0, :l => 0 }, 'a5' => { :p => 0, :l => 0 }, @@ -559,7 +559,7 @@ para paranumber_display=if @md.markup.inspect =~/no_ocn/ \ or @md.mod.inspect =~/--no-ocn/ '' - else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@ocn\\end{tiny}}}" #ocn object citation numbering + else "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}#@ocn\\end{tiny}}}" #ocn object citation numbering end if @txt !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ @txt.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect @@ -1189,7 +1189,7 @@ WOK string.gsub!(/\#/,'\#') string.gsub!(/\%/,'\%') string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes - if string !~/^\s*#{Mx[:lnk_o]}|#{Mx[:lnk_c]}image\s/ + if string !~/^\s*#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\s/ string.gsub!(/_/,'\_') end string.gsub!(/\{/,'\{') -- cgit v1.2.3 From 749e0d8443028eaff7af93d17c8dae8d44be42bc Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 29 Aug 2008 21:40:02 -0400 Subject: texpdf: paper use dimensions, tolerance, url matching; removal of dummy headings when not used; manifest presentation * texpdf: paper use dimensions, tolerance, url matching; * removal of dummy headings when not used (html scroll, latex/pdf, odf) * manifest presentation --- lib/sisu/v0/defaults.rb | 12 +++++----- lib/sisu/v0/html_scroll.rb | 1 + lib/sisu/v0/i18n.rb | 54 +++++++++++++++++++++++++++++++++++++++----- lib/sisu/v0/manifest.rb | 29 ++++++++++++++++-------- lib/sisu/v0/odf.rb | 1 + lib/sisu/v0/plaintext.rb | 4 ---- lib/sisu/v0/texpdf.rb | 15 +++++++----- lib/sisu/v0/texpdf_format.rb | 20 ++++++++-------- lib/sisu/v0/xml.rb | 3 --- 9 files changed, 95 insertions(+), 44 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 801b6434..a3e1b16d 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -2095,7 +2095,7 @@ WOK end def landscape def w - 250 + 238 end def h 160 @@ -2122,7 +2122,7 @@ WOK end def landscape def w - 234 + 226 end def h 166 @@ -2140,7 +2140,7 @@ WOK 168 end def h - 294 + 286 end def img_px 474 @@ -2149,7 +2149,7 @@ WOK end def landscape def w - 306 + 296 end def h 166 @@ -2176,7 +2176,7 @@ WOK end def landscape def w - 208 + 200 end def h 130 @@ -2203,7 +2203,7 @@ WOK end def landscape def w - 164 + 152 end def h 100 diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 9286df10..3e72f855 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -87,6 +87,7 @@ module SiSU_HTML_scroll #if para =~/^#{Mx[:lv_o]}\d:endnotes#{Mx[:lv_c]}\s*Endnotes/ ## para.gsub!(/Endnotes.+/,'') #end + para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ para.gsub!(/(Document Information(?: \(metadata\))?)/,'\1') end diff --git a/lib/sisu/v0/i18n.rb b/lib/sisu/v0/i18n.rb index 8ac3ffc8..286ba65d 100644 --- a/lib/sisu/v0/i18n.rb +++ b/lib/sisu/v0/i18n.rb @@ -105,6 +105,9 @@ module SiSU_Translate def metadata @lang_class.metadata end + def filetype_description + @lang_class.filetype_description + end def file_size @lang_class.file_size end @@ -258,6 +261,9 @@ module SiSU_Translate def language @lang_class.language end + def manifest_description + @lang_class.manifest_description + end def manifest_description_output @lang_class.manifest_description_output end @@ -314,6 +320,9 @@ module SiSU_Translate def description 'description' end + def filetype_description + 'filetype description' + end def metadata 'metadata' end @@ -464,11 +473,14 @@ module SiSU_Translate def language_version_list 'Document Language Versions, manifests' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output - 'SiSU manifest' + 'Available document filetypes' end def manifest_description_metadata - 'SiSU manifest of document metadata' + 'Document Metadata' end def language_list_translated lang=case @trans_str @@ -513,6 +525,9 @@ module SiSU_Translate def description 'description' end + def filetype_description + description + end def metadata 'metadonnées' end @@ -663,6 +678,9 @@ module SiSU_Translate def language_version_list 'Versions des langues du document, manifestes' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Manifeste SiSU du document généré' end @@ -712,6 +730,9 @@ module SiSU_Translate def description 'Beschreibung' end + def filetype_description + description + end def metadata 'Metadata' end @@ -862,6 +883,9 @@ module SiSU_Translate def language_version_list 'verfügbare Sprachen' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'SiSU Zusammenfassung des Dokumentes' end @@ -907,10 +931,13 @@ module SiSU_Translate end def filename 'nombre del fichero' - end - def description - 'descripción' - end + end + def description + 'descripción' + end + def filetype_description + description + end def metadata 'metadatos' end @@ -1061,6 +1088,9 @@ module SiSU_Translate def language_version_list 'Document Language Versions, manifests' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Manifiesto SiSU de salida generada' end @@ -1110,6 +1140,9 @@ module SiSU_Translate def description 'descrizione' end + def filetype_description + description + end def metadata 'metadati' end @@ -1260,6 +1293,9 @@ module SiSU_Translate def language_version_list 'Traduzioni disponibili' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Inventario SiSU dell\'output generato' end @@ -1309,6 +1345,9 @@ module SiSU_Translate def description 'kuvaus' end + def filetype_description + description + end def metadata 'metadata' end @@ -1459,6 +1498,9 @@ module SiSU_Translate def language_version_list 'Dokumentin kieliversiot, manifestit' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Tuotetun tuloksen SISU-manifesti' end diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index ffd99695..78045e80 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -65,6 +65,7 @@ module SiSU_Manifest require "#{SiSU_lib}/particulars" include SiSU_Particulars require "#{SiSU_lib}/html_minitoc" + #require "#{SiSU_lib}/html_format" require "#{SiSU_lib}/html" include SiSU_HTML_Format require "#{SiSU_lib}/param" @@ -119,7 +120,7 @@ module SiSU_Manifest manifest << x end end - def summarize(id,file,img='') + def summarize(id,file,img='● ') size=(File.size("#{@base_path}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" @@ -177,7 +178,7 @@ module SiSU_Manifest elsif url =~/^\.\.\//; url.gsub(/^\.(\.)?/,@env.url.root) else url end - @manifest[:html] << %{

    #{lnk}

      #{@url_brace.xml_open}#{static}#{@url_brace.xml_close}

    #{lnk}

      #{@url_brace.xml_open}#{static}#{@url_brace.xml_close}

    WOK published_versions @manifest[:html] << '
    ' @manifest[:html] <<<#{@translate.manifest_description_output} - - +

    #{@translate.description}

    #{@translate.filename}

    #{@translate.file_size}

    (kB)

    + WOK output_tests @@ -589,7 +600,7 @@ WOK @manifest[:html] << '

    #{@translate.filetype_description}

    #{@translate.filename}

    #{@translate.file_size}

    (kB)

    ' @manifest[:html] <<<#{@translate.manifest_description_metadata} - +
    WOK metadata_tests @@ -597,8 +608,8 @@ WOK

    #{@translate.metadata}

    #{@translate.description}

    WOK @manifest[:html] <<< -

    #{@translate.suggested_links}:

    WOK links_tests @manifest[:html] <<<#{@translate.language_version_list} -
    +
    WOK diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 03a94ce6..6b1491c2 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -441,6 +441,7 @@ module SiSU_ODF data.each do |para| #p para if para =~safe_characters and @md.cmd =~/V/ #KEEP #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') + para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ para_array=[] word=para.scan(/\S+|\n/) if word diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 9d25ed73..4dd808fc 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -378,10 +378,6 @@ WOK #@plaintext[:owner_details]=formatMono.bold_para #para='' elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! check - #elsif para =~/(.*)(.*)/ - # one,two=$1,$2 - # format_text=Format_text_object.new(one,two) - # para=format_text.seg_no_paranum end para='' if (para =~// \ and para =~/^(-\{{2}~\d+|)/) # -endnote diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index f86d8729..3cf560c4 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -344,6 +344,7 @@ module SiSU_TeX # DEBUG 2003w16 this is a kludge, because i could not get parameters # from param, Sort out ... revert to more elegant solution # even more of a kludge as had to insert newlines where code is used not satisfactory, think about + para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ para=if para =~/#{Mx[:br_nl]}|\n/; para.split(/#{Mx[:br_nl]}|\n/) else para end @@ -438,7 +439,7 @@ module SiSU_TeX end elsif x =~/code/; @@flag_alt,@@flag_code=true,true elsif @@flag_alt - if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/m + if para =~ /(?:https?|file|ftp)/m txt_obj={:txt =>para,:paper_size =>'a4'} para=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http end @@ -503,7 +504,7 @@ module SiSU_TeX end para end - if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/ + if para =~ /(?:https?|file|ftp)/ para=if para !~/\.(?:png|jpg|gif)/ txt_obj={:txt =>para,:paper_size =>'a4'} SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http @@ -539,10 +540,12 @@ module SiSU_TeX end @tex_file <<< # note this bit of dereferencing magic + s_lnk_url=%<\\begin{scriptsize}\\url{#{url}}\\end{scriptsize}> # note this bit of dereferencing magic else url.gsub!(/\.\.\//,'') s_lnk_url="(#{@tex.site}) \\\\\n" + ' ' + "\\begin{scriptsize}" + - %<\\href\{#{@vz.url_root_http}/#{url}\}\{#{@vz.url_root_http}/#{url}\}> + # note this bit of dereferencing magic + %<\\url\{#{@vz.url_root_http}/#{url}\}> + # note this bit of dereferencing magic "\\end{scriptsize}" end @tex_file << " #{s_lnk} \\\\\n #{s_lnk_url} \n" unless @md.doc_skin =~/skin_mail/ diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index c224d4aa..b6a1e1f2 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -461,9 +461,9 @@ para @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ @words.each do |word| @w << if word=~@url_generic_rgx - if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ - regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ - punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join + if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ + regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ + punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?([;.,]?(?:\s|$))/.match(word).captures.join else regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\S+)/ punctuate='' @@ -1042,14 +1042,14 @@ WOK string.gsub!(/&\S+?;/,' ') string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') - string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code - string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start else #code-block: angle brackets special characters, note _ already escaped string.gsub!(/\\_/,'\<') #string.gsub!(/<=gt>/,'\>') string.gsub!(/<=underscore>/,'\_') - string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text + string.gsub!(/((?:\\href|\\url)\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') @@ -1209,14 +1209,14 @@ WOK string.gsub!(/&\S+?;/,' ') string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') - string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case - string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code - string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start else #code-block: angle brackets special characters, note _ already escaped string.gsub!(/\\_/,'\<') #string.gsub!(/<=gt>/,'\>') string.gsub!(/<=underscore>/,'\_') - string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text + string.gsub!(/((?:\\href|\\url)?\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 1fc6d221..4826a503 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -389,9 +389,6 @@ WOK format_text.scr_inden_ocn_e_no_paranum end end - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ - # i don't get the condition for no paranum - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para -- cgit v1.2.3 From b2ef41078f8704e16c589063cde225874a3069f9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 2 Sep 2008 23:23:12 -0400 Subject: html segments; sql db field lengths increased --- lib/sisu/v0/db_columns.rb | 36 ++++++++++++++++++------------------ lib/sisu/v0/html_segments.rb | 7 +++---- 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/db_columns.rb b/lib/sisu/v0/db_columns.rb index fcb37812..87e14b01 100644 --- a/lib/sisu/v0/db_columns.rb +++ b/lib/sisu/v0/db_columns.rb @@ -62,28 +62,28 @@ module SiSU_DB_columns class Column_size def lt_title - 320 + 600 end def lt_subtitle - 320 + 600 end def lt_creator - 200 + 600 end def lt_illustrator - 200 + 600 end def lt_translator - 200 + 600 end def lt_prepared_by - 200 + 600 end def lt_digitized_by - 200 + 600 end def lt_subject - 400 + 600 end def lt_date 10 @@ -104,25 +104,25 @@ module SiSU_DB_columns 10 end def lt_type - 100 + 600 end def lt_description - 800 + 2000 end def lt_publisher - 120 + 600 end def lt_contributor - 120 + 600 end def lt_format - 100 + 600 end def lt_identifier 256 end def lt_source - 100 + 200 end def lt_language 30 @@ -143,16 +143,16 @@ module SiSU_DB_columns 100 end def lt_rights - 800 + 2000 end def lt_copyright - 200 + 2000 end def lt_owner - 100 + 600 end def lt_keywords - 200 + 600 end def lt_comment 600 diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 11c95755..8d89de28 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -195,7 +195,6 @@ module SiSU_HTML_seg end end end - @@seg[:main] << "\n\n" data end def header_art(para) @@ -380,7 +379,7 @@ module SiSU_HTML_seg def tail format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn] - @@seg[:tail] << '
    ' + @@seg[:tail] << %{\n
    \n
    \n} if @@seg_endnotes[@@get_hash_fn].flatten.length > 0 @@seg[:tail] << format_head_seg.endnote_mark @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| @@ -397,9 +396,9 @@ module SiSU_HTML_seg filename_seg=[] filename_seg << @@seg[:title] << @@seg[:tocband_banner] if type !~/endnote/ - filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] + filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] << "\n
    \n" else - filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
    \n} << @@seg[:endnote_all] #<< '
    ' << '
    ' + filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
    \n} << @@seg[:endnote_all] << '
    ' end filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] filename_seg.flatten!.compact! -- cgit v1.2.3 From 2a738f528cb87793ff7f8312099666af1e21f44c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 3 Sep 2008 22:25:03 -0400 Subject: xml character encoding adjusted; xml image match; odf issue with '@' symbol in url --- lib/sisu/v0/character_encoding.rb | 4 +++- lib/sisu/v0/odf.rb | 7 +++++-- lib/sisu/v0/param.rb | 42 +++++++++++++++++++-------------------- lib/sisu/v0/shared_xml.rb | 29 +++++++++++++++++++++++++++ lib/sisu/v0/xhtml.rb | 2 +- lib/sisu/v0/xml.rb | 2 +- lib/sisu/v0/xml_dom.rb | 2 +- 7 files changed, 61 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/character_encoding.rb b/lib/sisu/v0/character_encoding.rb index 60c2f335..aa856cdd 100644 --- a/lib/sisu/v0/character_encoding.rb +++ b/lib/sisu/v0/character_encoding.rb @@ -374,7 +374,9 @@ module SiSU_character_encode ['ü', 252, '374', '\303\274', 'ü', 'ü', 'ü', '\"{u}', '', 'Small u, umlaut ü' ], ['ý', 253, '375', '\303\275', 'ý', 'ý', 'ý', '', '', 'Small y, acute accent ý' ], ['þ', 254, '376', '\303\276', 'þ', 'þ', 'þ', '', '', 'Small thorn, Icelandic þ' ], - ['ÿ', 255, '377', '\303\277', 'ÿ', 'ÿ', 'ÿ', '', '', 'Smally y, umlaut ÿ' ] + ['ÿ', 255, '377', '\303\277', 'ÿ', 'ÿ', 'ÿ', '', '', 'Smally y, umlaut ÿ' ], + ['∝', , '', '', '∝', '∝', '∝', '', '', 'proportional to U+221D (8733) ∝' ], + ['∞', , '', '', '∞', '∞', '∞', '', '', 'infinity U+221E (8734) ∞' ], ] end end diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 6b1491c2..bf23f91f 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -267,7 +267,7 @@ module SiSU_ODF #para.gsub!(/\b((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, also works #%{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}\\2}) #http ftp matches with decoration para.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, - %{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}}) + %{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}}) if para !~/http:\/\// # improve upon, document crash where url contains '@' symbol para=case para when /^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/m m=$1 @@ -443,6 +443,7 @@ module SiSU_ODF #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ para_array=[] + para.gsub!(//,'>') word=para.scan(/\S+|\n/) if word word.each do |w| # _ - / # | : ! ^ ~ @@ -487,8 +488,10 @@ module SiSU_ODF para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') para.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') para.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - para.gsub!(/`/,"'") + para.gsub!(/[`’]/,"'") para.gsub!(/­/u,'-') + para.gsub!(/ /u, ' ') # space identify + para.gsub!(/ /u, ' ') # space identify para.gsub!(/·/u,'*') para.gsub!(/[“”]/u,'""') para.gsub!(/[­–—]/u,'-') #— – chk diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 3cfbf1e5..b211f5c1 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -368,32 +368,32 @@ module SiSU_Param @dc_date_modified=date @date_modified_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/ end - when /^(?:0~type|@type:)\s+(.+?)$/m; @dc_type=$1 #% metainfo DC - when /^(?:0~format|@format:)\s+(.+?)$/m; @dc_format=$1 #% metainfo DC - #when /^(?:0~identifier|@identifier:)\s+(.+?)$/m; @dc_identifier=$1 #% metainfo DC - when /^(?:0~source|@source:)\s+(.+?)$/m; @dc_source=$1 #% metainfo DC - when /^(?:0~language(?:\.document)?|@language(?:\.document)?:)\s+(.+?)$/m #% metainfo DC + when /^(?:0~type|@type:)\s+(.+?)$/m; @dc_type=$1 #% metainfo DC + when /^(?:0~format|@format:)\s+(.+?)$/m; @dc_format=$1 #% metainfo DC + #when /^(?:0~identifier|@identifier:)\s+(.+?)$/m; @dc_identifier=$1 #% metainfo DC + when /^(?:0~source|@source:)\s+(.+?)$/m; @dc_source=$1 #% metainfo DC + when /^(?:0~language(?:\.document)?|@language(?:\.document)?:)\s+(.+?)$/m #% metainfo DC x=$1.strip lang=SiSU_Env::Standardise_language.new(x.dup) @dc_language[:code]=lang.code @dc_language[:name]=lang.title - when /^(?:0~language\.original|@language\.original:)\s+(.+?)$/m #% metainfo DC + when /^(?:0~language\.original|@language\.original:)\s+(.+?)$/m #% metainfo DC x=$1.strip lang=SiSU_Env::Standardise_language.new(x.dup) @language_original[:name]=lang.title - when /^(?:0~relation|@relation:)\s+(.+?)$/m; @dc_relation=$1 #% metainfo DC - when /^(?:0~coverage|@coverage:)\s+(.+?)$/m; @dc_coverage=$1 #% metainfo DC - when /^(?:0~rights|@rights:)\s+(.+?)$/m; @dc_rights=$1 #% metainfo DC copyright, public domain, copyleft, creative commons, etc. - when /^(?:0~papersize|@papersize:)\s+(.+?)$/m #% metainfo DC + when /^(?:0~relation|@relation:)\s+(.+?)$/m; @dc_relation=$1 #% metainfo DC + when /^(?:0~coverage|@coverage:)\s+(.+?)$/m; @dc_coverage=$1 #% metainfo DC + when /^(?:0~rights|@rights:)\s+(.+?)$/m; @dc_rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. + when /^(?:0~papersize|@papersize:)\s+(.+?)$/m #% metainfo DC l=$1 if @mod.inspect !~/--papersize[=-]\S+/ l=determine_papersize(l.dup) @papersize=l end - when /^(?:0~keywords?|@keywords?:?)\s+(.+?)$/m; @keywords=$1 #% metainfo DC - when /^(?:0~comments?|@comments?:?)\s+(.+?)$/m; @comments=$1 #% metainfo DC - when /^(?:0~abstract|@abstract)\s+(.+?)$/m; @abstract=$1 #% metainfo DC - when /^(?:0~tags?|@tags?:)\s+\S/m #% metainfo + when /^(?:0~keywords?|@keywords?:?)\s+(.+?)$/m; @keywords=$1 #% metainfo DC + when /^(?:0~comments?|@comments?:?)\s+(.+?)$/m; @comments=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC + when /^(?:0~abstract|@abstract)\s+(.+?)$/m; @abstract=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC + when /^(?:0~tags?|@tags?:)\s+\S/m #% metainfo tags=para.match(/^(?:0~tags?|@tags?:)\s+(.+)\Z/m)[1] tags.split(/,|$/).each do |tag| tag.strip! @@ -403,18 +403,18 @@ module SiSU_Param tag_a=tag_a.split(/:/).join('][') @tag_a << tag_a end - when /^(?:0~catalogue|@catalogue:)\s+(.+)?$/m #% metainfo + when /^(?:0~catalogue|@catalogue:)\s+(.+)?$/m #% metainfo m=$1 @cls_pg=m.match(/pg=(\S+)/)[1] if m =~/pg=/ @cls_isbn=m.match(/isbn=(\S+)/)[1] if m =~/isbn=/ @cls_dewey=m.match(/dewey=(\S+)/)[1] if m =~/dewey=/ @cls_loc=m.match(/loc=(\S+)/)[1] if m =~/loc=/ - when /^(?:0~class(?:ify)?_loc|@class(?:ify)?_loc:)\s+(.+?)$/m; @cls_loc=$1 #% metainfo - when /^(?:0~class(?:ify)?_dewey|@class(?:ify)?_dewey:)\s+(.+?)$/m; @cls_dewey=$1 #% metainfo - when /^(?:0~class(?:ify)?_pg|@class(?:ify)?_pg)\s+(.+?)$/m; @cls_pg=$1 #% metainfo - when /^(?:0~(?:class(?:ify)?_)?isbn|@(?:class(?:ify)?_)?isbn)\s+(\S+?)$/m; @cls_isbn=$1 #% metainfo - when /^(?:0~images?|@images?:)\s+(.+?)$/m; @image=$1 #% processing - when /^(?:0~(?:toc|structure)|@(?:toc|structure):)\s+(.+?)\Z/m #% processing + when /^(?:0~class(?:ify)?_loc|@class(?:ify)?_loc:)\s+(.+?)$/m; @cls_loc=$1 #% metainfo + when /^(?:0~class(?:ify)?_dewey|@class(?:ify)?_dewey:)\s+(.+?)$/m; @cls_dewey=$1 #% metainfo + when /^(?:0~class(?:ify)?_pg|@class(?:ify)?_pg)\s+(.+?)$/m; @cls_pg=$1 #% metainfo + when /^(?:0~(?:class(?:ify)?_)?isbn|@(?:class(?:ify)?_)?isbn)\s+(\S+?)$/m; @cls_isbn=$1 #% metainfo + when /^(?:0~images?|@images?:)\s+(.+?)$/m; @image=$1 #% processing + when /^(?:0~(?:toc|structure)|@(?:toc|structure):)\s+(.+?)\Z/m #% processing doc_toc_str=$1 @toc=doc_toc_str.split(/;\s*/) @toc=[ @toc ] if @toc == String diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 9203f0df..228a5c14 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -166,6 +166,8 @@ module SiSU_XML_munge #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷ ##para.gsub!(//, '&#;') ##para.gsub!(//, '&;') + para.gsub!(//u, '>') # '>' # > para.gsub!(/¢/u, '¢') # '¢' # ¢ para.gsub!(/£/u, '£') # '£' # £ para.gsub!(/¥/u, '¥') # '¥' # ¥ @@ -250,10 +252,23 @@ module SiSU_XML_munge para.gsub!(/ü/u, 'ý') # 'ü' # ý para.gsub!(/þ/u, 'þ') # 'þ' # þ para.gsub!(/ÿ/u, 'ÿ') # 'ÿ' # ÿ + para.gsub!(/‘/u, '‘') # '‘' # ‘ + para.gsub!(/’/u, '’') # '’' # ’ + para.gsub!(/–/u, '–') # – # – + para.gsub!(/—/u, '—') # — # — + para.gsub!(/∝/u, '∝') # ∝ # ∝ + para.gsub!(/∞/u, '∞') # ∞ # ∞ + para.gsub!(/™/u, '™') # ™ # ™ + para.gsub!(/✠/u, '†') # † # † incorrect replacement! † + para.gsub!(/ /u, ' ') # space identify + para.gsub!(/ /u, ' ') # space identify end end def html(para='') if @sys.locale =~/utf-?8/i # instead ucs for utf8 #require 'iconv' ? Iñtërnâtiônàlizætiøn + para.gsub!(/ /u, ' ') # space identify + para.gsub!(/ /u, ' ') # space identify + else para.gsub!(/¢/u, '¢') # ¢ para.gsub!(/£/u, '£') # £ para.gsub!(/¥/u, '¥') # ¥ @@ -338,6 +353,16 @@ module SiSU_XML_munge para.gsub!(/ü/u, 'ü') # ý para.gsub!(/þ/u, 'þ') # þ para.gsub!(/ÿ/u, 'ÿ') # ÿ + para.gsub!(/‘/u, '&#lsquo;') # ‘ # ‘ + para.gsub!(/’/u, '&#rsquo;') # ’ # ’ + para.gsub!(/–/u, '–') # – # – + para.gsub!(/—/u, '—') # — # — + para.gsub!(/∝/u, '∝') # ∝ # ∝ + para.gsub!(/∞/u, '∞') # ∞ # ∞ + para.gsub!(/™/u, '™') # ™ # ™ + para.gsub!(/✠/u, '†') # † # † incorrect replacement † + para.gsub!(/ /u, ' ') # space identify + para.gsub!(/ /u, ' ') # space identify end end self @@ -381,6 +406,10 @@ module SiSU_XML_munge %{[\\1] \\4}) para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?#{Mx[:lnk_c]}(https?:\/\/\S+)/, %{\\1}) + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, + %{[\\1] \\4}) + para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?#{Mx[:lnk_c]}image/, + %{\\1}) para.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/, '\1\2\4') #watch, compare html_tune para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 95da5d2d..5f99cacf 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -267,8 +267,8 @@ WOK (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @xml_contents_close[x]='' } data.each do |para| - para=@trans.markup(para) @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 + para=@trans.markup(para) if para =~/^#{Rx[:meta]}\s*.+?$/ # for headers d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta if d_meta; xml_head(d_meta) diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 4826a503..49c71b88 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -291,8 +291,8 @@ WOK (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @xml_contents_close[x]='' } data.each do |para| - para=@trans.markup(para) @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 + para=@trans.markup(para) if para =~/^#{Rx[:meta]}\s*.+?$/ # for headers d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta if d_meta; xml_head(d_meta) diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index b2bc0de7..13aed504 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -349,8 +349,8 @@ WOK (0..6).each { |x| @cont[x]=@level[x]=false } (4..6).each { |x| @xml_contents_close[x]='' } data.each do |para| - para=@trans.markup(para) @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 + para=@trans.markup(para) if para =~/^#{Rx[:meta]}\s*(.+?)$/ # for headers d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta if d_meta; xml_head(d_meta) -- cgit v1.2.3 From fc826abef5f83543f2cf00938b6d656e3b2c2821 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 3 Sep 2008 22:40:23 -0400 Subject: dal, left and right quotes (single & double) kept; previously converted to ordinary quotes (watch) --- lib/sisu/v0/dal.rb | 4 ---- lib/sisu/v0/shared_xml.rb | 12 +++++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index a8bf1cd0..e75309f9 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -240,13 +240,9 @@ module SiSU_DAL para.gsub!(/(#{Mx[:en_a_o]})\s*/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') para.gsub!(/ \/\//,"#{Mx[:br_line]}") #added 2004w29 para.gsub!(/
    /,"#{Mx[:br_line]}") #needed by xml, xhtml etc. - #para.gsub!(/

    /,'

    ') #consider - para.gsub!(/`/,"'") para.gsub!(/\t/,' ') para.gsub!(/\342\200\231/u,"'") #if para =~/’/ #Avoid #‘ ’ #“ ” para.gsub!(/�/u,' ') #watch, replace with char code - para.gsub!(/[“”]/u,'""') - para.gsub!(/[­–—]/u,'-') #— – chk para.gsub!(/·/u,'*') para.gsub!(/\\copy(?:right)?\b/,'©') para.gsub!(/\\trademark\b|\\tm\b/,'®') diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 228a5c14..7ecc52bb 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -254,6 +254,8 @@ module SiSU_XML_munge para.gsub!(/ÿ/u, 'ÿ') # 'ÿ' # ÿ para.gsub!(/‘/u, '‘') # '‘' # ‘ para.gsub!(/’/u, '’') # '’' # ’ + para.gsub!(/“/u, '“') # “ # “ + para.gsub!(/”/u, '”') # ” # ” para.gsub!(/–/u, '–') # – # – para.gsub!(/—/u, '—') # — # — para.gsub!(/∝/u, '∝') # ∝ # ∝ @@ -355,6 +357,8 @@ module SiSU_XML_munge para.gsub!(/ÿ/u, 'ÿ') # ÿ para.gsub!(/‘/u, '&#lsquo;') # ‘ # ‘ para.gsub!(/’/u, '&#rsquo;') # ’ # ’ + para.gsub!(/“/u, '“') # “ # “ + para.gsub!(/”/u, '”') # ” # ” para.gsub!(/–/u, '–') # – # – para.gsub!(/—/u, '—') # — # — para.gsub!(/∝/u, '∝') # ∝ # ∝ @@ -369,11 +373,13 @@ module SiSU_XML_munge end def tidywords(wordlist) wordlist.each do |x| + #imperfect solution will not catch all possible cases x.gsub!(/&/,'&') unless x =~/&\S+;/ + x.gsub!(/&([A-Z])/,'&\1') end end def markup(para='') - wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 + wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 para=tidywords(wordlist).join(' ').strip para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
    ') para.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') @@ -439,7 +445,7 @@ module SiSU_XML_munge "#{@dir.url.images_local}\/\\1") para.gsub!(/ /,' ') #para.gsub!(/ /,' ') #clean - wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 + wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 para=tidywords(wordlist).join(' ').strip para end @@ -462,7 +468,7 @@ module SiSU_XML_munge "#{@dir.url.images_local}\/\\1") para.gsub!(/ /,' ') #para.gsub!(/ /,' ') #clean - wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 + wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 para=tidywords(wordlist).join(' ').strip para end -- cgit v1.2.3 From 7c96df7fc4f45f820d74421d60bdcd61a10d3709 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 5 Sep 2008 00:59:01 -0400 Subject: dal, bullet footnotes fix (check numbered bullets, should also be ok) --- lib/sisu/v0/dal.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index e75309f9..6bfbd76e 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -237,7 +237,7 @@ module SiSU_DAL para.gsub!(/<~#>|~#\s*/,"#{Mx[:fa_o]}~##{Mx[:fa_c]}") para.gsub!(/-#\s*/,"#{Mx[:fa_o]}-##{Mx[:fa_c]}#{Mx[:fa_o]}~##{Mx[:fa_c]}") #para.gsub!(/(#\{{3} arch-tag:|0\{{3}~cvs)\s+/, "0{{~rcs ") #KEEP ... ENABLE WIDER USE OF REVISION CONTROL - para.gsub!(/(#{Mx[:en_a_o]})\s*/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') + para.gsub!(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') para.gsub!(/ \/\//,"#{Mx[:br_line]}") #added 2004w29 para.gsub!(/
    /,"#{Mx[:br_line]}") #needed by xml, xhtml etc. para.gsub!(/\t/,' ') @@ -848,7 +848,7 @@ module SiSU_DAL unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ case para # auto-numbered endnotes --> - when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+].+?#{Mx[:en_b_c]}/ + when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) word_mode=endnote_call_number(word_mode) @@ -872,15 +872,15 @@ module SiSU_DAL case word when /#{Mx[:en_a_o]}/ unless word =~/#{Mx[:en_a_o]}[*+]+/ - word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@@endnote_counter}") + word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@@endnote_counter} ") @@endnote_counter+=1 end when /#{Mx[:en_b_o]}/ if word =~/#{Mx[:en_b_o]}[+]/ - word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@@endnote_counter_dag}") + word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@@endnote_counter_dag} ") @@endnote_counter_dag+=1 else - word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@@endnote_counter_asterisk}") + word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@@endnote_counter_asterisk} ") @@endnote_counter_asterisk+=1 end when /~\^|<:e>/ -- cgit v1.2.3 From 9432d0345a982f2c64c684cc913b704cca5660f5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 5 Sep 2008 01:24:49 -0400 Subject: character given to represent non-break space in internal code (dal, constants and affected downstream code) --- lib/sisu/v0/constants.rb | 2 +- lib/sisu/v0/dal.rb | 18 +++++++------- lib/sisu/v0/dal_doc_str_code.rb | 2 +- lib/sisu/v0/dal_syntax.rb | 45 +++++++++++++++++----------------- lib/sisu/v0/db_import.rb | 2 +- lib/sisu/v0/html_tune.rb | 1 + lib/sisu/v0/manpage.rb | 6 ++--- lib/sisu/v0/odf.rb | 7 +----- lib/sisu/v0/shared_xml.rb | 8 +++--- lib/sisu/v0/spell.rb | 3 ++- lib/sisu/v0/sst_do_inline_footnotes.rb | 2 +- lib/sisu/v0/sst_to_s_xml_dom.rb | 2 +- lib/sisu/v0/texinfo_format.rb | 3 +-- lib/sisu/v0/texpdf_format.rb | 8 +++--- lib/sisu/v0/wikispeak.rb | 2 +- 15 files changed, 54 insertions(+), 57 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index 2c08bdfa..96878fcf 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -90,6 +90,7 @@ Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}" #non substantive text sort: <-#> <~#> Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph) Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) +Mx[:nbsp]= '▭ ' Mx[:br_line]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_paragraph]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_nl]= "#{Mx[:mk_o]}nl#{Mx[:mk_c]}" @@ -172,4 +173,3 @@ check: ▶this is text or an image◀http:// ◀this is text or an image▶ http:// - diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 6bfbd76e..25b7528e 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -407,14 +407,14 @@ module SiSU_DAL if describe tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry if describe =~/^~\^ / - "     {#{describe} }#{@u.remote}/#{url_dir}/#{o_f} " + "#{Mx[:nbsp]*4} {#{describe} }#{@u.remote}/#{url_dir}/#{o_f} " else - "     { #{describe} }#{@u.remote}/#{url_dir}/#{o_f} " + "#{Mx[:nbsp]*4} { #{describe} }#{@u.remote}/#{url_dir}/#{o_f} " end else if describe =~/^~\^ / - "     {#{describe} }../#{url_dir}/#{o_f} " - else "     { #{describe} }../#{url_dir}/#{o_f} " + "#{Mx[:nbsp]*4} {#{describe} }../#{url_dir}/#{o_f} " + else "#{Mx[:nbsp]*4} { #{describe} }../#{url_dir}/#{o_f} " end end end @@ -428,13 +428,13 @@ module SiSU_DAL if describe tuned_file_tmp << if @u.remote x=if describe =~/zip/ - "     {#{describe} }#{@u.src_pod}/#{o_f} " - else "     {#{describe} }#{@u.src_txt}/#{o_f} " + "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_pod}/#{o_f} " + else "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_txt}/#{o_f} " end else x=if describe =~/zip/ - "     { #{describe} }../pod/#{o_f} " - else "     { #{describe} }../zip/#{o_f} " + "#{Mx[:nbsp]*4} { #{describe} }../pod/#{o_f} " + else "#{Mx[:nbsp]*4} { #{describe} }../zip/#{o_f} " end end end @@ -1137,7 +1137,7 @@ module SiSU_DAL #% same as db clean --> s=s.gsub(/(.+?)<\/del>/,'DELETED(\1)') # deletions s=s.gsub(/(\d+)<\/sup>/,'[\1]') - s=s.gsub(/(?: \\;)+/,' ') + s=s.gsub(/(?:#{Mx[:nbsp]})+/,' ') #s=s.gsub(//,"[TABLE]\n") # tables #s=s.gsub(//,'\1') # tables #s=s.gsub(/¡¡\d+¡/,' ') # tables diff --git a/lib/sisu/v0/dal_doc_str_code.rb b/lib/sisu/v0/dal_doc_str_code.rb index 82ada040..27e20d51 100644 --- a/lib/sisu/v0/dal_doc_str_code.rb +++ b/lib/sisu/v0/dal_doc_str_code.rb @@ -170,7 +170,7 @@ module SiSU_document_structure_code data.each do |line| if line =~/\S/ \ and line !~/^code\{|^\}code|#{Mx[:gr_o]}code.+/ - line.gsub!(/\s\s/,'  ') + line.gsub!(/\s\s/,"#{Mx[:nbsp]}#{Mx[:nbsp]}") line.gsub!(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # try sort for texpdf special case if line =~/(?:https?|file|ftp):\/\/\S+$/ line.gsub!(/$/," #{Mx[:br_nl]}") diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 8e439870..acdec0e4 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -260,6 +260,7 @@ module SiSU_Syntax 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!(/ /,"#{Mx[:nbsp]}") #escaped special character 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 @@ -298,31 +299,31 @@ module SiSU_Syntax #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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)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[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics # depreciated ^ - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\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!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{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!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|\(|\>|\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+|['"]|#{Mx[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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[:nbsp]}|#{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!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{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 @@ -355,7 +356,7 @@ module SiSU_Syntax line.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert

    back, clumsy 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") + line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") else # 0~ end line diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 52bb3ad2..f02ccd3f 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -147,7 +147,7 @@ module SiSU_DB_import def strip_markup(string) #define rules, make same as in dal clean string.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') string.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/,'') - string.gsub!(/(?: \\;)+/,' ') + string.gsub!(/(?: \\;|#{Mx[:nbsp]})+/,' ') string.gsub!(/#{Mx[:gr_o]}T[h]?#{Mx[:tc_p]}.+?#{Mx[:gr_c]}/u,"[TABLE]\n") #tables #CHECK should take whole table string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1') #tables string.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' ') #tables diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index f06b8764..99f2d7f4 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -245,6 +245,7 @@ module SiSU_Tune para.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'
    ') + para.gsub!(/#{Mx[:nbsp]}/,' ') para.gsub!(/<(p|br)>/,'<\1 />') para=SiSU_Tune::Clean_html.new(para).clean @tuned_file << para diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index 77d6e408..597099ed 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -144,7 +144,7 @@ module SiSU_manpage end wrap=util.line_wrap if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m - wrap.gsub!(/(^| |\s|\*)\\\*/,'\1\\\\\*') #man page requires + wrap.gsub!(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*') #man page requires wrap.gsub!(/\s\.(\S+)/,' \\.\1') wrap.gsub!(/(["''])/,"\\\\\\1") # quotation marks need escape wrap.gsub!(/^\s*([\d*+]+)\s+(.+?)\s*\Z/m, <<\s]+?)([.,]?(?:\s|$))/,'\1\2\3') para.gsub!(/(.+?)<\/a>/m,'\1') para.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links - para.gsub!(/ /,' ') # decide on + para.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on para.gsub!(/(["''])/,"\\\\\\1") # quotation marks need escape para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") para.gsub!(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index bf23f91f..d6558634 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -307,7 +307,7 @@ module SiSU_ODF para end def group_clean(para) - para.gsub!(/&nbsp;| /,' ') + para.gsub!(/&nbsp;| |#{Mx[:nbsp]}/,' ') para.gsub!(//,'>') para.gsub!(/<(text:span text:style-name="T[1-5]"|\/text:span)>/,'<\1>') #works, not ideal para.gsub!(/#{Mx[:br_line]}/,'
    ') @@ -447,9 +447,6 @@ module SiSU_ODF word=para.scan(/\S+|\n/) if word word.each do |w| # _ - / # | : ! ^ ~ - unless w =~/#{Mx[:id_o]}~\S+?;\S+?;\S+?#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|#{Mx[:gr_o]}.+?#{Mx[:gr_c]}|<[:!][^<>]+?>/ - w.gsub!(/^<([^<>][^<>][^<>][^<>]+?)>$/,'<\1>') #refix - end unless para =~/^(?:#{Rx[:meta]}|%+ )/m w.gsub!(/&#(?:126|152);/,'~') #126 usual if w !~/&\S{1,7};/ \ @@ -488,12 +485,10 @@ module SiSU_ODF para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') para.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') para.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - para.gsub!(/[`’]/,"'") para.gsub!(/­/u,'-') para.gsub!(/ /u, ' ') # space identify para.gsub!(/ /u, ' ') # space identify para.gsub!(/·/u,'*') - para.gsub!(/[“”]/u,'""') para.gsub!(/[­–—]/u,'-') #— – chk para.gsub!(/ < /i,'<') para.gsub!(/\\copy(?:right)?\b/,'©') diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 7ecc52bb..437f5482 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -422,12 +422,12 @@ module SiSU_XML_munge %{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, '\1\2') #escaped urls not linked, deal with later - para.gsub!(/ /,' ') + para.gsub!(/ |#{Mx[:nbsp]}/,' ') #para.gsub!(/ /,' ') #clean else para.gsub!(/(^|[^}])_/m,'\1>') #code-block: angle brackets special characters para.gsub!(/(^|[^}])_/m,'\1>') - para.gsub!(/ /,' ') + para.gsub!(/ |#{Mx[:nbsp]}/,' ') end para end @@ -443,7 +443,7 @@ module SiSU_XML_munge para.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, "#{@dir.url.images_local}\/\\1") - para.gsub!(/ /,' ') + para.gsub!(/ |#{Mx[:nbsp]}/,' ') #para.gsub!(/ /,' ') #clean wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 para=tidywords(wordlist).join(' ').strip @@ -466,7 +466,7 @@ module SiSU_XML_munge para.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, "#{@dir.url.images_local}\/\\1") - para.gsub!(/ /,' ') + para.gsub!(/ |#{Mx[:nbsp]}/,' ') #para.gsub!(/ /,' ') #clean wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 para=tidywords(wordlist).join(' ').strip diff --git a/lib/sisu/v0/spell.rb b/lib/sisu/v0/spell.rb index 477a472f..8f89c470 100644 --- a/lib/sisu/v0/spell.rb +++ b/lib/sisu/v0/spell.rb @@ -72,7 +72,8 @@ module Utility end def check @input.each do |data| - data.gsub!(/(https?|www|ftp|gopher|png|jpg|gif|html|htm| )\S+/i,' ') + data.gsub!(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' ') + data.gsub!(/( |#{Mx[:nbsp]})/i,' ') data.gsub!(/<\/?(table|tr|td|b|p|href).*?>/i,' ') data.gsub!(/(<==.+|<:\S+>||^0~.+|\{\{\{|~)/,' ') data.gsub!(/(["|<>)(\n'`'.;&_-]|\=)/,' ') diff --git a/lib/sisu/v0/sst_do_inline_footnotes.rb b/lib/sisu/v0/sst_do_inline_footnotes.rb index ba1f6379..514eb2c8 100644 --- a/lib/sisu/v0/sst_do_inline_footnotes.rb +++ b/lib/sisu/v0/sst_do_inline_footnotes.rb @@ -473,7 +473,7 @@ module SiSU_Convert_footnotes #% same as db clean --> s=s.gsub(/(.+?)<\/del>/,'DELETED(\1)') # deletions s=s.gsub(/(\d+)<\/sup>/,'[\1]') - s=s.gsub(/(?: \\;)+/,' ') + s=s.gsub(/(?: \\;|#{Mx[:nbsp]})+/,' ') #checking source Mx not necessary s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search s=s.gsub(/\s\s+/,' ') diff --git a/lib/sisu/v0/sst_to_s_xml_dom.rb b/lib/sisu/v0/sst_to_s_xml_dom.rb index efb60a88..30dc370a 100644 --- a/lib/sisu/v0/sst_to_s_xml_dom.rb +++ b/lib/sisu/v0/sst_to_s_xml_dom.rb @@ -367,7 +367,7 @@ WOK "#{dir.url.images_local}/\\1") para.gsub!(/#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, "#{dir.url.images_local}/\\1") - para.gsub!(/ /,' ') + para.gsub!(/ |#{Mx[:nbsp]}/,' ') # checking source Mx not necessary para=SiSU_document_structure::Structure.new(@md,para).structure @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 para.gsub!(/^0~(\S+)/,"#{Mx[:lv_o]}@\\1#{Mx[:lv_c]}") diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index cdfa6a75..22fd7a84 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -367,8 +367,7 @@ WOK @txt.gsub!(/@/i,'@@') @txt.gsub!(/\{/,'@{'); @txt.gsub!(/\}/,'@}') #@txt.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @txt.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') - @txt.gsub!(/  /,' ') # ~ character for hardspace - @txt.gsub!(/ /,' ') # ~ character for hardspace + @txt.gsub!(/(?: |#{Mx[:nbsp]})+/,' ') # ~ character for hardspace @txt.gsub!(/&(\S+?);/,' ') @txt.gsub!(/&/,'<=and>') @txt.gsub!(/(\s+&\s+)/,' and ') diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index b6a1e1f2..58a057d8 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -987,7 +987,7 @@ WOK string.gsub!(/.+?<-#>/,'') string.gsub!(/#{Mx[:br_eof]}|#{Mx[:br_endnotes]}/,'') #problem sequence -> - string.gsub!(/&(?:nbsp);/,'<=hardspace>') # < SiSU special character also LaTeX + string.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'<=hardspace>') # < SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#nbsp#{Mx[:gl_c]}/,'<=hardspace>') # < SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<=lt>') # < SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'<=gt>') # > SiSU special character also LaTeX @@ -1027,7 +1027,7 @@ WOK end string.gsub!(/\{/,'\{') #string.gsub!(/\}/,'\}') - string.gsub!(/ /,'~') # ~ character for hardspace + string.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace # sequence important must appear after removal of { and } string.gsub!(/&\S+?;/,'') #hmmm # sequence imortant place before removal of & @@ -1155,7 +1155,7 @@ WOK string.gsub!(/#{Mx[:br_endnotes]}/,'') #string.gsub!(//,'') #problem sequence -> - string.gsub!(/&(?:nbsp);/,'<=hardspace>') # < SiSU special character also LaTeX + string.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'<=hardspace>') # < SiSU special character also LaTeX string.gsub!(/&(?:lt|#060);/,'<=lt>') # < SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'<=gt>') # > SiSU special character also LaTeX #string.gsub!(/#{Mx[:gl_o]}(&#(?:[a-z]+|[0-9]+);)#{Mx[:gl_c]}/,'\1') @@ -1194,7 +1194,7 @@ WOK end string.gsub!(/\{/,'\{') string.gsub!(/\}/,'\}') - string.gsub!(/ /,'~') # ~ character for hardspace + string.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace # sequence important must appear after removal of { and } string.gsub!(/&\S+?;/,'') #hmmm # sequence imortant place before removal of & diff --git a/lib/sisu/v0/wikispeak.rb b/lib/sisu/v0/wikispeak.rb index 0e8d3989..d9cb3cbd 100644 --- a/lib/sisu/v0/wikispeak.rb +++ b/lib/sisu/v0/wikispeak.rb @@ -260,7 +260,7 @@ WOK para.gsub!(/^\s*#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') # remove empty lines - check para.gsub!(/
    (.+?)<\/a>/m,'\1') para.gsub!(/<:name#\S+?>/,'') # remove name links - para.gsub!(/ /,' ') # decide on + para.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') #para.gsub!(/^\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') -- cgit v1.2.3 From e46264082eaca056dddabf4f1d02732a88a305e8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 7 Sep 2008 14:07:18 -0400 Subject: minor unicode for a type of cross --- lib/sisu/v0/constants.rb | 2 -- lib/sisu/v0/shared_xml.rb | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index 96878fcf..f352ab7c 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -170,6 +170,4 @@ check: '〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' ◁▷ -▶this is text or an image◀http:// - ◀this is text or an image▶ http:// diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 437f5482..bf59830f 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -261,7 +261,7 @@ module SiSU_XML_munge para.gsub!(/∝/u, '∝') # ∝ # ∝ para.gsub!(/∞/u, '∞') # ∞ # ∞ para.gsub!(/™/u, '™') # ™ # ™ - para.gsub!(/✠/u, '†') # † # † incorrect replacement! † + para.gsub!(/✠/u, '✠') # ✗ # ✠ para.gsub!(/ /u, ' ') # space identify para.gsub!(/ /u, ' ') # space identify end @@ -364,7 +364,8 @@ module SiSU_XML_munge para.gsub!(/∝/u, '∝') # ∝ # ∝ para.gsub!(/∞/u, '∞') # ∞ # ∞ para.gsub!(/™/u, '™') # ™ # ™ - para.gsub!(/✠/u, '†') # † # † incorrect replacement † + para.gsub!(/✠/u, '✠') # ✠ + #para.gsub!(/✠/u, '†') # † # † incorrect replacement † para.gsub!(/ /u, ' ') # space identify para.gsub!(/ /u, ' ') # space identify end -- cgit v1.2.3 From 3655940354be602e6e69e1e8445d157bcb89c965 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 7 Sep 2008 23:16:47 -0400 Subject: book index (markup adjustment, dal module); dal numbering moved to separate module; version date --- lib/sisu/v0/constants.rb | 1 + lib/sisu/v0/dal.rb | 335 +------------------------------------- lib/sisu/v0/dal_idx.rb | 201 +++++++++++++++++++++++ lib/sisu/v0/dal_numbering.rb | 374 +++++++++++++++++++++++++++++++++++++++++++ lib/sisu/v0/dal_syntax.rb | 2 +- lib/sisu/v0/param.rb | 7 +- lib/sisu/v0/plaintext.rb | 2 +- 7 files changed, 589 insertions(+), 333 deletions(-) create mode 100644 lib/sisu/v0/dal_idx.rb create mode 100644 lib/sisu/v0/dal_numbering.rb (limited to 'lib') diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index f352ab7c..3f050df7 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -90,6 +90,7 @@ Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}" #non substantive text sort: <-#> <~#> Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph) Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) +Mx[:idx_o]='▢ '; Mx[:idx_c]='▢ ' # Mx[:nbsp]= '▭ ' Mx[:br_line]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_paragraph]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 25b7528e..aa4758b7 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -65,6 +65,8 @@ module SiSU_DAL require "#{SiSU_lib}/param" require "#{SiSU_lib}/dal_syntax" require "#{SiSU_lib}/dal_doc_str" + require "#{SiSU_lib}/dal_idx" + require "#{SiSU_lib}/dal_numbering" require "#{SiSU_lib}/i18n" require "#{SiSU_lib}/shared_sem" include SiSU_Env @@ -211,7 +213,8 @@ module SiSU_DAL data=character_check(data) data=images(data) data=SiSU_document_structure::Tables.new(@md,data).tables - data=numbering_song(data) #tr issue + data=SiSU_numbering::Numbering.new(@md,data).numbering_song + data=SiSU_book_index::Book_index.new(data).indexing_song if @md.book_index data=endnotes(data) data=object_digest(data) meta=metadata(data) @@ -449,7 +452,7 @@ module SiSU_DAL end def substitutions_and_insertions?(data) data_expand=[] - if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content preceeds it) + if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'') data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'') end @@ -507,332 +510,6 @@ module SiSU_DAL end end end - def numbering_song(data) - data=number_plaintext_para(data) - data=name_endnote_seg(data) #tr issue - data=auto_number_heading_ie_title(data) #tr issue - data=ocn(data) #watch - data=minor_numbering(data) - data=name_para_seg_filename(data) - data=set_heading_seg(data) unless @md.set_heading_seg - data=set_heading_top(data) unless @md.set_heading_top - data=set_header_title(data) unless @md.set_header_title - data - end - def number_plaintext_para(data) - @tuned_file=[] - data.each do |para| - if para !~/#{Mx[:gr_o]}(?:code|group|alt|poem|verse)#{Mx[:gr_c]}|#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ - para.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks - end - para.gsub!(/^/,"\n") unless para =~/#{Mx[:tc_p]}/u - para.gsub!(/^\s+|\s$/,"\n") - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - def name_endnote_seg(data) - @tuned_file=[] - data.each do |para| - para.gsub!(/<:3>\s*<:ee>/, <<-WOK -#{@@endnote['special_align']}


    \r -#{@@endnote['seg_name_3']}

    -#{@@endnote['special_align_close']} - WOK - ) - para.gsub!(/<:2>\s*<:ee>/, <<-WOK -#{@@endnote['special_align']}


    \r -#{@@endnote['seg_name_2']}

    -#{@@endnote['special_align_close']} - WOK - ) - para.gsub!(/<:1>\s*<:ee>/, <<-WOK -#{@@endnote['special_align']}


    \r -#{@@endnote['seg_name_1']}

    -#{@@endnote['special_align_close']} - WOK - ) - @tuned_file << para - end - # debug 2003w46 adding revision control info - if @md.flag_auto_endnotes \ - and @md.flag_separate_endnotes_make - @tuned_file << "\n#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}Endnotes #{Mx[:gl_o]}-##{Mx[:gl_c]} #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" - end - @tuned_file << "\n#{Mx[:br_endnotes]}" #DECIDE ON - @tuned_file=@tuned_file.flatten - end - def owner_details_seg - data << "#{Mx[:lv_o]}4:owner.details#{Mx[:lv_c]}Owner Details" - end - def number_sub_heading(para,num,title_no) - case para - when /#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/; para.gsub!(/#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/,"#{title_no} ") - when /^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/; para.gsub!(/^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/,"#{title_no} ") - when /^#{Mx[:lv_o]}#{num}:[a-z_\.]+#{Mx[:lv_c]}/ - para.gsub!(/^#{Mx[:lv_o]}#{num}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i,%{#{Mx[:lv_o]}#{num}:\\1#{Mx[:lv_c]} #{title_no} \\2 #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) - when /^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}\s*#{title_no}/ - para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]}") #where title contains title number - else para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]} #{title_no} ") #main, where title number is to be provided - end - if @md.toc_lev_limit \ - and @md.toc_lev_limit < num - para.gsub!(/^#{Mx[:lv_o]}[5-9]:\S*?#{Mx[:lv_c]}/,'!_ ') #bold line, watch - end - para - end - def auto_number_heading_ie_title(data) #also does some segment naming - @tuned_file=[] - if @md.markup =~/num_top/ \ - or @md.num_top # watch, 2003w23 - input="#{@md.markup}"[/num_top\=([1-6])/,1] if @md.markup - input||=@md.num_top if @md.num_top !~/^$/ - end - num_top=input.to_i - t_no1=t_no2=t_no3=t_no4=0 - no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3) - t_not=0 - data.each do |para| #@md.seg_names << [additions to segment names] - if (@md.markup =~/num_top/ \ - or (@md.num_top \ - and @md.num_top !~/^$/)) \ - and para !~/^#{Rx[:meta]}/ - if (para =~/^(?:#{no1}|^#{no2}|^#{no3}#{no4})~#/ \ - and para !~/^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}/) - t_not+=1 #; t_no2=0; t_no3=0 - para.gsub!(/^(#{Mx[:lv_o]}#{no1}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") - para.gsub!(/^(#{Mx[:lv_o]}#{no2}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") - para.gsub!(/^(#{Mx[:lv_o]}#{no3}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") - para.gsub!(/^(#{Mx[:lv_o]}#{no4}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") - end - if para =~/#{Mx[:lv_o]}#{no1}:/ - @subnumber=1 - @subnumber=0 if para =~/#{Mx[:lv_o]}#{no1}:/ - end - if para =~/^#{Mx[:lv_o]}[1-6]:[\w-]*#{Mx[:lv_c]}/ \ - and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s*[\d.]+)\s/ \ - and para !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ - if para =~/^#{Mx[:lv_o]}#{no1}:/ - t_no1+=1; t_no2=0; t_no3=0 - title_no="#{t_no1}" - if not @md.seg_names.nil? \ - and not @md.seg_names.include?(title_no) - para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*(\S+)#/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]} \\1 #{title_no} ") #shift placement of auto-number to after first word, e.g. Article # not # Article, added on occasion of ABF (20040329) - para.gsub!(/^#{no1}\{\s+(Article|Clause|Section)\s+#/i,%{#{no1}~#{title_no} \\1 #{title_no}. }) - unless para =~/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review - para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]}#{title_no}. ") - end - @md.seg_names << title_no - #else puts "warning segment name #{title_no} already exists" - end - unless para =~/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required - para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i, - %{#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}#{title_no}. \\2 #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) - end - para.gsub!(/^#{Mx[:lv_o]}#{no1}:##{Mx[:lv_c]}/,"#{title_no}. ") #watch - para.gsub!(/^#{no1}~#\s*/,"#{title_no}. ") - end - if para =~/^#{Mx[:lv_o]}#{no2}:\S*?#{Mx[:lv_c]}/ - t_no2+=1; t_no3=0 - title_no="#{t_no1}.#{t_no2}" - para=number_sub_heading(para,no2,title_no) - end - if para =~/^#{Mx[:lv_o]}#{no3}:\S*?#{Mx[:lv_c]}/ - t_no3+=1 - title_no="#{t_no1}.#{t_no2}.#{t_no3}" - para=number_sub_heading(para,no3,title_no) - end - elsif para =~/^#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}/ # endnotes, watch2005 - para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}") #"#{no1}~\\1 ") - para.gsub!(/^#{Mx[:lv_o]}#{no2}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no2}:\\1#{Mx[:lv_c]}") - para.gsub!(/^#{Mx[:lv_o]}#{no3}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no3}:\\1#{Mx[:lv_c]}") - end - elsif @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 - if para =~/^#{Mx[:lv_o]}[1-9]:#{Mx[:lv_c]}([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d - name_num=$1 - para.gsub!(/^#{Mx[:lv_o]}([1-9]:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{name_num}#{Mx[:lv_c]}") - end - if @md.toc_lev_limit - end - end - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - def ocn(data) #and auto segment numbering increment - @tuned_file=[] - object_array=SiSU_document_structure::OCN.new(@md,data).ocn - object_array.each do |o| - @tuned_file <<= if o.ocn; "#{o.txt} #{Mx[:id_o]}~#{o.ocn};#{o.lv};#{o.type}#{Mx[:id_c]}" #main ocn descriptor - else o.txt - end - end - @tuned_file=@tuned_file.flatten - end - def minor_numbering(data) #and auto segment numbering increment - @tuned_file=[] - number_small,letter_small=0,0 - letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z ) - data.each do |para| - if para =~/\w|\S|<|\(/ - if para !~/^%% |#{Rx[:meta]}|^0~|^#{Mx[:lv_o]}endnotes:|^4~endnotes|^<\/center>|<:ee>|<:e[:_]>|^\^~ |<:e[:_]\d+?>|^#{Mx[:fa_o]}:p[bn]#{Mx[:fa_c]}|^<:\#|<:- |<[:!]!4|#{Mx[:gr_o]}(?:alt|code|group|poem|table)#{Mx[:gr_c]}|^(?:alt|code|group|poem|table)\{|^\}(?:alt|code|group|poem|table)|^\}table$||||

    |<\/tr>|
    |\[endnotes\]|<:zz>|<:isbn-|<:journal-|<:conference-|#{Mx[:br_endnotes]}/i #ocn here #  added with Tune.code #¡ - if para=~/^#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}/; number_small,letter_small=0,0 #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) - end - if para =~/^#[ 1]/ - letter_small=0 - number_small=0 if para =~ /^#1/ - number_small+=1 - para.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004 - end - if para =~/^_# / - para.gsub!(/^_# /,"#{Mx[:fa_o]}:i1#{Mx[:fa_c]} #{letter[letter_small]}. ") #change 2004 - letter_small+=1 - end - end - end - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - def name_para_seg_filename(data) - # paragraph name/numbering rules - # manual naming overrides, manual naming may be - # alpha-numeric characters mixed, - # numeric only (a number), if - # all segments have been named, - # the numbers used are over 1000 or - # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) - # [for now a warning is printed for such documents on use of maintenance or very-verbose flag] - # auto-naming takes the form of giving numbers to segments - # the rules for which are as follows - # if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.) - # otherwise the level 4 segment number from the embedded document structure info is used - # if there is none a sequential number is designated, preceded by an underscore - @tuned_file=[] - art_filename_auto=1 - @counter=1 - @unique_auto_name=[] - if not @md.seg_autoname_safe and @md.cmd =~/[MV]/ - puts 'manual segment names, numbers used as names, risk warning (segmented html)' - end - data.each do |para| - para=SiSU_document_structure::Structure.new(@md,para).structure_markup - if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}/ - if para=~/^#{Mx[:lv_o]}[4]:#{Mx[:lv_c]}/ \ - and not @md.set_heading_seg - @md.set_heading_seg=true - end - if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}(?:\s*\S+)?\s+([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name - pattern=$1 - pattern.gsub!(/(?:[:,-]|\W)/,'.') - pattern.gsub!(/\.$/,'') - if not @md.seg_names.nil? \ - and not @md.seg_names.include?(pattern) - para.gsub!(/^#{Mx[:lv_o]}([456]):#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1:#{pattern}#{Mx[:lv_c]}") - @md.seg_names << pattern - else puts 'warn, there may be a conflicting numbering scheme' if @md.cmd =~/[VM]/ - end - end - if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}.+?;4:(\d+);/m #extract segment name from embedded document structure info - pattern=$1 - pattern.gsub!(/(?:[:,-]|\W)/,'.') - pattern.gsub!(/\.$/,'') - if not @md.seg_names.nil? \ - and not @md.seg_names.include?(pattern) - para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{pattern}#{Mx[:lv_c]}") - @md.seg_names << pattern - else - para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1~#{pattern}#{Mx[:lv_c]}") - @md.seg_names << "~#{pattern}" - end - end - if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}/ #if still not segment name, provide a numerical one - if not @md.seg_names.nil? \ - and not @md.seg_names.include?(art_filename_auto) - para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,%{#{Mx[:lv_o]}\\1~#{art_filename_auto}#{Mx[:lv_c]}}) - @md.seg_names << art_filename_auto - else puts 'segment name (numbering) error' - end - art_filename_auto+=1 - end - end - @tuned_file << if para =~/^#{Mx[:lv_o]}([1-6]):\S*?#{Mx[:lv_c]}/m \ - and (@md.pagenew or @md.pagebreak) - m=$1 #watch ref~ - para_tmp=[] - if @md.pagenew.inspect =~/#{m}/; para_tmp << "#{Mx[:br_page_new]}\n" << para - elsif @md.pagebreak.inspect =~/#{m}/; para_tmp << "#{Mx[:br_page]}\n" << para - end - para_result=unless para_tmp.length > 0; para - else para_tmp - end - else para - end - end - if @md.seg_names.length > 0 - @md.set_heading_seg=true - end - @tuned_file=@tuned_file.flatten - end - def set_heading_top(data) #% make sure no false positives - unless @md.set_heading_top - puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.cmd =~/[MV]/ - @tuned_file=[] - data.each do |para| - unless @md.set_heading_top - if para !~/^(?:#{Rx[:meta]}|@\S+:|0~\S+)\s/m \ - and para !~/\A\s*\Z/m - @md.set_heading_top=true - head=if @md.title ; "#{Mx[:lv_o]}1:#{Mx[:lv_c]} #{@md.title}" - else "#{Mx[:lv_o]}1:#{Mx[:lv_c]} [no title provided]" - end - @tuned_file << head - end - end - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - end - def set_heading_seg(data) #% make sure no false positives - unless @md.set_heading_seg - puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.cmd =~/[MV]/ - @tuned_file=[] - data.each do |para| - unless @md.set_heading_seg - if para !~/^(?:#{Rx[:meta]}|#{Mx[:lv_o]}[123]:\S*?#{Mx[:lv_c]})/m \ - and para !~/\A\s*\Z/m \ - and para !~/#{Mx[:br_page]}|#{Mx[:br_page_new]}/ - @md.set_heading_seg=true - head=if @md.title ; "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [#{@md.title}]" - else "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [segment]" - end - @tuned_file << head - end - end - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - end - def set_header_title(data) #% make sure no false positives - unless @md.set_header_title - puts "\t no document title provided, (will have to manufacture one)" if @md.cmd =~/[MV]/ - @tuned_file=[] - data.each do |para| - unless @md.set_header_title - if para !~/^%{1,2}\s/m \ - and para !~/\A\s*\Z/m - @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" - @md.title=@md.heading_seg_first - @md.set_header_title=true - end - end - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - end def endnotes(data) @tuned_file=[] endnote_no,endnote_ref=1,1 @@ -1058,7 +735,7 @@ module SiSU_DAL para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch para_plus_en=para.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) para_tail=if para =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m - /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.+?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] + /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.*?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] else '' end para_plus_en << para_tail diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb new file mode 100644 index 00000000..5e07396a --- /dev/null +++ b/lib/sisu/v0/dal_idx.rb @@ -0,0 +1,201 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_book_index + class Book_index + def initialize(data) + @data=data + end + def indexing_song + @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ + #@rgx_idx=/\s*#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ + @rgx_idx_ocn_init=/#{Mx[:idx_o]}(.+?)#{Mx[:idx_c]}\s*#{Mx[:id_o]}~(\d+)\S+?#{Mx[:id_c]}/ + @rgx_idx_ocn=/(.+?)~(\d+)/ + @data=extract_book_index(@data) + @data=clean_index(@data) + @data + end + def extract_book_index(data) + tuned_file=[] + idx_array=[] + data.each do |para| + idx_array << @rgx_idx_ocn_init.match(para)[0].gsub(@rgx_idx_ocn_init,'\1~\2') if para =~ @rgx_idx_ocn_init + tuned_file << para if para + end + idx_array.each do |i| + i.gsub!(@rgx_idx_ocn_init,'\1~\2') + end + idx_array=construct_idx_array(idx_array) if idx_array.length > 0 + if idx_array.length > 0 + the_idx=construct_book_index(idx_array) + screen_print(the_idx) + end + tuned_file + end + def construct_idx_array(idx_array) + idx_lst=[] + idx_array.each do |idx| + idx_list,ocn=@rgx_idx_ocn.match(idx)[1,2] + idx_lst <<=if idx_list =~/;/ + g=idx_list.scan(/[^;]+/) + idxl=[] + g.each do |i| + idxl << { :rough_idx => i, :ocn => ocn } + end + idxl + else { :rough_idx => idx_list, :ocn => ocn } + end + end + idx_lst.flatten! + idx_lst + end + def construct_book_index(idx_array) + @the_idx={} + idx_array.each do |idx| + idx_lst=idx[:rough_idx].scan(/[^|:]+/) + if idx_lst[0] =~/.+?\+\d+/ + use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] + else use=idx_lst[0] + end + @the_idx[use]={} unless @the_idx[use] and defined? @the_idx[use] + idx_lst.each do |i| + i.strip! + i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ + x=if idx_lst.length == 1 or idx_lst[0] == i + @the_idx[use]['a1']=[] unless @the_idx[use]['a1'] and defined? @the_idx[use]['a1'] + x=if r + @the_idx[use]['a1'] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" } + "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" + else + @the_idx[use]['a1'] << { :ocn => idx[:ocn] } + "#{i} #{idx[:ocn]}" + end + else + @the_idx[use]['b1']={} unless @the_idx[use]['b1'] and defined? @the_idx[use]['b1'] + @the_idx[use]['b1'][i]=[] unless @the_idx[use]['b1'][i] and defined? @the_idx[use]['b1'][i] + x=if r + @the_idx[use]['b1'][i] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" } + "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" + else + @the_idx[use]['b1'][i] << { :ocn => idx[:ocn] } + "#{idx_lst[0]}:#{i} #{idx[:ocn]}" + end + end + end + end + the_idx=@the_idx.sort + #p the_idx; p '-----' + the_idx + end + def screen_print(the_idx) + the_idx.each do |i| + i.each do |x| + if x.class == String + print "\n" + x + ', ' + elsif x.class == Array + p 'array error? -->' + print x + elsif x.class == Hash + if x['a1'].class == Array + x['a1'].each do |a| + if a[:range] + print a[:range] + ', ' + elsif a[:ocn] + print a[:ocn] + ', ' + else p 'error' + end + end + end + if x['b1'] + m=x['b1'] + m=m.sort + m.each do |k,y| + if k !~/a1/ + print "\n\t" + k + ', ' + #p y + y.each do |z| + if z[:range] + print z[:range] + ', ' + elsif z[:ocn] + print z[:ocn] + ', ' + else p 'error' + end + end + end + end + end + end + end + end + end + def clean_index(data) + tuned_file=[] + data.each do |para| + para.gsub!(@rgx_idx,'') + tuned_file << para + end + tuned_file + end + end +end + +__END__ + diff --git a/lib/sisu/v0/dal_numbering.rb b/lib/sisu/v0/dal_numbering.rb new file mode 100644 index 00000000..e14b87d7 --- /dev/null +++ b/lib/sisu/v0/dal_numbering.rb @@ -0,0 +1,374 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_numbering + class Numbering + def initialize(md,data) + @md,@data=md,data + end + def numbering_song + data=@data + data=number_plaintext_para(data) + #data=name_endnote_seg(data) #tr issue + data=auto_number_heading_ie_title(data) #tr issue + data=ocn(data) #watch + data=minor_numbering(data) + data=name_para_seg_filename(data) + data=set_heading_seg(data) unless @md.set_heading_seg + data=set_heading_top(data) unless @md.set_heading_top + data=set_header_title(data) unless @md.set_header_title + data + end + def number_plaintext_para(data) + @tuned_file=[] + data.each do |para| + if para !~/#{Mx[:gr_o]}(?:code|group|alt|poem|verse)#{Mx[:gr_c]}|#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ + para.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks + end + para.gsub!(/^/,"\n") unless para =~/#{Mx[:tc_p]}/u + para.gsub!(/^\s+|\s$/,"\n") + @tuned_file << para + end + @tuned_file=@tuned_file.flatten + end + def name_endnote_seg(data) + @tuned_file=[] + if @md.flag_auto_endnotes \ + and @md.flag_separate_endnotes_make + @tuned_file << "\n#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}Endnotes #{Mx[:gl_o]}-##{Mx[:gl_c]} #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" + end + @tuned_file << "\n#{Mx[:br_endnotes]}" #DECIDE ON + @tuned_file=@tuned_file.flatten + end + def owner_details_seg + data << "#{Mx[:lv_o]}4:owner.details#{Mx[:lv_c]}Owner Details" + end + def number_sub_heading(para,num,title_no) + case para + when /#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/; para.gsub!(/#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/,"#{title_no} ") + when /^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/; para.gsub!(/^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/,"#{title_no} ") + when /^#{Mx[:lv_o]}#{num}:[a-z_\.]+#{Mx[:lv_c]}/ + para.gsub!(/^#{Mx[:lv_o]}#{num}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i,%{#{Mx[:lv_o]}#{num}:\\1#{Mx[:lv_c]} #{title_no} \\2 #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) + when /^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}\s*#{title_no}/ + para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]}") #where title contains title number + else para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]} #{title_no} ") #main, where title number is to be provided + end + if @md.toc_lev_limit \ + and @md.toc_lev_limit < num + para.gsub!(/^#{Mx[:lv_o]}[5-9]:\S*?#{Mx[:lv_c]}/,'!_ ') #bold line, watch + end + para + end + def auto_number_heading_ie_title(data) #also does some segment naming + @tuned_file=[] + if @md.markup =~/num_top/ \ + or @md.num_top # watch, 2003w23 + input="#{@md.markup}"[/num_top\=([1-6])/,1] if @md.markup + input||=@md.num_top if @md.num_top !~/^$/ + end + num_top=input.to_i + t_no1=t_no2=t_no3=t_no4=0 + no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3) + t_not=0 + data.each do |para| #@md.seg_names << [additions to segment names] + if (@md.markup =~/num_top/ \ + or (@md.num_top \ + and @md.num_top !~/^$/)) \ + and para !~/^#{Rx[:meta]}/ + if (para =~/^(?:#{no1}|^#{no2}|^#{no3}#{no4})~#/ \ + and para !~/^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}/) + t_not+=1 #; t_no2=0; t_no3=0 + para.gsub!(/^(#{Mx[:lv_o]}#{no1}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") + para.gsub!(/^(#{Mx[:lv_o]}#{no2}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") + para.gsub!(/^(#{Mx[:lv_o]}#{no3}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") + para.gsub!(/^(#{Mx[:lv_o]}#{no4}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") + end + if para =~/#{Mx[:lv_o]}#{no1}:/ + @subnumber=1 + @subnumber=0 if para =~/#{Mx[:lv_o]}#{no1}:/ + end + if para =~/^#{Mx[:lv_o]}[1-6]:[\w-]*#{Mx[:lv_c]}/ \ + and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s*[\d.]+)\s/ \ + and para !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ + if para =~/^#{Mx[:lv_o]}#{no1}:/ + t_no1+=1; t_no2=0; t_no3=0 + title_no="#{t_no1}" + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(title_no) + para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*(\S+)#/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]} \\1 #{title_no} ") #shift placement of auto-number to after first word, e.g. Article # not # Article, added on occasion of ABF (20040329) + para.gsub!(/^#{no1}\{\s+(Article|Clause|Section)\s+#/i,%{#{no1}~#{title_no} \\1 #{title_no}. }) + unless para =~/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review + para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]}#{title_no}. ") + end + @md.seg_names << title_no + #else puts "warning segment name #{title_no} already exists" + end + unless para =~/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required + para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i, + %{#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}#{title_no}. \\2 #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) + end + para.gsub!(/^#{Mx[:lv_o]}#{no1}:##{Mx[:lv_c]}/,"#{title_no}. ") #watch + para.gsub!(/^#{no1}~#\s*/,"#{title_no}. ") + end + if para =~/^#{Mx[:lv_o]}#{no2}:\S*?#{Mx[:lv_c]}/ + t_no2+=1; t_no3=0 + title_no="#{t_no1}.#{t_no2}" + para=number_sub_heading(para,no2,title_no) + end + if para =~/^#{Mx[:lv_o]}#{no3}:\S*?#{Mx[:lv_c]}/ + t_no3+=1 + title_no="#{t_no1}.#{t_no2}.#{t_no3}" + para=number_sub_heading(para,no3,title_no) + end + elsif para =~/^#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}/ # endnotes, watch2005 + para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}") #"#{no1}~\\1 ") + para.gsub!(/^#{Mx[:lv_o]}#{no2}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no2}:\\1#{Mx[:lv_c]}") + para.gsub!(/^#{Mx[:lv_o]}#{no3}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no3}:\\1#{Mx[:lv_c]}") + end + elsif @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 + if para =~/^#{Mx[:lv_o]}[1-9]:#{Mx[:lv_c]}([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d + name_num=$1 + para.gsub!(/^#{Mx[:lv_o]}([1-9]:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{name_num}#{Mx[:lv_c]}") + end + if @md.toc_lev_limit + end + end + @tuned_file << para + end + @tuned_file=@tuned_file.flatten + end + def ocn(data) #and auto segment numbering increment + @tuned_file=[] + object_array=SiSU_document_structure::OCN.new(@md,data).ocn + object_array.each do |o| + @tuned_file <<= if o.ocn; "#{o.txt} #{Mx[:id_o]}~#{o.ocn};#{o.lv};#{o.type}#{Mx[:id_c]}" #main ocn descriptor + else o.txt + end + end + @tuned_file=@tuned_file.flatten + end + def minor_numbering(data) #and auto segment numbering increment + @tuned_file=[] + number_small,letter_small=0,0 + letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z ) + data.each do |para| + if para =~/\w|\S|<|\(/ + if para !~/^%% |#{Rx[:meta]}|^0~|^#{Mx[:lv_o]}endnotes:|^4~endnotes|^<\/center>|<:ee>|<:e[:_]>|^\^~ |<:e[:_]\d+?>|^#{Mx[:fa_o]}:p[bn]#{Mx[:fa_c]}|^<:\#|<:- |<[:!]!4|#{Mx[:gr_o]}(?:alt|code|group|poem|table)#{Mx[:gr_c]}|^(?:alt|code|group|poem|table)\{|^\}(?:alt|code|group|poem|table)|^\}table$||||
    |<\/tr>|
    |\[endnotes\]|<:zz>|<:isbn-|<:journal-|<:conference-|#{Mx[:br_endnotes]}/i #ocn here #  added with Tune.code #¡ + if para=~/^#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}/; number_small,letter_small=0,0 #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) + end + if para =~/^#[ 1]/ + letter_small=0 + number_small=0 if para =~ /^#1/ + number_small+=1 + para.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004 + end + if para =~/^_# / + para.gsub!(/^_# /,"#{Mx[:fa_o]}:i1#{Mx[:fa_c]} #{letter[letter_small]}. ") #change 2004 + letter_small+=1 + end + end + end + @tuned_file << para + end + @tuned_file=@tuned_file.flatten + end + def name_para_seg_filename(data) + # paragraph name/numbering rules + # manual naming overrides, manual naming may be + # alpha-numeric characters mixed, + # numeric only (a number), if + # all segments have been named, + # the numbers used are over 1000 or + # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) + # [for now a warning is printed for such documents on use of maintenance or very-verbose flag] + # auto-naming takes the form of giving numbers to segments + # the rules for which are as follows + # if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.) + # otherwise the level 4 segment number from the embedded document structure info is used + # if there is none a sequential number is designated, preceded by an underscore + @tuned_file=[] + art_filename_auto=1 + @counter=1 + @unique_auto_name=[] + if not @md.seg_autoname_safe and @md.cmd =~/[MV]/ + puts 'manual segment names, numbers used as names, risk warning (segmented html)' + end + data.each do |para| + para=SiSU_document_structure::Structure.new(@md,para).structure_markup + if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}/ + if para=~/^#{Mx[:lv_o]}[4]:#{Mx[:lv_c]}/ \ + and not @md.set_heading_seg + @md.set_heading_seg=true + end + if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}(?:\s*\S+)?\s+([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name + pattern=$1 + pattern.gsub!(/(?:[:,-]|\W)/,'.') + pattern.gsub!(/\.$/,'') + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(pattern) + para.gsub!(/^#{Mx[:lv_o]}([456]):#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1:#{pattern}#{Mx[:lv_c]}") + @md.seg_names << pattern + else puts 'warn, there may be a conflicting numbering scheme' if @md.cmd =~/[VM]/ + end + end + if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}.+?;4:(\d+);/m #extract segment name from embedded document structure info + pattern=$1 + pattern.gsub!(/(?:[:,-]|\W)/,'.') + pattern.gsub!(/\.$/,'') + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(pattern) + para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{pattern}#{Mx[:lv_c]}") + @md.seg_names << pattern + else + para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1~#{pattern}#{Mx[:lv_c]}") + @md.seg_names << "~#{pattern}" + end + end + if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}/ #if still not segment name, provide a numerical one + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(art_filename_auto) + para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,%{#{Mx[:lv_o]}\\1~#{art_filename_auto}#{Mx[:lv_c]}}) + @md.seg_names << art_filename_auto + else puts 'segment name (numbering) error' + end + art_filename_auto+=1 + end + end + @tuned_file << if para =~/^#{Mx[:lv_o]}([1-6]):\S*?#{Mx[:lv_c]}/m \ + and (@md.pagenew or @md.pagebreak) + m=$1 #watch ref~ + para_tmp=[] + if @md.pagenew.inspect =~/#{m}/; para_tmp << "#{Mx[:br_page_new]}\n" << para + elsif @md.pagebreak.inspect =~/#{m}/; para_tmp << "#{Mx[:br_page]}\n" << para + end + para_result=unless para_tmp.length > 0; para + else para_tmp + end + else para + end + end + if @md.seg_names.length > 0 + @md.set_heading_seg=true + end + @tuned_file=@tuned_file.flatten + end + def set_heading_top(data) #% make sure no false positives + unless @md.set_heading_top + puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.cmd =~/[MV]/ + @tuned_file=[] + data.each do |para| + unless @md.set_heading_top + if para !~/^(?:#{Rx[:meta]}|@\S+:|0~\S+)\s/m \ + and para !~/\A\s*\Z/m + @md.set_heading_top=true + head=if @md.title ; "#{Mx[:lv_o]}1:#{Mx[:lv_c]} #{@md.title}" + else "#{Mx[:lv_o]}1:#{Mx[:lv_c]} [no title provided]" + end + @tuned_file << head + end + end + @tuned_file << para + end + @tuned_file=@tuned_file.flatten + end + end + def set_heading_seg(data) #% make sure no false positives + unless @md.set_heading_seg + puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.cmd =~/[MV]/ + @tuned_file=[] + data.each do |para| + unless @md.set_heading_seg + if para !~/^(?:#{Rx[:meta]}|#{Mx[:lv_o]}[123]:\S*?#{Mx[:lv_c]})/m \ + and para !~/\A\s*\Z/m \ + and para !~/#{Mx[:br_page]}|#{Mx[:br_page_new]}/ + @md.set_heading_seg=true + head=if @md.title ; "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [#{@md.title}]" + else "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [segment]" + end + @tuned_file << head + end + end + @tuned_file << para + end + @tuned_file=@tuned_file.flatten + end + end + def set_header_title(data) #% make sure no false positives + unless @md.set_header_title + puts "\t no document title provided, (will have to manufacture one)" if @md.cmd =~/[MV]/ + @tuned_file=[] + data.each do |para| + unless @md.set_header_title + if para !~/^%{1,2}\s/m \ + and para !~/\A\s*\Z/m + @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" + @md.title=@md.heading_seg_first + @md.set_header_title=true + end + end + @tuned_file << para + end + @tuned_file=@tuned_file.flatten + end + end + end +end +__END__ diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index acdec0e4..80635f36 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -326,7 +326,7 @@ module SiSU_Syntax line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{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!(/=\{(.+?)\}/,"#{Mx[:idx_o]}\\1#{Mx[:idx_c]}") # 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 diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index b211f5c1..7994487d 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -119,13 +119,13 @@ module SiSU_Param @doc={ :lv=>[] } @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' @@publisher='SiSU scribe' - attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec,:opt,:sem_tag + attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec,:opt,:sem_tag,:book_index def initialize(fns_array,opt) @env=@fn=@fns=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@sfx=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@site_skin=@sisu=@sisu_version=@ruby_version=@title=@dc_title=@html_title=@subtitle=@subtitle_tex=@creator_home=@dc_creator=@translator=@illustrator=@prepared_by=@digitized_by=@dc_subject=@dc_description=@dc_publisher=@dc_contributor=@dc_date=@dc_date_created=@dc_date_issued=@dc_date_available=@dc_date_valid=@dc_date_modified=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@dc_type=@dc_format=@dc_identifier=@dc_source=@dc_language=@language_original=@dc_relation=@dc_coverage=@dc_rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@num_top=@toc_lev_limit=@flag_auto_heading_num=@make_bold=@make_italic=@flag_tables=@vocabulary=@doc_skin=@doc_css=@yaml=@lnk=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@file_size=@firstseg=@programs=@creator_copymark=@lang=@en=@dgst=@dgst_skin=@generated=@heading_seg_first=@base_program=@man_synopsis=nil @man_section=1 @man_name='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' @data,@fns,@cmd,@mod,@opt=fns_array,opt.fns,opt.cmd,opt.mod,opt #@data used as data - @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo=false,false,false,false,false,false + @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_index=false,false,false,false,false,false,false @seg_autoname_safe=true @sem_tag=false @markup_instruction,@markup_declared,@image='','','' #check which other values should be set to empty rather than nil @@ -576,6 +576,9 @@ module SiSU_Param end end end + if not @book_index and para =~/^=\{(.+?)\}\s*$/ + @book_index=true + end unless @code_flag case para when /~\{\s+.+?\}~/m #% processing diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 4dd808fc..fb4b1115 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -321,7 +321,7 @@ WOK para.gsub!(/(^|#{Mx[:gl_c]}|\s)[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3') para.gsub!(/
    (.+?)<\/a>/m,'\1') para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links - para.gsub!(/ /,' ') # decide on + para.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") para.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') #para.gsub!(/^\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') -- cgit v1.2.3 From 798d710dea23806e428ec7636dad4c1d872166e3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 8 Sep 2008 22:24:15 -0400 Subject: dal, several modules split into separate files --- lib/sisu/v0/dal.rb | 608 +----------------------- lib/sisu/v0/dal_character_check.rb | 112 +++++ lib/sisu/v0/dal_doc_str.rb | 4 +- lib/sisu/v0/dal_endnotes.rb | 132 +++++ lib/sisu/v0/dal_expand_insertions.rb | 155 ++++++ lib/sisu/v0/dal_hash_digest.rb | 176 +++++++ lib/sisu/v0/dal_idx.rb | 8 +- lib/sisu/v0/dal_images.rb | 125 +++++ lib/sisu/v0/dal_metadata.rb | 228 +++++++++ lib/sisu/v0/dal_numbering.rb | 10 +- lib/sisu/v0/dal_substitutions_and_insertions.rb | 131 +++++ 11 files changed, 1096 insertions(+), 593 deletions(-) create mode 100644 lib/sisu/v0/dal_character_check.rb create mode 100644 lib/sisu/v0/dal_endnotes.rb create mode 100644 lib/sisu/v0/dal_expand_insertions.rb create mode 100644 lib/sisu/v0/dal_hash_digest.rb create mode 100644 lib/sisu/v0/dal_images.rb create mode 100644 lib/sisu/v0/dal_metadata.rb create mode 100644 lib/sisu/v0/dal_substitutions_and_insertions.rb (limited to 'lib') diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index aa4758b7..d091284d 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -60,15 +60,22 @@ =end module SiSU_DAL - require "#{SiSU_lib}/defaults" - require "#{SiSU_lib}/sysenv" - require "#{SiSU_lib}/param" - require "#{SiSU_lib}/dal_syntax" - require "#{SiSU_lib}/dal_doc_str" - require "#{SiSU_lib}/dal_idx" - require "#{SiSU_lib}/dal_numbering" - require "#{SiSU_lib}/i18n" - require "#{SiSU_lib}/shared_sem" + require "#{SiSU_lib}/defaults" # defaults.rb + require "#{SiSU_lib}/sysenv" # sysenv.rb + require "#{SiSU_lib}/param" # param.rb + require "#{SiSU_lib}/dal_syntax" # dal_syntax.rb + require "#{SiSU_lib}/dal_doc_str" # dal_doc_str.rb + require "#{SiSU_lib}/dal_idx" # dal_idx.rb + require "#{SiSU_lib}/dal_numbering" # dal_numbering.rb + require "#{SiSU_lib}/dal_hash_digest" # dal_hash_digest.rb + require "#{SiSU_lib}/dal_endnotes" # dal_endnotes.rb + require "#{SiSU_lib}/dal_images" # dal_images.rb + require "#{SiSU_lib}/dal_metadata" # dal_metadata.rb + require "#{SiSU_lib}/dal_character_check" # dal_character_check.rb + require "#{SiSU_lib}/dal_substitutions_and_insertions" # dal_substitutions_and_insertions.rb + require "#{SiSU_lib}/dal_expand_insertions" # dal_expand_insertions.rb + require "#{SiSU_lib}/i18n" # i18n.rb + require "#{SiSU_lib}/shared_sem" # shared_sem.rb include SiSU_Env include SiSU_Param include SiSU_Viz @@ -76,9 +83,6 @@ module SiSU_DAL class Instantiate < SiSU_Param::Parameters::Instructions def initialize @@flag_vocab=0 - @@endnote={} - @@endnote_array=@@word_mode=[] - @@endnote_counter,@@endnote_counter_asterisk,@@endnote_counter_dag=1,1,1 #added @@line_mode='' end end @@ -171,26 +175,17 @@ module SiSU_DAL end end class Make - @@endnote={} - @@endnote_array=@@word_mode=[] - @@endnote_counter,@@endnote_counter_asterisk,@@endnote_counter_dag=1,1,1 - @@comment='%' + #@@comment='%' @@dp=nil def initialize(md,data) @md,@data=md,data - @@word_mode=[] + #@@word_mode=[] @env=SiSU_Env::Info_env.new(@md.fns) @skin=SiSU_Env::Info_skin.new(@md) @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern - l=SiSU_Env::Standardise_language.new.file_to_language(@md.fns) - @language=l[:l] - @tr=SiSU_Translate::Source.new(@md,@language) end def reset @@flag_vocab=0 - @@endnote={} - @@endnote_array=@@word_mode=[] - @@endnote_counter,@@endnote_counter_asterisk,@@endnote_counter_dag=1,1,1 @@line_mode='' end def song @@ -199,9 +194,9 @@ module SiSU_DAL @metafile="#{@env.path.dal}/#{@md.fns}.meta" my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) data=data.join.split("\n\n") - data=expand_insertions?(data) + data=SiSU_insertions::Insertions.new(data).expand_insertions? data=SiSU_document_structure::Code.new(@md,data).code - data=substitutions_and_insertions?(data) + data=SiSU_substitute_and_insert::SI.new(@md,data).substitutions_and_insertions? data_new=[] data.each do |x| data_new << if x =~ /\n\n/m; x.split(/\n\n+/) @@ -210,14 +205,15 @@ module SiSU_DAL end data=data_new.flatten data=SiSU_Syntax::Markup.new(@md,data).songsheet - data=character_check(data) - data=images(data) + data,endnote_array=SiSU_character_check::Check.new(data).character_check_and_oldstyle_endnote_array + data=SiSU_images::Images.new(@md,data).images data=SiSU_document_structure::Tables.new(@md,data).tables data=SiSU_numbering::Numbering.new(@md,data).numbering_song data=SiSU_book_index::Book_index.new(data).indexing_song if @md.book_index - data=endnotes(data) - data=object_digest(data) - meta=metadata(data) + data=SiSU_endnotes::Endnotes.new(@md,data,endnote_array).endnotes + data=SiSU_hash::Object_digest.new(@md,data,@env).object_digest + meta=SiSU_metadata::Metadata.new(@md,data).metadata + #meta=metadata(data) outputdata=data + meta if @md.cmd =~/[mM]/ SiSU_DAL::Output.new(@md,outputdata).hard_output @@ -227,100 +223,6 @@ module SiSU_DAL outputdata end protected - def character_check(data) - require 'iconv' - reset - @tuned_file=[] - endnote_no=1 - data.each do |para| - para.strip! - para.gsub!(/^([12])~\?\s+/,'\1~ ') #conditional header for incorporated document 2004w12 - para.gsub!(/^[{~}]\s*$/,'') - para.gsub!(/^#{@@comment}.*/,'') #remove comment and divider #% - para.gsub!(/<~#>|~#\s*/,"#{Mx[:fa_o]}~##{Mx[:fa_c]}") - para.gsub!(/-#\s*/,"#{Mx[:fa_o]}-##{Mx[:fa_c]}#{Mx[:fa_o]}~##{Mx[:fa_c]}") - #para.gsub!(/(#\{{3} arch-tag:|0\{{3}~cvs)\s+/, "0{{~rcs ") #KEEP ... ENABLE WIDER USE OF REVISION CONTROL - para.gsub!(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') - para.gsub!(/ \/\//,"#{Mx[:br_line]}") #added 2004w29 - para.gsub!(/
    /,"#{Mx[:br_line]}") #needed by xml, xhtml etc. - para.gsub!(/\t/,' ') - para.gsub!(/\342\200\231/u,"'") #if para =~/’/ #Avoid #‘ ’ #“ ” - para.gsub!(/�/u,' ') #watch, replace with char code - para.gsub!(/·/u,'*') - para.gsub!(/\\copy(?:right)?\b/,'©') - para.gsub!(/\\trademark\b|\\tm\b/,'®') - #non_utf8(para) - para=para + "\n" - unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ - case para - when /\^~/ # endnotes - #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ - sub_para=para.dup - @@endnote_array << sub_para.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip - endnote_no+=1 - para=nil if para =~/\^~ .+/ #removes 'binary' endnote now in endnote array for later insertion - end - end - @tuned_file << para unless para.nil? - end - @tuned_file=@tuned_file.flatten - end - def images(data) - tuned_file=[] - @rmgk=false - if SiSU_Env::Info_settings.new.program?('rmagick'); @rmgk=SiSU_Env::Load.new('RMagick').prog - else tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') - tell.warn if @md.cmd =~/[vVM]/ - end - data.each do |para| - para.strip! - if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ - if para !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ - m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ - if @rmgk - imgs=para.scan(m).flatten - images=imgs.each do |image| - dir=SiSU_Env::Info_env.new(@md.fns) - path_image=[dir.path.image_source_local_tex,dir.path.image_source_remote_tex,dir.path.image_source_tex] - image_path=nil - path_image.each do |image_path| - break if FileTest.exist?("#{image_path}/#{image}") - end - if FileTest.exist?("#{image_path}/#{image}") - img=Magick::ImageList.new("#{image_path}/#{image}") - img_col,img_row=img.columns,img.rows - if img_col > img_row #landscape - if img_col> 640 #480 - img_col=640 #480 - img_row=((1.00*img_col/img.columns)*img.rows).round - end - else #portrait - if img_col> 640 #480 - img_col=640 #480 - img_row=((1.00*img_col/img.columns)*img.rows).round - end - if img_row > 640 - img_row=640 - img_col=((1.00*img_row/img.rows)*img.columns).round - end - end - para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else para.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') - end - end - else - images=para.scan(m) do |image| - tell=SiSU_Screen::Ansi.new(@md.cmd,'where image dimensions have not been provided RMagick is required',image) - tell.warn #unless @opt.cmd =~/q/ - end - end - end - end - para.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ - tuned_file << para unless para.nil? - end - tuned_file - end def output_filetypes_in_cmd(cmd_shortcut,source=nil) #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used cf_defaults=SiSU_Env::Info_processing_flag.new @@ -366,464 +268,6 @@ module SiSU_DAL file_type_names[:src]=file_type_names[:src].flatten file_type_names end - def expand_insertions?(data) - tuned_file,tuned_file_tmp=[],[] - data.each do |para| - if para !~/^%+\s/ \ - and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ - txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil - @u=SiSU_Env::Info_env.new.url - if defined? @u.remote - if para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/m - pre,txt,cmd,source,url_dir,note="#{$1.strip} ",$2,$3,$4,$5,$6 - elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/ - pre,txt,cmd,source,url_dir,note='',$1,$2,$3,$4,$5 - end - manifest="#{pre}{#{txt} }#{@u.remote}/#{url_dir}/toc.html#{note}\n\n" - else - puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" - if para =~/\{(?:~\^\s+)?(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ - txt,cmd,url_dir,note=$1,$2,$3,$4 - manifest="{ #{txt} }../#{url_dir}/toc.html#{note}\n\n" - end - end - tuned_file_tmp << manifest - output_filetypes=output_filetypes_in_cmd(cmd,source) - output_filetypes[:gen].each do |o_f| - describe = case o_f - when /sisu_manifest.html/; '~^ document manifest' - when /toc.html/; ' html, segmented text' - when /doc.html/; ' html, scroll, document in one' - when /landscape.pdf/; ' pdf, landscape' - when /portrait.pdf/; ' pdf, portrait' - when /opendocument.odt/; ' odf:odt, open document text' - when /scroll.xhtml/; ' xhtml scroll' - when /sax.xml/; ' xml, sax' - when /dom.xml/; ' xml, dom' - when /plain.txt/; ' plain text utf-8' - #when /manpage.1/; ' man, 1' - when /wiki.txt/; ' wiki text' - when /concordance.html/; ' concordance' - when /digest.txt/; ' dcc, document content certificate (digests)' - else nil - end - if describe - tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry - if describe =~/^~\^ / - "#{Mx[:nbsp]*4} {#{describe} }#{@u.remote}/#{url_dir}/#{o_f} " - else - "#{Mx[:nbsp]*4} { #{describe} }#{@u.remote}/#{url_dir}/#{o_f} " - end - else - if describe =~/^~\^ / - "#{Mx[:nbsp]*4} {#{describe} }../#{url_dir}/#{o_f} " - else "#{Mx[:nbsp]*4} { #{describe} }../#{url_dir}/#{o_f} " - end - end - end - end - output_filetypes[:src].each do |o_f| - describe=case o_f - when /#{source}\.zip/; ' markup source (zipped) pod' - when /#{source}/; ' markup source text' - else nil - end - if describe - tuned_file_tmp << if @u.remote - x=if describe =~/zip/ - "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_pod}/#{o_f} " - else "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_txt}/#{o_f} " - end - else - x=if describe =~/zip/ - "#{Mx[:nbsp]*4} { #{describe} }../pod/#{o_f} " - else "#{Mx[:nbsp]*4} { #{describe} }../zip/#{o_f} " - end - end - end - end - tuned_file << 'group{' << tuned_file_tmp.join("\n") << '}group' - #tuned_file << 'group{' << tuned_file_tmp.join("\n").strip << '}group' - tuned_file_tmp=[] - else tuned_file << para - end - end - tuned_file - end - def substitutions_and_insertions?(data) - data_expand=[] - if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) - data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'') - data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'') - end - if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier - data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1') - data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1') - end - data.each do |para| - if para =~/<:insert\d+!?>/ \ - and para !~/^%\s+/ - @skin.select - ins=SiSU_Viz::Inserts.new - case para - when /^\s*<:insert1>\s*$/ - para=[] - ins.insert1.split(/\n\n/).each{|x| para << x } - when /^\s*<:insert2>\s*$/ - para=[] - ins.insert2.split(/\n\n/).each{|x| para << x } - when /^\s*<:insert3>\s*$/ - para=[] - ins.insert3.split(/\n\n/).each{|x| para << x << "\n"} - para=ins.insert3 - when /^\s*<:insert4>\s*$/ - para=[] - ins.insert4.split(/\n\n/).each{|x| para << x << "\n"} - para=ins.insert4 - when /^\s*<:insert5>\s*$/ - para=[] - ins.insert5.split(/\n\n/).each{|x| para << x << "\n"} - when /^\s*<:insert6>\s*$/ - para=[] - ins.insert6.split(/\n\n/).each{|x| para << x << "\n"} - when /^\s*<:insert7>\s*$/ - para=[] - ins.insert7.split(/\n\n/).each{|x| para << x << "\n"} - end - para.each{|x| data_expand << x } - else data_expand << para - end - data_expand.flatten! - data_expand.compact! - end - data_expand.each do |para| - para=if @md.markup_version.to_f >= 0.38 - SiSU_document_structure::Structure.new(@md,para).structure_markup_normalize - else - SiSU_document_structure::Structure.new(@md,para).structure_marks - end - #para.gsub!(//,'\1') #consider, would permit use of text hyperlinks if desired, dal_syntax more appropriate? - para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 - if para =~/^@\S+?:/ - para.gsub!(/^@(\S+?):\s+/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}") - para.gsub!(/^@(\S+?):([+-])\s+/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}") - end - end - end - def endnotes(data) - @tuned_file=[] - endnote_no,endnote_ref=1,1 - #% endnote work zone - data.each do |para| - # manually numbered endnotes --> - if @md.mod.inspect =~/--no-asterisk|--no-annotate/ - para.gsub!(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') - end - if @md.mod.inspect =~/--no-dagger|--no-annotate/ - para.gsub!(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') - end - unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ - case para - # auto-numbered endnotes --> - when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ - para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 - word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) - word_mode=endnote_call_number(word_mode) - para=word_mode.join(' ') - endnote_ref+=1 - when /~\^(?:\s|$)|<:e>/ - #%Note inserts endnotes previously gathered from /^(|[-~]\{{3})/ (in earlier loop) - word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) - word_mode=endnote_call_number(word_mode) - para=word_mode.join(' ') - endnote_ref+=1 - end - end - @tuned_file << para - end - @tuned_file=@tuned_file.flatten - end - def endnote_call_number(data) - data.each do |word| - unless data =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ - case word - when /#{Mx[:en_a_o]}/ - unless word =~/#{Mx[:en_a_o]}[*+]+/ - word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@@endnote_counter} ") - @@endnote_counter+=1 - end - when /#{Mx[:en_b_o]}/ - if word =~/#{Mx[:en_b_o]}[+]/ - word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@@endnote_counter_dag} ") - @@endnote_counter_dag+=1 - else - word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@@endnote_counter_asterisk} ") - @@endnote_counter_asterisk+=1 - end - when /~\^|<:e>/ - word.gsub!(/~\^|<:e>/,"#{@@endnote_array[@@endnote_counter-1]}") - @@endnote_counter+=1 - end - end - end - end - def metadata(data) - meta,@dc,@rc,@cvs,dctitle,add=Array.new(6){[]} - dir=SiSU_Env::Info_env.new(@md.fns) - base_html="#{dir.url.root}/#{@md.fnb}" - ocnm=ocnd=ocnv=0 - ocnm+=1 - header1="\n#{Mx[:lv_o_1]}meta#{Mx[:lv_c]}Document Information (metadata) #{Mx[:id_o]}~0;0:0;m#{ocnm}#{Mx[:id_c]}" - ocnm+=1 - header4="\n#{Mx[:lv_o_4]}metadata#{Mx[:lv_c]}Metadata #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" - ocnm+=1; ocnd+=1 - head_no_dc="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - ocnm+=1; ocnd+=1 - head_no_dc_tag="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - data.each do |para| - case para - when /^#{Mx[:meta_o]}(title|creator|author|translator|translated_by|illustrator|illustrated_by|prepared_by|digitized_by|description|publisher|contributor|date\.created|date\.issued|date\.available|date\.valid|date\.modified|date|type|format|rights|identifier|source|language)#{Mx[:meta_c]}/i - m=$1 - ocnm+=1; ocnd+=1 - @dc << case para - when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/ - "\n#{@tr.dc_title}: #{Mx[:fa_underscore_o]}#{@md.dc_title}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}(?:creator|author)#{Mx[:meta_c]}/ - "\n#{@tr.creator}: #{Mx[:fa_underscore_o]}#{@md.dc_creator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /#{Mx[:meta_o]}(?:translator|translated_by)#{Mx[:meta_c]}/ - "\n#{@tr.translator}: #{Mx[:fa_underscore_o]}#{@md.translator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}(?:illustrator|illustrated_by)#{Mx[:meta_c]}/ - "\n#{@tr.illustrator}: #{Mx[:fa_underscore_o]}#{@md.illustrator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}prepared_by#{Mx[:meta_c]}/ - "\n#{@tr.prepared_by}: #{Mx[:fa_underscore_o]}#{@md.prepared_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}digitized_by#{Mx[:meta_c]}/ - "\n#{@tr.digitized_by}: #{Mx[:fa_underscore_o]}#{@md.digitized_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}description#{Mx[:meta_c]}/ - "\n#{@tr.description}: #{Mx[:fa_underscore_o]}#{@md.dc_description}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}subject#{Mx[:meta_c]}/ - "\n#{@tr.subject}: #{Mx[:fa_underscore_o]}#{@md.dc_subject}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}abstract#{Mx[:meta_c]}/ - "\n#{@tr.abstract}: #{Mx[:fa_underscore_o]}#{@md.dc_abstract}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}publisher#{Mx[:meta_c]}/ - "\n#{@tr.publisher}: #{Mx[:fa_underscore_o]}#{@md.dc_publisher}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}contributor#{Mx[:meta_c]}/ - "\n#{@tr.contributor}: #{Mx[:fa_underscore_o]}#{@md.dc_contributor}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}date.created#{Mx[:meta_c]}/ - "\n#{@tr.date_created}: #{Mx[:fa_underscore_o]}#{@md.dc_date_created}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}date.issued#{Mx[:meta_c]}/ - "\n#{@tr.date_issued}: #{Mx[:fa_underscore_o]}#{@md.dc_date_issued}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}date.available#{Mx[:meta_c]}/ - "\n#{@tr.date_available}: #{Mx[:fa_underscore_o]}#{@md.dc_date_available}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}date.modified#{Mx[:meta_c]}/ - "\n#{@tr.date_modified}: #{Mx[:fa_underscore_o]}#{@md.dc_date_modified}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}date.valid#{Mx[:meta_c]}/ - "\n#{@tr.date_valid}: #{Mx[:fa_underscore_o]}#{@md.dc_date_valid}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}date#{Mx[:meta_c]}/ - "\n#{@tr.date}: #{Mx[:fa_underscore_o]}#{@md.dc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}type#{Mx[:meta_c]}/ - "\n#{@tr.type}: #{Mx[:fa_underscore_o]}#{@md.dc_type}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}format#{Mx[:meta_c]}/ - "\n#{@tr.format}: #{Mx[:fa_underscore_o]}#{@md.dc_format}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}rights#{Mx[:meta_c]}/ - "\n#{@tr.rights}: #{Mx[:fa_underscore_o]}#{@md.dc_rights}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}identifier#{Mx[:meta_c]}/ - "\n#{@tr.identifier}: #{Mx[:fa_underscore_o]}#{@md.dc_identifier}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}source#{Mx[:meta_c]}/ - "\n#{@tr.source}: #{Mx[:fa_underscore_o]}#{@md.dc_source}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}language#{Mx[:meta_c]}/ - "\n#{@tr.language}: #{Mx[:fa_underscore_o]}#{@md.dc_language}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}language.original#{Mx[:meta_c]}/ - "\n#{@tr.language_original}: #{Mx[:fa_underscore_o]}#{@md.language_original}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}relation#{Mx[:meta_c]}/ - "\n#{@tr.relation}: #{Mx[:fa_underscore_o]}#{@md.dc_relation}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}coverage#{Mx[:meta_c]}/ - "\n#{@tr.coverage}: #{Mx[:fa_underscore_o]}#{@md.dc_coverage}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}keywords#{Mx[:meta_c]}/ - "\n#{@tr.keywords}: #{Mx[:fa_underscore_o]}#{@md.keywords}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}comments#{Mx[:meta_c]}/ - "\n#{@tr.comments}: #{Mx[:fa_underscore_o]}#{@md.comments}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}cls_loc#{Mx[:meta_c]}/ - "\n#{@cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}cls_dewey#{Mx[:meta_c]}/ - "\n#{@tr.cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}(?:cls_gutenberg|cls_pg)#{Mx[:meta_c]}/ - "\n#{@tr.cls_gutenberg}: #{Mx[:fa_underscore_o]}#{@md.cls_gutenberg}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - #"\n#{@tr.cls_gutenberg}: #{@md.cls_pg} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}cls_isbn#{Mx[:meta_c]}/ - "\n#{@tr.cls_isbn}: #{Mx[:fa_underscore_o]}#{@md.cls_isbn}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}prefix(?:_a)?#{Mx[:meta_c]}/ - "\n#{@tr.prefix_a}: #{Mx[:fa_underscore_o]}#{@md.prefix_a}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - when /^#{Mx[:meta_o]}prefix_b#{Mx[:meta_c]}/ - "\n#{@tr.prefix_b}: #{Mx[:fa_underscore_o]}#{@md.prefix_b}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" - else para.gsub(/^#{Mx[:meta_o]}(#{m})\s+(.+)/m,"\n#{m.capitalize}: #{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}") - end - end - end - ocnm+=1; ocnv+=1 - head_no_rc="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - head_no_rc_tag="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - data.each do |para| - case para - when /^0~(?:cvs|rcs)\+\s+/ #note the + sign to turn on use of cvs id - ocnm+=1; ocnv+=1 - @cvs << "#{@tr.sc_number}: #{Mx[:fa_underscore_o]}#{@md.sc_number}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - @cvs << "#{@tr.sc_date}: #{Mx[:fa_underscore_o]}#{@md.sc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - @cvs << "CVS/RCS time: #{Mx[:fa_underscore_o]}#{@md.sc_time}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - when /^0~cvs[+\s]/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP - when /^0~cvs\s+/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP - end - end - if true #default version information - ocnm+=1; ocnv+=1 - if @md.sc_filename \ - and @md.sc_filename.length > 3 - @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.sc_filename}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - else @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.fns}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - end - ocnm+=1; ocnv+=1 - if @md.file_encoding \ - and @md.file_encoding.length > 3 #translate - @rc << "Filetype: #{Mx[:fa_underscore_o]}#{@md.file_encoding}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - end - ocnm+=1; ocnv+=1 - if @md.dgst #change. enable by default - @rc << "#{@tr.sourcefile_digest}, #{@md.dgst[0]} #{Mx[:fa_underscore_o]}#{@md.dgst[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - end - if @md.dgst_skin #change. enable by default - @rc << "Skin_Digest: #{@md.dgst_skin[0]} #{Mx[:fa_underscore_o]}#{@md.dgst_skin[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - end - @rc << "#{Mx[:fa_bold_o]}Generated#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 - @rc << "#{@tr.last_generated}: #{Mx[:fa_underscore_o]}#{Time.now}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - if @md.sisu_version[:version] - @rc << "#{@tr.sisu_version}: #{Mx[:fa_underscore_o]}#{@md.sisu_version[:project]}#{Mx[:fa_underscore_c]} #{Mx[:fa_underscore_o]}#{@md.sisu_version[:version]}#{Mx[:fa_underscore_c]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]}) #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - ocnm+=1; ocnv+=1 - end - @rc << "#{@tr.ruby_version}: #{Mx[:fa_underscore_o]} #{@md.ruby_version}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" - end - meta << Mx[:br_page_new] << header1 << header4 - meta << "Document Manifest @\n #{base_html}/#{@md.fn[:manifest]} #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" - meta << "#{Mx[:fa_bold_o]}Dublin Core#{Mx[:fa_bold_c]} (DC) #{head_no_dc}" if @dc.length > 0 - meta << "#{Mx[:fa_italics_o]}DC tags included with this document are provided here.#{Mx[:fa_italics_c]} #{head_no_dc_tag}" if @dc.length > 0 - @dc.each { |x| meta << x } - meta << "#{Mx[:fa_bold_o]}Version Information#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 - if @cvs.length > 0 - meta << "#{Mx[:fa_italics_o]}Note the version information provided here, is specific to the host site.#{Mx[:fa_italics_c]} #{head_no_rc_tag}" - @cvs.each { |x| meta << x } - end - @rc.each { |x| meta << x } - ## ENDNOTE RELATED endnote related - meta << "\n#{Mx[:br_eof]}" - meta=object_digest(meta) - end - def stamped(para,hash_class) - @tuned=[] - para=strip_clean_extra_spaces(para) - digest_all=hash_class.hexdigest(para) # print "#{hash_class.name}: "; puts digest_all #length==32 or 64 - stripped=strip_clean_of_markup(para) - digest_strip=hash_class.hexdigest(stripped) - unless para =~/#{Mx[:fa_o]}code#{Mx[:fa_c]}/ - case para - when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m - en_and_para,en_and_para_digest=[],[] - para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch - para_plus_en=para.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) - para_tail=if para =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m - /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.*?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] - else '' - end - para_plus_en << para_tail - en_and_para_digest << endnote_digest(para_plus_en) - para_new=en_and_para_digest.join(' ') - @tuned << para_new + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? - else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? - end - else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? - end - @tuned.join - end - def object_digest(data) - # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes - # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) - # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) - # [digests should not include other digests] - # vim==/<[0-9a-f]\{#{@@dl}\}\(:[0-9a-f]\{#{@@dl}\}\)\?>/ - require 'digest/md5' - require 'digest/sha2' - @tuned_file=[] - data.compact! - data.each do |para| - para.strip! - if para=~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}/ \ - and para !~/#{Rx[:meta]}/ #test should not be necessary remove - if @env.digest.type =~/sha256/ - for hash_class in [ Digest::SHA256 ] - @tuned_file << stamped(para,hash_class) - end - else - for hash_class in [ Digest::MD5 ] - @tuned_file << stamped(para,hash_class) - end - end - else @tuned_file << para unless para.nil? - end - end - @tuned_file=@tuned_file.flatten - #use md5 or to create hash of each dal object including ocn, & add into to each dal object - end - def endnote_digest(data) - para_bit=[] - data.each do |en_plus| - para_bit <<= case en_plus - when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ - para_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4] - stripped_en=strip_clean_of_markup(en_txt) - digest_en_strip=if @env.digest.type =~/sha256/ - Digest::SHA256.hexdigest(stripped_en) - else - Digest::MD5.hexdigest(stripped_en) - end - para_txt + en_open + en_txt + Mx[:id_o] + digest_en_strip + Mx[:id_c] + en_close - else puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up - end - else en_plus - end - end - para_bit.join - end - def strip_clean_extra_spaces(s) # dal output tuned - s=s.dup - s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - s=s.gsub(/ [ ]+/,' ') - s=s.gsub(/^ [ ]+/,'') - s=s.gsub(/ [ ]+$/,'') - s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') - s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') - end - def strip_clean_of_markup(s) # used for digest, define rules, make same as in db clean - #consider: <\/?[ib]>|<(?:\/ )?br>|(.+?)<\/del> - s=s.dup - s=s.gsub(/(?:<\/?[ib]>|#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}|#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|^#{Mx[:lv_o]}[1-6]:\S+?#{Mx[:lv_c]}|#{Mx[:en_a_o]}\d+\s.+?#{Mx[:en_a_c]})/m,'') # markup and endnotes removed - #% same as db clean --> - s=s.gsub(/(.+?)<\/del>/,'DELETED(\1)') # deletions - s=s.gsub(/(\d+)<\/sup>/,'[\1]') - s=s.gsub(/(?:#{Mx[:nbsp]})+/,' ') - #s=s.gsub(//,"[TABLE]\n") # tables - #s=s.gsub(//,'\1') # tables - #s=s.gsub(/¡¡\d+¡/,' ') # tables - #s=s.gsub(/¡/,' ') # tables tidy later - #s=s.gsub(/<.+?>/,'') - s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search - s=s.gsub(/\s\s+/,' ') - s=s.strip - end end end __END__ diff --git a/lib/sisu/v0/dal_character_check.rb b/lib/sisu/v0/dal_character_check.rb new file mode 100644 index 00000000..8cee0a13 --- /dev/null +++ b/lib/sisu/v0/dal_character_check.rb @@ -0,0 +1,112 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end + +module SiSU_character_check + class Check + def initialize(data) + @data=data + @comment='%' + @endnote_array=[] + end + def character_check_and_oldstyle_endnote_array + require 'iconv' + data=@data + #reset + @tuned_file,@endnote_array=[],[] + endnote_no=1 + data.each do |para| + para.strip! + para.gsub!(/^([12])~\?\s+/,'\1~ ') #conditional header for incorporated document 2004w12 + para.gsub!(/^[{~}]\s*$/,'') + para.gsub!(/^#{@comment}.*/,'') #remove comment and divider #% + para.gsub!(/<~#>|~#\s*/,"#{Mx[:fa_o]}~##{Mx[:fa_c]}") + para.gsub!(/-#\s*/,"#{Mx[:fa_o]}-##{Mx[:fa_c]}#{Mx[:fa_o]}~##{Mx[:fa_c]}") + #para.gsub!(/(#\{{3} arch-tag:|0\{{3}~cvs)\s+/, "0{{~rcs ") #KEEP ... ENABLE WIDER USE OF REVISION CONTROL + para.gsub!(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') + para.gsub!(/ \/\//,"#{Mx[:br_line]}") #added 2004w29 + para.gsub!(/
    /,"#{Mx[:br_line]}") #needed by xml, xhtml etc. + para.gsub!(/\t/,' ') + para.gsub!(/\342\200\231/u,"'") #if para =~/’/ #Avoid #‘ ’ #“ ” + para.gsub!(/�/u,' ') #watch, replace with char code + para.gsub!(/·/u,'*') + para.gsub!(/\\copy(?:right)?\b/,'©') + para.gsub!(/\\trademark\b|\\tm\b/,'®') + #non_utf8(para) + para=para + "\n" + unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ + case para + when /\^~/ # endnotes + #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ + sub_para=para.dup + @endnote_array << sub_para.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip + endnote_no+=1 + para=nil if para =~/\^~ .+/ #removes 'binary' endnote now in endnote array for later insertion + end + end + @tuned_file << para unless para.nil? + end + @tuned_file=@tuned_file.flatten + [@tuned_file,@endnote_array] + end + end +end +__END__ diff --git a/lib/sisu/v0/dal_doc_str.rb b/lib/sisu/v0/dal_doc_str.rb index d34bf01e..ac7e2b49 100644 --- a/lib/sisu/v0/dal_doc_str.rb +++ b/lib/sisu/v0/dal_doc_str.rb @@ -59,8 +59,8 @@ =end module SiSU_document_structure - require "#{SiSU_lib}/dal_doc_str_tables" - require "#{SiSU_lib}/dal_doc_str_code" + require "#{SiSU_lib}/dal_doc_str_tables" # dal_doc_str_tables.rb + require "#{SiSU_lib}/dal_doc_str_code" # dal_doc_str_code.rb class Structure def initialize(md,para) @md,@para=md,para diff --git a/lib/sisu/v0/dal_endnotes.rb b/lib/sisu/v0/dal_endnotes.rb new file mode 100644 index 00000000..47f872ec --- /dev/null +++ b/lib/sisu/v0/dal_endnotes.rb @@ -0,0 +1,132 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_endnotes + class Endnotes + def initialize(md,data,endnote_array=nil) + @md,@data,@endnote_array=md,data,endnote_array + @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 + end + def endnotes + data=@data + @tuned_file=[] + endnote_no,endnote_ref=1,1 + #% endnote work zone + data.each do |para| + # manually numbered endnotes --> + if @md.mod.inspect =~/--no-asterisk|--no-annotate/ + para.gsub!(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') + end + if @md.mod.inspect =~/--no-dagger|--no-annotate/ + para.gsub!(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') + end + unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ + case para + # auto-numbered endnotes --> + when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ + para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 + word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) + word_mode=endnote_call_number(word_mode) + para=word_mode.join(' ') + endnote_ref+=1 + when /~\^(?:\s|$)|<:e>/ + #%Note inserts endnotes previously gathered from /^(|[-~]\{{3})/ (in earlier loop) + word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) + word_mode=endnote_call_number(word_mode) + para=word_mode.join(' ') + endnote_ref+=1 + end + end + @tuned_file << para + end + @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 + @tuned_file=@tuned_file.flatten + end + def endnote_call_number(data) + data.each do |word| + unless data =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ + case word + when /#{Mx[:en_a_o]}/ + unless word =~/#{Mx[:en_a_o]}[*+]+/ + word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@endnote_counter} ") + @endnote_counter+=1 + end + when /#{Mx[:en_b_o]}/ + if word =~/#{Mx[:en_b_o]}[+]/ + word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") + @endnote_counter_dag+=1 + else + word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") + @endnote_counter_asterisk+=1 + end + when /~\^|<:e>/ + if @endnote_array + word.gsub!(/~\^|<:e>/,"#{@endnote_array[@endnote_counter-1]}") + @endnote_counter+=1 + end + end + end + end + end + end +end +__END__ + diff --git a/lib/sisu/v0/dal_expand_insertions.rb b/lib/sisu/v0/dal_expand_insertions.rb new file mode 100644 index 00000000..1ab0c03b --- /dev/null +++ b/lib/sisu/v0/dal_expand_insertions.rb @@ -0,0 +1,155 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_insertions + class Insertions + def initialize(data) + @data=data + end + def expand_insertions? + data=@data + tuned_file,tuned_file_tmp=[],[] + data.each do |para| + if para !~/^%+\s/ \ + and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ + txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil + @u=SiSU_Env::Info_env.new.url + if defined? @u.remote + if para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/m + pre,txt,cmd,source,url_dir,note="#{$1.strip} ",$2,$3,$4,$5,$6 + elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/ + pre,txt,cmd,source,url_dir,note='',$1,$2,$3,$4,$5 + end + manifest="#{pre}{#{txt} }#{@u.remote}/#{url_dir}/toc.html#{note}\n\n" + else + puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" + if para =~/\{(?:~\^\s+)?(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ + txt,cmd,url_dir,note=$1,$2,$3,$4 + manifest="{ #{txt} }../#{url_dir}/toc.html#{note}\n\n" + end + end + tuned_file_tmp << manifest + output_filetypes=output_filetypes_in_cmd(cmd,source) + output_filetypes[:gen].each do |o_f| + describe = case o_f + when /sisu_manifest.html/; '~^ document manifest' + when /toc.html/; ' html, segmented text' + when /doc.html/; ' html, scroll, document in one' + when /landscape.pdf/; ' pdf, landscape' + when /portrait.pdf/; ' pdf, portrait' + when /opendocument.odt/; ' odf:odt, open document text' + when /scroll.xhtml/; ' xhtml scroll' + when /sax.xml/; ' xml, sax' + when /dom.xml/; ' xml, dom' + when /plain.txt/; ' plain text utf-8' + #when /manpage.1/; ' man, 1' + when /wiki.txt/; ' wiki text' + when /concordance.html/; ' concordance' + when /digest.txt/; ' dcc, document content certificate (digests)' + else nil + end + if describe + tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry + if describe =~/^~\^ / + "#{Mx[:nbsp]*4} {#{describe} }#{@u.remote}/#{url_dir}/#{o_f} " + else + "#{Mx[:nbsp]*4} { #{describe} }#{@u.remote}/#{url_dir}/#{o_f} " + end + else + if describe =~/^~\^ / + "#{Mx[:nbsp]*4} {#{describe} }../#{url_dir}/#{o_f} " + else "#{Mx[:nbsp]*4} { #{describe} }../#{url_dir}/#{o_f} " + end + end + end + end + output_filetypes[:src].each do |o_f| + describe=case o_f + when /#{source}\.zip/; ' markup source (zipped) pod' + when /#{source}/; ' markup source text' + else nil + end + if describe + tuned_file_tmp << if @u.remote + x=if describe =~/zip/ + "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_pod}/#{o_f} " + else "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_txt}/#{o_f} " + end + else + x=if describe =~/zip/ + "#{Mx[:nbsp]*4} { #{describe} }../pod/#{o_f} " + else "#{Mx[:nbsp]*4} { #{describe} }../zip/#{o_f} " + end + end + end + end + tuned_file << 'group{' << tuned_file_tmp.join("\n") << '}group' + #tuned_file << 'group{' << tuned_file_tmp.join("\n").strip << '}group' + tuned_file_tmp=[] + else tuned_file << para + end + end + tuned_file + end + end +end +__END__ + diff --git a/lib/sisu/v0/dal_hash_digest.rb b/lib/sisu/v0/dal_hash_digest.rb new file mode 100644 index 00000000..7588bd47 --- /dev/null +++ b/lib/sisu/v0/dal_hash_digest.rb @@ -0,0 +1,176 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end + +module SiSU_hash + class Object_digest + def initialize(md,data,env=nil) + @md,@data,@env=md,data,env + @env ||=SiSU_Env::Info_env.new(@md.fns) + end + def object_digest + # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes + # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) + # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) + # [digests should not include other digests] + # vim==/<[0-9a-f]\{#{@@dl}\}\(:[0-9a-f]\{#{@@dl}\}\)\?>/ + require 'digest/md5' + require 'digest/sha2' + data=@data + @tuned_file=[] + data.compact! + data.each do |para| + para.strip! + if para=~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}/ \ + and para !~/#{Rx[:meta]}/ #test should not be necessary remove + if @env.digest.type =~/sha256/ + for hash_class in [ Digest::SHA256 ] + @tuned_file << stamped(para,hash_class) + end + else + for hash_class in [ Digest::MD5 ] + @tuned_file << stamped(para,hash_class) + end + end + else @tuned_file << para unless para.nil? + end + end + @tuned_file=@tuned_file.flatten + #use md5 or to create hash of each dal object including ocn, & add into to each dal object + end + def endnote_digest(data) + para_bit=[] + data.each do |en_plus| + para_bit <<= case en_plus + when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ + if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ + para_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4] + stripped_en=strip_clean_of_markup(en_txt) + digest_en_strip=if @env.digest.type =~/sha256/ + Digest::SHA256.hexdigest(stripped_en) + else + Digest::MD5.hexdigest(stripped_en) + end + para_txt + en_open + en_txt + Mx[:id_o] + digest_en_strip + Mx[:id_c] + en_close + else puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up + end + else en_plus + end + end + para_bit.join + end + def stamped(para,hash_class) + @tuned=[] + para=strip_clean_extra_spaces(para) + digest_all=hash_class.hexdigest(para) # print "#{hash_class.name}: "; puts digest_all #length==32 or 64 + stripped=strip_clean_of_markup(para) + digest_strip=hash_class.hexdigest(stripped) + unless para =~/#{Mx[:fa_o]}code#{Mx[:fa_c]}/ + case para + when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m + en_and_para,en_and_para_digest=[],[] + para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch + para_plus_en=para.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) + para_tail=if para =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m + /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.*?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] + #/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.+?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] + else '' + end + para_plus_en << para_tail + en_and_para_digest << endnote_digest(para_plus_en) + para_new=en_and_para_digest.join(' ') + @tuned << para_new + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? + else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? + end + else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? + end + @tuned.join + end + def strip_clean_extra_spaces(s) # dal output tuned + s=s.dup + s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ + s=s.gsub(/ [ ]+/,' ') + s=s.gsub(/^ [ ]+/,'') + s=s.gsub(/ [ ]+$/,'') + s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') + s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') + end + def strip_clean_of_markup(s) # used for digest, define rules, make same as in db clean + #consider: <\/?[ib]>|<(?:\/ )?br>|(.+?)<\/del> + s=s.dup + s=s.gsub(/(?:<\/?[ib]>|#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}|#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|^#{Mx[:lv_o]}[1-6]:\S+?#{Mx[:lv_c]}|#{Mx[:en_a_o]}\d+\s.+?#{Mx[:en_a_c]})/m,'') # markup and endnotes removed + #% same as db clean --> + s=s.gsub(/(.+?)<\/del>/,'DELETED(\1)') # deletions + s=s.gsub(/(\d+)<\/sup>/,'[\1]') + s=s.gsub(/(?:#{Mx[:nbsp]})+/,' ') + #s=s.gsub(//,"[TABLE]\n") # tables + #s=s.gsub(//,'\1') # tables + #s=s.gsub(/¡¡\d+¡/,' ') # tables + #s=s.gsub(/¡/,' ') # tables tidy later + #s=s.gsub(/<.+?>/,'') + s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search + s=s.gsub(/\s\s+/,' ') + s=s.strip + end + end +end +__END__ + diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index 5e07396a..607686a3 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -80,9 +80,9 @@ module SiSU_book_index idx_array << @rgx_idx_ocn_init.match(para)[0].gsub(@rgx_idx_ocn_init,'\1~\2') if para =~ @rgx_idx_ocn_init tuned_file << para if para end - idx_array.each do |i| - i.gsub!(@rgx_idx_ocn_init,'\1~\2') - end + #idx_array.each do |i| + # i.gsub!(@rgx_idx_ocn_init,'\1~\2') + #end idx_array=construct_idx_array(idx_array) if idx_array.length > 0 if idx_array.length > 0 the_idx=construct_book_index(idx_array) @@ -189,7 +189,7 @@ module SiSU_book_index def clean_index(data) tuned_file=[] data.each do |para| - para.gsub!(@rgx_idx,'') + para.gsub!(/\n*#{@rgx_idx}/m,'') tuned_file << para end tuned_file diff --git a/lib/sisu/v0/dal_images.rb b/lib/sisu/v0/dal_images.rb new file mode 100644 index 00000000..75fa333c --- /dev/null +++ b/lib/sisu/v0/dal_images.rb @@ -0,0 +1,125 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_images + class Images + def initialize(md,data) + @md,@data=md,data + end + def images + data=@data + tuned_file=[] + @rmgk=false + if SiSU_Env::Info_settings.new.program?('rmagick'); @rmgk=SiSU_Env::Load.new('RMagick').prog + else tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') + tell.warn if @md.cmd =~/[vVM]/ + end + data.each do |para| + para.strip! + if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ + if para !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ + m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ + if @rmgk + imgs=para.scan(m).flatten + images=imgs.each do |image| + dir=SiSU_Env::Info_env.new(@md.fns) + path_image=[dir.path.image_source_local_tex,dir.path.image_source_remote_tex,dir.path.image_source_tex] + image_path=nil + path_image.each do |image_path| + break if FileTest.exist?("#{image_path}/#{image}") + end + if FileTest.exist?("#{image_path}/#{image}") + img=Magick::ImageList.new("#{image_path}/#{image}") + img_col,img_row=img.columns,img.rows + if img_col > img_row #landscape + if img_col> 640 #480 + img_col=640 #480 + img_row=((1.00*img_col/img.columns)*img.rows).round + end + else #portrait + if img_col> 640 #480 + img_col=640 #480 + img_row=((1.00*img_col/img.columns)*img.rows).round + end + if img_row > 640 + img_row=640 + img_col=((1.00*img_row/img.rows)*img.columns).round + end + end + para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") + else para.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') + end + end + else + images=para.scan(m) do |image| + tell=SiSU_Screen::Ansi.new(@md.cmd,'where image dimensions have not been provided RMagick is required',image) + tell.warn #unless @opt.cmd =~/q/ + end + end + end + end + para.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ + tuned_file << para unless para.nil? + end + tuned_file + end + end +end +__END__ diff --git a/lib/sisu/v0/dal_metadata.rb b/lib/sisu/v0/dal_metadata.rb new file mode 100644 index 00000000..900c5495 --- /dev/null +++ b/lib/sisu/v0/dal_metadata.rb @@ -0,0 +1,228 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_metadata + class Metadata + def initialize(md,data) + @md,@data=md,data + l=SiSU_Env::Standardise_language.new.file_to_language(md.fns) + language=l[:l] + @tr=SiSU_Translate::Source.new(md,language) + end + def metadata + data=@data + meta,@dc,@rc,@cvs,dctitle,add=Array.new(6){[]} + dir=SiSU_Env::Info_env.new(@md.fns) + base_html="#{dir.url.root}/#{@md.fnb}" + ocnm=ocnd=ocnv=0 + ocnm+=1 + header1="\n#{Mx[:lv_o_1]}meta#{Mx[:lv_c]}Document Information (metadata) #{Mx[:id_o]}~0;0:0;m#{ocnm}#{Mx[:id_c]}" + ocnm+=1 + header4="\n#{Mx[:lv_o_4]}metadata#{Mx[:lv_c]}Metadata #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" + ocnm+=1; ocnd+=1 + head_no_dc="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + ocnm+=1; ocnd+=1 + head_no_dc_tag="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + data.each do |para| + case para + when /^#{Mx[:meta_o]}(title|creator|author|translator|translated_by|illustrator|illustrated_by|prepared_by|digitized_by|description|publisher|contributor|date\.created|date\.issued|date\.available|date\.valid|date\.modified|date|type|format|rights|identifier|source|language)#{Mx[:meta_c]}/i + m=$1 + ocnm+=1; ocnd+=1 + @dc << case para + when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/ + "\n#{@tr.dc_title}: #{Mx[:fa_underscore_o]}#{@md.dc_title}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}(?:creator|author)#{Mx[:meta_c]}/ + "\n#{@tr.creator}: #{Mx[:fa_underscore_o]}#{@md.dc_creator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /#{Mx[:meta_o]}(?:translator|translated_by)#{Mx[:meta_c]}/ + "\n#{@tr.translator}: #{Mx[:fa_underscore_o]}#{@md.translator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}(?:illustrator|illustrated_by)#{Mx[:meta_c]}/ + "\n#{@tr.illustrator}: #{Mx[:fa_underscore_o]}#{@md.illustrator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}prepared_by#{Mx[:meta_c]}/ + "\n#{@tr.prepared_by}: #{Mx[:fa_underscore_o]}#{@md.prepared_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}digitized_by#{Mx[:meta_c]}/ + "\n#{@tr.digitized_by}: #{Mx[:fa_underscore_o]}#{@md.digitized_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}description#{Mx[:meta_c]}/ + "\n#{@tr.description}: #{Mx[:fa_underscore_o]}#{@md.dc_description}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}subject#{Mx[:meta_c]}/ + "\n#{@tr.subject}: #{Mx[:fa_underscore_o]}#{@md.dc_subject}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}abstract#{Mx[:meta_c]}/ + "\n#{@tr.abstract}: #{Mx[:fa_underscore_o]}#{@md.dc_abstract}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}publisher#{Mx[:meta_c]}/ + "\n#{@tr.publisher}: #{Mx[:fa_underscore_o]}#{@md.dc_publisher}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}contributor#{Mx[:meta_c]}/ + "\n#{@tr.contributor}: #{Mx[:fa_underscore_o]}#{@md.dc_contributor}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}date.created#{Mx[:meta_c]}/ + "\n#{@tr.date_created}: #{Mx[:fa_underscore_o]}#{@md.dc_date_created}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}date.issued#{Mx[:meta_c]}/ + "\n#{@tr.date_issued}: #{Mx[:fa_underscore_o]}#{@md.dc_date_issued}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}date.available#{Mx[:meta_c]}/ + "\n#{@tr.date_available}: #{Mx[:fa_underscore_o]}#{@md.dc_date_available}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}date.modified#{Mx[:meta_c]}/ + "\n#{@tr.date_modified}: #{Mx[:fa_underscore_o]}#{@md.dc_date_modified}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}date.valid#{Mx[:meta_c]}/ + "\n#{@tr.date_valid}: #{Mx[:fa_underscore_o]}#{@md.dc_date_valid}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}date#{Mx[:meta_c]}/ + "\n#{@tr.date}: #{Mx[:fa_underscore_o]}#{@md.dc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}type#{Mx[:meta_c]}/ + "\n#{@tr.type}: #{Mx[:fa_underscore_o]}#{@md.dc_type}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}format#{Mx[:meta_c]}/ + "\n#{@tr.format}: #{Mx[:fa_underscore_o]}#{@md.dc_format}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}rights#{Mx[:meta_c]}/ + "\n#{@tr.rights}: #{Mx[:fa_underscore_o]}#{@md.dc_rights}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}identifier#{Mx[:meta_c]}/ + "\n#{@tr.identifier}: #{Mx[:fa_underscore_o]}#{@md.dc_identifier}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}source#{Mx[:meta_c]}/ + "\n#{@tr.source}: #{Mx[:fa_underscore_o]}#{@md.dc_source}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}language#{Mx[:meta_c]}/ + "\n#{@tr.language}: #{Mx[:fa_underscore_o]}#{@md.dc_language}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}language.original#{Mx[:meta_c]}/ + "\n#{@tr.language_original}: #{Mx[:fa_underscore_o]}#{@md.language_original}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}relation#{Mx[:meta_c]}/ + "\n#{@tr.relation}: #{Mx[:fa_underscore_o]}#{@md.dc_relation}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}coverage#{Mx[:meta_c]}/ + "\n#{@tr.coverage}: #{Mx[:fa_underscore_o]}#{@md.dc_coverage}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}keywords#{Mx[:meta_c]}/ + "\n#{@tr.keywords}: #{Mx[:fa_underscore_o]}#{@md.keywords}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}comments#{Mx[:meta_c]}/ + "\n#{@tr.comments}: #{Mx[:fa_underscore_o]}#{@md.comments}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}cls_loc#{Mx[:meta_c]}/ + "\n#{@cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}cls_dewey#{Mx[:meta_c]}/ + "\n#{@tr.cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}(?:cls_gutenberg|cls_pg)#{Mx[:meta_c]}/ + "\n#{@tr.cls_gutenberg}: #{Mx[:fa_underscore_o]}#{@md.cls_gutenberg}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + #"\n#{@tr.cls_gutenberg}: #{@md.cls_pg} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}cls_isbn#{Mx[:meta_c]}/ + "\n#{@tr.cls_isbn}: #{Mx[:fa_underscore_o]}#{@md.cls_isbn}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}prefix(?:_a)?#{Mx[:meta_c]}/ + "\n#{@tr.prefix_a}: #{Mx[:fa_underscore_o]}#{@md.prefix_a}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + when /^#{Mx[:meta_o]}prefix_b#{Mx[:meta_c]}/ + "\n#{@tr.prefix_b}: #{Mx[:fa_underscore_o]}#{@md.prefix_b}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" + else para.gsub(/^#{Mx[:meta_o]}(#{m})\s+(.+)/m,"\n#{m.capitalize}: #{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}") + end + end + end + ocnm+=1; ocnv+=1 + head_no_rc="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + head_no_rc_tag="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + data.each do |para| + case para + when /^0~(?:cvs|rcs)\+\s+/ #note the + sign to turn on use of cvs id + ocnm+=1; ocnv+=1 + @cvs << "#{@tr.sc_number}: #{Mx[:fa_underscore_o]}#{@md.sc_number}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + @cvs << "#{@tr.sc_date}: #{Mx[:fa_underscore_o]}#{@md.sc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + @cvs << "CVS/RCS time: #{Mx[:fa_underscore_o]}#{@md.sc_time}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + when /^0~cvs[+\s]/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP + when /^0~cvs\s+/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP + end + end + if true #default version information + ocnm+=1; ocnv+=1 + if @md.sc_filename \ + and @md.sc_filename.length > 3 + @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.sc_filename}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + else @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.fns}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + end + ocnm+=1; ocnv+=1 + if @md.file_encoding \ + and @md.file_encoding.length > 3 #translate + @rc << "Filetype: #{Mx[:fa_underscore_o]}#{@md.file_encoding}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + end + ocnm+=1; ocnv+=1 + if @md.dgst #change. enable by default + @rc << "#{@tr.sourcefile_digest}, #{@md.dgst[0]} #{Mx[:fa_underscore_o]}#{@md.dgst[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + end + if @md.dgst_skin #change. enable by default + @rc << "Skin_Digest: #{@md.dgst_skin[0]} #{Mx[:fa_underscore_o]}#{@md.dgst_skin[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + end + @rc << "#{Mx[:fa_bold_o]}Generated#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 + @rc << "#{@tr.last_generated}: #{Mx[:fa_underscore_o]}#{Time.now}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + if @md.sisu_version[:version] + @rc << "#{@tr.sisu_version}: #{Mx[:fa_underscore_o]}#{@md.sisu_version[:project]}#{Mx[:fa_underscore_c]} #{Mx[:fa_underscore_o]}#{@md.sisu_version[:version]}#{Mx[:fa_underscore_c]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]}) #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + ocnm+=1; ocnv+=1 + end + @rc << "#{@tr.ruby_version}: #{Mx[:fa_underscore_o]} #{@md.ruby_version}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" + end + meta << Mx[:br_page_new] << header1 << header4 + meta << "Document Manifest @\n #{base_html}/#{@md.fn[:manifest]} #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" + meta << "#{Mx[:fa_bold_o]}Dublin Core#{Mx[:fa_bold_c]} (DC) #{head_no_dc}" if @dc.length > 0 + meta << "#{Mx[:fa_italics_o]}DC tags included with this document are provided here.#{Mx[:fa_italics_c]} #{head_no_dc_tag}" if @dc.length > 0 + @dc.each { |x| meta << x } + meta << "#{Mx[:fa_bold_o]}Version Information#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 + if @cvs.length > 0 + meta << "#{Mx[:fa_italics_o]}Note the version information provided here, is specific to the host site.#{Mx[:fa_italics_c]} #{head_no_rc_tag}" + @cvs.each { |x| meta << x } + end + @rc.each { |x| meta << x } + ## ENDNOTE RELATED endnote related + meta << "\n#{Mx[:br_eof]}" + meta=SiSU_hash::Object_digest.new(@md,meta,@env).object_digest + end + end +end +__END__ diff --git a/lib/sisu/v0/dal_numbering.rb b/lib/sisu/v0/dal_numbering.rb index e14b87d7..fd873da2 100644 --- a/lib/sisu/v0/dal_numbering.rb +++ b/lib/sisu/v0/dal_numbering.rb @@ -67,7 +67,7 @@ module SiSU_numbering def numbering_song data=@data data=number_plaintext_para(data) - #data=name_endnote_seg(data) #tr issue + data=name_endnote_seg(data) #tr issue data=auto_number_heading_ie_title(data) #tr issue data=ocn(data) #watch data=minor_numbering(data) @@ -90,13 +90,13 @@ module SiSU_numbering @tuned_file=@tuned_file.flatten end def name_endnote_seg(data) - @tuned_file=[] + tuned_file=data if @md.flag_auto_endnotes \ and @md.flag_separate_endnotes_make - @tuned_file << "\n#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}Endnotes #{Mx[:gl_o]}-##{Mx[:gl_c]} #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" + tuned_file << "\n#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}Endnotes #{Mx[:gl_o]}-##{Mx[:gl_c]} #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" end - @tuned_file << "\n#{Mx[:br_endnotes]}" #DECIDE ON - @tuned_file=@tuned_file.flatten + tuned_file << "\n#{Mx[:br_endnotes]}" #DECIDE ON + tuned_file=tuned_file.flatten end def owner_details_seg data << "#{Mx[:lv_o]}4:owner.details#{Mx[:lv_c]}Owner Details" diff --git a/lib/sisu/v0/dal_substitutions_and_insertions.rb b/lib/sisu/v0/dal_substitutions_and_insertions.rb new file mode 100644 index 00000000..dad07ec9 --- /dev/null +++ b/lib/sisu/v0/dal_substitutions_and_insertions.rb @@ -0,0 +1,131 @@ +# 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 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_substitute_and_insert + class SI + def initialize(md,data) + @md,@data=md,data + end + def substitutions_and_insertions? + data=@data + data_expand=[] + if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) + data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'') + data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'') + end + if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier + data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1') + data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1') + end + data.each do |para| + if para =~/<:insert\d+!?>/ \ + and para !~/^%\s+/ + @skin.select + ins=SiSU_Viz::Inserts.new + case para + when /^\s*<:insert1>\s*$/ + para=[] + ins.insert1.split(/\n\n/).each{|x| para << x } + when /^\s*<:insert2>\s*$/ + para=[] + ins.insert2.split(/\n\n/).each{|x| para << x } + when /^\s*<:insert3>\s*$/ + para=[] + ins.insert3.split(/\n\n/).each{|x| para << x << "\n"} + para=ins.insert3 + when /^\s*<:insert4>\s*$/ + para=[] + ins.insert4.split(/\n\n/).each{|x| para << x << "\n"} + para=ins.insert4 + when /^\s*<:insert5>\s*$/ + para=[] + ins.insert5.split(/\n\n/).each{|x| para << x << "\n"} + when /^\s*<:insert6>\s*$/ + para=[] + ins.insert6.split(/\n\n/).each{|x| para << x << "\n"} + when /^\s*<:insert7>\s*$/ + para=[] + ins.insert7.split(/\n\n/).each{|x| para << x << "\n"} + end + para.each{|x| data_expand << x } + else data_expand << para + end + data_expand.flatten! + data_expand.compact! + end + data_expand.each do |para| + para=if @md.markup_version.to_f >= 0.38 + SiSU_document_structure::Structure.new(@md,para).structure_markup_normalize + else + SiSU_document_structure::Structure.new(@md,para).structure_marks + end + #para.gsub!(//,'\1') #consider, would permit use of text hyperlinks if desired, dal_syntax more appropriate? + para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 + if para =~/^@\S+?:/ + para.gsub!(/^@(\S+?):\s+/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}") + para.gsub!(/^@(\S+?):([+-])\s+/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}") + end + end + end + end +end +__END__ + -- cgit v1.2.3 From 1529e474fd5c8a67679438e8f2cea5cd6d26db3d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 8 Sep 2008 23:09:37 -0400 Subject: book index, sample html file and to screen sisu markup sample added (-M flag) --- lib/sisu/v0/css.rb | 12 +++++ lib/sisu/v0/dal.rb | 2 +- lib/sisu/v0/dal_idx.rb | 144 +++++++++++++++++++++++++++++++++++++++++++------ lib/sisu/v0/sysenv.rb | 3 +- 4 files changed, 143 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index b5b08698..ec71c4f3 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -358,6 +358,18 @@ WOK margin-top: 1px; margin-bottom: 3px; } + p.book_index_lev1 { + line-height: 100%; + margin-top: 4px; + margin-bottom: 1px; + } + p.book_index_lev2 { + line-height: 100%; + text-align: left; + margin-left: 3em; + margin-top: 1px; + margin-bottom: 3px; + } p.quickref { font-size: 10px; diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index d091284d..a00d307b 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -209,7 +209,7 @@ module SiSU_DAL data=SiSU_images::Images.new(@md,data).images data=SiSU_document_structure::Tables.new(@md,data).tables data=SiSU_numbering::Numbering.new(@md,data).numbering_song - data=SiSU_book_index::Book_index.new(data).indexing_song if @md.book_index + data=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_index data=SiSU_endnotes::Endnotes.new(@md,data,endnote_array).endnotes data=SiSU_hash::Object_digest.new(@md,data,@env).object_digest meta=SiSU_metadata::Metadata.new(@md,data).metadata diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index 607686a3..26fc66b6 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -61,14 +61,21 @@ =end module SiSU_book_index class Book_index - def initialize(data) - @data=data - end - def indexing_song + def initialize(md,data,env=nil) + @md,@data,@env=md,data,env @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ #@rgx_idx=/\s*#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ @rgx_idx_ocn_init=/#{Mx[:idx_o]}(.+?)#{Mx[:idx_c]}\s*#{Mx[:id_o]}~(\d+)\S+?#{Mx[:id_c]}/ + @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ @rgx_idx_ocn=/(.+?)~(\d+)/ + @rxp_lv1=/^#{Mx[:lv_o]}1:/ + @rxp_lv2=/^#{Mx[:lv_o]}2:/ + @rxp_lv3=/^#{Mx[:lv_o]}3:/ + @rxp_seg=/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/ + @rxp_to=Regexp.new("#{Mx[:id_o]}~(\\d+);(?:[oh]|[0-6]:)\\d+;\\w\\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|#{Mx[:id_o]}\S+?#{Mx[:id_c]}$") + @env ||=SiSU_Env::Info_env.new(@md.fns) + end + def indexing_song @data=extract_book_index(@data) @data=clean_index(@data) @data @@ -77,7 +84,9 @@ module SiSU_book_index tuned_file=[] idx_array=[] data.each do |para| - idx_array << @rgx_idx_ocn_init.match(para)[0].gsub(@rgx_idx_ocn_init,'\1~\2') if para =~ @rgx_idx_ocn_init + if para =~@rxp_seg; @seg=para[@rxp_seg,1] + end + idx_array << @rgx_idx_ocn_init.match(para)[0].gsub(@rgx_idx_ocn_init,"\\1~\\2~#{@seg}") if para =~ @rgx_idx_ocn_init tuned_file << para if para end #idx_array.each do |i| @@ -85,23 +94,32 @@ module SiSU_book_index #end idx_array=construct_idx_array(idx_array) if idx_array.length > 0 if idx_array.length > 0 - the_idx=construct_book_index(idx_array) - screen_print(the_idx) + if @md.cmd.inspect =~/M/ + the_idx=construct_book_index(idx_array) + screen_print(the_idx) if @md.cmd.inspect =~/M/ + puts "\n---" + path="#{@env.path.output}/#{@md.fnb}" + @file_index_all=File.open("#{path}/#{@md.fn[:book_index]}",'w') + screen_html(the_idx) + @file_index_all.close + puts "\n---" + screen_sisu_markup(the_idx) + end end tuned_file end def construct_idx_array(idx_array) idx_lst=[] idx_array.each do |idx| - idx_list,ocn=@rgx_idx_ocn.match(idx)[1,2] + idx_list,ocn,seg=@rgx_idx_ocn_seg.match(idx)[1..3] idx_lst <<=if idx_list =~/;/ g=idx_list.scan(/[^;]+/) idxl=[] g.each do |i| - idxl << { :rough_idx => i, :ocn => ocn } + idxl << { :rough_idx => i, :ocn => ocn, :seg => seg } end idxl - else { :rough_idx => idx_list, :ocn => ocn } + else { :rough_idx => idx_list, :ocn => ocn, :seg => seg } end end idx_lst.flatten! @@ -122,20 +140,20 @@ module SiSU_book_index x=if idx_lst.length == 1 or idx_lst[0] == i @the_idx[use]['a1']=[] unless @the_idx[use]['a1'] and defined? @the_idx[use]['a1'] x=if r - @the_idx[use]['a1'] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" } + @the_idx[use]['a1'] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", :seg => idx[:seg] } "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" else - @the_idx[use]['a1'] << { :ocn => idx[:ocn] } + @the_idx[use]['a1'] << { :ocn => idx[:ocn], :seg => idx[:seg] } "#{i} #{idx[:ocn]}" end else @the_idx[use]['b1']={} unless @the_idx[use]['b1'] and defined? @the_idx[use]['b1'] @the_idx[use]['b1'][i]=[] unless @the_idx[use]['b1'][i] and defined? @the_idx[use]['b1'][i] x=if r - @the_idx[use]['b1'][i] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" } + @the_idx[use]['b1'][i] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", :seg => idx[:seg] } "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" else - @the_idx[use]['b1'][i] << { :ocn => idx[:ocn] } + @the_idx[use]['b1'][i] << { :ocn => idx[:ocn], :seg => idx[:seg] } "#{idx_lst[0]}:#{i} #{idx[:ocn]}" end end @@ -186,6 +204,102 @@ module SiSU_book_index end end end + def screen_html(the_idx) + @file_index_all << %{\n } + the_idx.each do |i| + i.each do |x| + if x.class == String + @file_index_all << %{\n

    #{x}, } + #@file_index_all << %{
    \n#{x}, } + print %{
    \n#{x}, } + elsif x.class == Array + p 'array error? -->' + print x + elsif x.class == Hash + if x['a1'].class == Array + x['a1'].each do |a| + if a[:range] + @file_index_all << %{
    #{a[:range]}, } + print %{#{a[:range]}, } + elsif a[:ocn] + @file_index_all << %{#{a[:ocn]}, } + print %{#{a[:ocn]}, } + else p 'error' + end + end + @file_index_all << '

    ' + end + if x['b1'] + m=x['b1'] + m=m.sort + m.each do |k,y| + if k !~/a1/ + @file_index_all << %{\n

    #{k}, } + #@file_index_all << %{
    \n\t#{k}, } + print %{
    \n\t#{k}, } + #p y + y.each do |z| + if z[:range] + @file_index_all << %{#{z[:range]}, } + print %{#{z[:range]}, } + elsif z[:ocn] + @file_index_all << %{#{z[:ocn]}, } + print %{#{z[:ocn]}, } + else p 'error' + end + end + @file_index_all << '

    ' + end + end + end + end + end + end + end + def screen_sisu_markup(the_idx) + the_idx.each do |i| + i.each do |x| + if x.class == String + print %{\n\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, } + #print %{\n\n#{Mx[:gr_o]}\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, } + #print "\n" + x + ', ' + elsif x.class == Array + p 'array error? -->' + print x + elsif x.class == Hash + if x['a1'].class == Array + x['a1'].each do |a| + if a[:range] + print %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } + elsif a[:ocn] + print %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } + else p 'error' + end + end + end + if x['b1'] + m=x['b1'] + m=m.sort + m.each do |k,y| + if k !~/a1/ + print %{\n #{k}, } + #print "\n\t" + k + ', ' + y.each do |z| + if z[:range] + print %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } + elsif z[:ocn] + print %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } + else p 'error' + end + end + puts " #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" + end + end + end + end + end + end + end def clean_index(data) tuned_file=[] data.each do |para| @@ -196,6 +310,4 @@ module SiSU_book_index end end end - __END__ - diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index ed0012e2..93e6ea8e 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -518,7 +518,8 @@ module SiSU_Env :sxs => filename(code,@fnb,'.sxs.xml'), :sxd => filename(code,@fnb,'.sxd.xml'), :sxn => filename(code,@fnb,'.sxn.xml'), - :sisupod => filename(nil,@fnz,'') + :sisupod => filename(nil,@fnz,''), + :book_index => filename(code,'book_index','.html'), } @fn end -- cgit v1.2.3 From 291080c0495f59f031bf5c0de2482f1bc7df59f2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 10 Sep 2008 21:24:31 -0400 Subject: primarily on book index where (markup) provided * book index, html, tex/pdf, xml * texpdf no ocn if ocn is 0 * odf, plaintext, if book index? remove ... do other outputs for which not relevant * concordance, better matches * constants, dal special character for hardspace changed as (ruby) regx bug in replacing it in xml, odd but move on Note: to fix html seg headers for endnotes and for index --- lib/sisu/v0/concordance.rb | 22 +++--- lib/sisu/v0/constants.rb | 2 +- lib/sisu/v0/dal.rb | 56 +++++++++++++-- lib/sisu/v0/dal_idx.rb | 157 ++++++++++++++++++++----------------------- lib/sisu/v0/dal_syntax.rb | 1 + lib/sisu/v0/html.rb | 3 - lib/sisu/v0/html_segments.rb | 86 ++++++++++++++---------- lib/sisu/v0/odf.rb | 1 + lib/sisu/v0/particulars.rb | 13 +++- lib/sisu/v0/plaintext.rb | 1 + lib/sisu/v0/shared_xml.rb | 4 +- lib/sisu/v0/sysenv.rb | 6 ++ lib/sisu/v0/texpdf.rb | 1 + 13 files changed, 211 insertions(+), 142 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 485f3df5..fad91d14 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -121,8 +121,8 @@ WOK end def create head_banner=SiSU_HTML_Format::Head_toc.new(@md) -minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet -toc='
    ' + minitoc.to_s + '
    ' + minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet + toc='
    ' + minitoc.to_s + '
    ' < @@ -199,7 +199,8 @@ WOK @rxp_t3=Regexp.new('^T3') @rxp_excluded1=/(?:https?|file|ftp):\/\/\S+/ @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#@dp|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! - @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|#{Mx[:id_o]}\S+?#{Mx[:id_c]}|\w+|[a-zA-Z]+}mi + @rgx_splitlist=%r{[—.,;:-]|#{Mx[:id_o]}\S+?#{Mx[:id_c]}}mi + @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|\w+|[a-zA-Z]+}mi rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error end end @@ -223,13 +224,13 @@ WOK @sfx='.html' #used for hardlinks, previous setting @sfx='', web server takes care of suffix @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}#\\2") unless wordlocation.nil? case @wordlocation - when @rxp_t1 - %{[H]#@show, } - when @rxp_t2 - %{[H]#@show, } - when @rxp_t3 - %{[H]#@show, } - else %{#@show, } + when @rxp_t1 + %{[H]#@show, } + when @rxp_t2 + %{[H]#@show, } + when @rxp_t3 + %{[H]#@show, } + else %{#@show, } end end def map_para @@ -243,6 +244,7 @@ WOK end if toy =~/\d+/ \ and toy !~/^0$/ + line=line.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.scan(@rgx_scanlist) #%take in word or other match #word.gsub!(@rxp_clean,'') word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'') diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index 3f050df7..414732e1 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -91,7 +91,7 @@ Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}" Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph) Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) Mx[:idx_o]='▢ '; Mx[:idx_c]='▢ ' # -Mx[:nbsp]= '▭ ' +Mx[:nbsp]= '░' #'▭ ' Mx[:br_line]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_paragraph]= "#{Mx[:mk_o]}br#{Mx[:mk_c]}" Mx[:br_nl]= "#{Mx[:mk_o]}nl#{Mx[:mk_c]}" diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index a00d307b..c01c2d0a 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -87,13 +87,14 @@ module SiSU_DAL end end class Source 0 if idx_array.length > 0 - if @md.cmd.inspect =~/M/ - the_idx=construct_book_index(idx_array) - screen_print(the_idx) if @md.cmd.inspect =~/M/ - puts "\n---" - path="#{@env.path.output}/#{@md.fnb}" - @file_index_all=File.open("#{path}/#{@md.fn[:book_index]}",'w') - screen_html(the_idx) - @file_index_all.close - puts "\n---" - screen_sisu_markup(the_idx) + the_idx=construct_book_index(idx_array) + #screen_print(the_idx) if @md.cmd.inspect =~/V/ + sisu_markup_idx,html_idx=nil,nil + if @md.book_index + idx=index(the_idx) + output_html_idx(idx[:html]) + html_idx=idx[:html] + sisu_markup_idx=idx[:sst] end end - tuned_file + [tuned_file,sisu_markup_idx,html_idx] + end + def output_html_idx(html_idx) + if @md.book_index + path="#{@env.path.output}/#{@md.fnb}" + Dir.mkdir(path) unless FileTest.directory?(path) + html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') + puts "#{path}/#{@md.fn[:book_index]}" + #html_file(the_idx) + html_idx.each {|x| html_index_file << x } + html_index_file.close + end end def construct_idx_array(idx_array) idx_lst=[] @@ -163,11 +170,22 @@ module SiSU_book_index #p the_idx; p '-----' the_idx end - def screen_print(the_idx) + def index(the_idx) + @x=1 + @idx={} + @idx[:sst],@idx[:html]=[],[] + @idx[:sst] << "\n\n#{Mx[:br_page_new]}" + @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" + @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" the_idx.each do |i| i.each do |x| if x.class == String - print "\n" + x + ', ' + @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + aname=x.gsub(/\s+/,'_') + @idx[:html] << %{\n

    #{x}, } + @o=@idx[:sst].index(@idx[:sst].last) #@o=@idx[:sst].length - 1 + @q=@idx[:html].index(@idx[:html].last) #@o=@idx[:html].length - 1 + print "\n" + x + ', ' if @md.cmd =~/V/ elsif x.class == Array p 'array error? -->' print x @@ -175,43 +193,55 @@ module SiSU_book_index if x['a1'].class == Array x['a1'].each do |a| if a[:range] - print a[:range] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{a[:range]}, } + print a[:range] + ', ' if @md.cmd =~/V/ elsif a[:ocn] - print a[:ocn] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{a[:ocn]}, } + print a[:ocn] + ', ' if @md.cmd =~/V/ else p 'error' end end + @idx[:html][@q]=@idx[:html][@q] + '

    ' end if x['b1'] m=x['b1'] m=m.sort m.each do |k,y| if k !~/a1/ - print "\n\t" + k + ', ' - #p y + @idx[:sst][@o]=@idx[:sst][@o] + %{#{k}, } + @idx[:html][@q]=@idx[:html][@q] + %{\n

    #{k}, } + print "\n\t" + k + ', ' if @md.cmd =~/V/ y.each do |z| if z[:range] - print z[:range] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{z[:range]}, } + print z[:range] + ', ' if @md.cmd =~/V/ elsif z[:ocn] - print z[:ocn] + ', ' + @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } + @idx[:html][@q]=@idx[:html][@q] + %{#{z[:ocn]}, } + print z[:ocn] + ', ' if @md.cmd =~/V/ else p 'error' end end + @idx[:html][@q]=@idx[:html][@q] + '

    ' end end end + @idx[:sst][@o]=@idx[:sst][@o] + " #{Mx[:id_o]}~0;0:0;x#{@x}#{Mx[:id_c]}" + @x +=1 end end end + print "\n" if @md.cmd =~/V/ + @idx end - def screen_html(the_idx) - @file_index_all << %{\n } + def screen_print(the_idx) the_idx.each do |i| i.each do |x| if x.class == String - @file_index_all << %{\n

    #{x}, } - #@file_index_all << %{
    \n#{x}, } - print %{
    \n#{x}, } + print "\n" + x + ', ' elsif x.class == Array p 'array error? -->' print x @@ -219,36 +249,28 @@ module SiSU_book_index if x['a1'].class == Array x['a1'].each do |a| if a[:range] - @file_index_all << %{#{a[:range]}, } - print %{#{a[:range]}, } + print a[:range] + ', ' elsif a[:ocn] - @file_index_all << %{#{a[:ocn]}, } - print %{#{a[:ocn]}, } + print a[:ocn] + ', ' else p 'error' end end - @file_index_all << '

    ' end if x['b1'] m=x['b1'] m=m.sort m.each do |k,y| if k !~/a1/ - @file_index_all << %{\n

    #{k}, } - #@file_index_all << %{
    \n\t#{k}, } - print %{
    \n\t#{k}, } + print "\n\t" + k + ', ' #p y y.each do |z| if z[:range] - @file_index_all << %{#{z[:range]}, } - print %{#{z[:range]}, } + print z[:range] + ', ' elsif z[:ocn] - @file_index_all << %{#{z[:ocn]}, } - print %{#{z[:ocn]}, } + print z[:ocn] + ', ' else p 'error' end end - @file_index_all << '

    ' end end end @@ -256,49 +278,18 @@ module SiSU_book_index end end end - def screen_sisu_markup(the_idx) - the_idx.each do |i| - i.each do |x| - if x.class == String - print %{\n\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, } - #print %{\n\n#{Mx[:gr_o]}\n#{Mx[:fa_bold_o]}#{x}#{Mx[:fa_bold_c]}, } - #print "\n" + x + ', ' - elsif x.class == Array - p 'array error? -->' - print x - elsif x.class == Hash - if x['a1'].class == Array - x['a1'].each do |a| - if a[:range] - print %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } - elsif a[:ocn] - print %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } - else p 'error' - end - end - end - if x['b1'] - m=x['b1'] - m=m.sort - m.each do |k,y| - if k !~/a1/ - print %{\n #{k}, } - #print "\n\t" + k + ', ' - y.each do |z| - if z[:range] - print %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } - elsif z[:ocn] - print %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } - else p 'error' - end - end - puts " #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" - end - end - end + def clean_and_insert_index(data,sisu_markup_idx) + tuned_file=[] + data.each do |para| + para.gsub!(/\n*#{@rgx_idx}/m,'') + tuned_file << para + if para =~/#{Mx[:br_endnotes]}/ and sisu_markup_idx + sisu_markup_idx.each do |idx| + tuned_file << idx end end end + tuned_file end def clean_index(data) tuned_file=[] diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 80635f36..cbcd42f9 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -357,6 +357,7 @@ module SiSU_Syntax line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert

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

    back, clumsy line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") + line else # 0~ end line diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index e73157bd..df53d1b7 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -173,9 +173,6 @@ module SiSU_HTML @md.file_type='html' if @md.cmd =~/[hon]/ directories newfilename=%{#{@env.path.output}/#{@md.fnb}/#{@md.fn[:index]}} if @md.file_type =~/html/ - my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) - @fnm=my_make_source_file.marshal_meta - @tune_verse_marshal=my_make_source_file.marshal_tune dal_array=@particulars.dal_array # dal file drawn here @tuned_file_array=SiSU_Tune::Tune.new(dal_array,@md).songsheet @tuned_file_array diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 8d89de28..796c3939 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -62,14 +62,43 @@ module SiSU_HTML_seg require "#{SiSU_lib}/shared_html" require "#{SiSU_lib}/html" require "#{SiSU_lib}/html_promo" + class Seg_output + def initialize(outputfile,seg,minitoc,type='') + @output_seg_file,@seg,@minitoc,@type=outputfile,seg,minitoc,type + end + def output #CONSIDER + if @seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... + filename_seg=[] + filename_seg << @seg[:title] << @seg[:tocband_banner] + if @type =~/endnote/ +#p @seg[:headers] #FIX endnote header + filename_seg << @seg[:header_endnotes] << @minitoc << @seg[:headers] << %{\n
    \n} << @seg[:endnote_all] << '
    ' # << '' + elsif @type =~/idx/ +#p @seg[:headers] #FIX inserted index header + filename_seg << @seg[:header_idx] << @minitoc << @seg[:headers] << %{\n
    \n} << @seg[:idx] << '
    ' # << '' + else + filename_seg << @minitoc << @seg[:headers] << @seg[:main] << "\n\n" + end + filename_seg << @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits] + filename_seg.flatten!.compact! + filename_seg.each do |para| + unless para =~/\A\s*\Z/ + para.strip! + @output_seg_file << para + end + end + @output_seg_file.close + end + end + end class Seg @@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{} - @@seg_name,@@seg_name_html,@@seg_name_php=[],[],[] - @@filename_seg=@@filename_segphp=@@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn='' + @@seg_name,@@seg_name_html=[],[] + @@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn='' @@loop_count=@@seg_total=@@tracker=0 @@is4=@@is3=@@is2=@@is1=0 @@header1=@@header2=@@header3=@@header4=0 - @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(10){[]} + @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(11){[]} @@seg[:header_endnotes]='' @@tablehead,@@number_of_cols=0,0 @@flag_alt=false @@ -85,7 +114,7 @@ module SiSU_HTML_seg end def songsheet begin - @@minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc + @minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc data=get_subtoc_endnotes(@data) data=articles(data) Seg.new.cleanup # (((( added )))) @@ -103,6 +132,13 @@ module SiSU_HTML_seg @h_sfx='.php' if @md.file_type =~/php/ @h_sfx=@md.sfx if @md.file_type =~/html/ @h_sfx='.html' if @md.file_type =~/html/ #used in creating file, not to be omitted. + idx_html=nil + if @md.book_index + my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) + idx_html=SiSU_Particulars::Combined_singleton.instance.get_html_idx(@md.opt).html_idx + idx_html.each {|x| @@seg[:idx] << x } + @@seg[:header_idx]='' + end data.each do |para| if para =~/^#{Mx[:lv_o]}4:/ @@seg_name << para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/,1] @@ -153,20 +189,24 @@ module SiSU_HTML_seg mkdir_p(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!! Seg.new('',@md).tail segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" - @@filename_seg=File.new(segfilename,'w') if @@seg_name_html[tracking-1] - unless (@@seg_name_html[tracking-1] =~/endnotes/) - Seg.new.output - else Seg.new.output('endnotes') + @output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] + if @@seg_name_html[tracking-1] !~/endnotes|idx/ + Seg_output.new(@output_seg_file,@@seg,@minitoc).output + elsif @@seg_name_html[tracking-1] =~/endnotes/ + Seg_output.new(@output_seg_file,@@seg,@minitoc,'endnotes').output + elsif @@seg_name_html[tracking-1] =~/idx/ + Seg_output.new(@output_seg_file,@@seg,@minitoc,'idx').output + else p 'check' end Seg.new.reinitialise header_art(para) head(para) if @@seg_name_html[tracking] =~/metadata/ # this is for metadata segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" - @@filename_seg=File.new(segfilename,'w') - Seg.new.reinitialise + @output_seg_file=File.new(segfilename,'w') + Seg.new.reinitialise #BUG with items following endnote, and occurring before metadata, this becomes a bug ... work area for book index, FIX flagend="x" - @@filename_seg.close #%(((( EOF )))) --> + @output_seg_file.close #%(((( EOF )))) --> end end if tracking == 0 @@ -391,26 +431,6 @@ module SiSU_HTML_seg ads=SiSU_HTML_promo::Ad.new(@md) @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close end - def output(type='') - if @@seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... - filename_seg=[] - filename_seg << @@seg[:title] << @@seg[:tocband_banner] - if type !~/endnote/ - filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main] << "\n\n" - else - filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n
    \n} << @@seg[:endnote_all] << '
    ' - end - filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits] - filename_seg.flatten!.compact! - filename_seg.each do |para| - unless para =~/\A\s*\Z/ - para.strip! - @@filename_seg << para - end - end - @@filename_seg.close - end - end def reinitialise @@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]} @@segtocband=nil @@ -433,11 +453,9 @@ module SiSU_HTML_seg @@seg_endnotes_array=[] if para=~/^#{Mx[:lv_o]}4:/ @@fns_previous=@md.fns if para=~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}/ end - if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs + if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs @@seg_subtoc[@@fn]=@@seg_subtoc_array @@seg_subtoc_array=[] - end - if para =~/^#{Mx[:lv_o]}4:/ #% SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs if para !~/^#{Mx[:lv_o]}4:metadata#{Mx[:lv_c]}/ m=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?#{Mx[:id_o]}~(\d+);(?:[oh]|4:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] end diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index d6558634..05a6272c 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -439,6 +439,7 @@ module SiSU_ODF bullet=image_src('bullet_09.png') cp("#{bullet}/bullet_09.png","#{@env.path.odf}/Pictures/.") #if image_src('bullet_09.png') data.each do |para| + para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove #p para if para =~safe_characters and @md.cmd =~/V/ #KEEP #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ diff --git a/lib/sisu/v0/particulars.rb b/lib/sisu/v0/particulars.rb index 8ae4f66e..59b8956b 100644 --- a/lib/sisu/v0/particulars.rb +++ b/lib/sisu/v0/particulars.rb @@ -92,7 +92,11 @@ module SiSU_Particulars set_env set_md end - attr_accessor :opt,:md + def get_html_idx(opt) + @opt=opt + set_html_idx + end + attr_accessor :opt,:md,:html_idx def set_md begin @md=SiSU_Param::Parameters.new(@opt).get @@ -116,6 +120,13 @@ module SiSU_Particulars rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error end end + def set_html_idx + begin + @html_idx=SiSU_DAL::Source.new(@md).get_idx_html + self + rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + end + end end end __END__ diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index fb4b1115..754e366d 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -275,6 +275,7 @@ WOK table_message='[table omitted, see other document formats]' fix=[] data.each do |para| + para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}") para.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ') # bullet markup, marked down diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index bf59830f..41e8c393 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -423,13 +423,11 @@ module SiSU_XML_munge %{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, '\1\2') #escaped urls not linked, deal with later - para.gsub!(/ |#{Mx[:nbsp]}/,' ') - #para.gsub!(/ /,' ') #clean else para.gsub!(/(^|[^}])_/m,'\1>') #code-block: angle brackets special characters para.gsub!(/(^|[^}])_/m,'\1>') - para.gsub!(/ |#{Mx[:nbsp]}/,' ') end + para.gsub!(/ |#{Mx[:nbsp]}/m,' ') para end def markup_light(para='') diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 93e6ea8e..25cf90ec 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -3033,12 +3033,18 @@ WOK def file_meta File.new("#{@env.path.dal}/#@fns.meta",'w+') end + def file_meta_idx_html + File.new("#{@env.path.dal}/#@fns.idx.html",'w+') + end def file_note File.new("#{Dir.pwd}/#@fns.fn",'w+') end def marshal_meta "#{@env.path.dal}/#@fns.meta.rbm" end + def marshal_meta_idx_html + "#{@env.path.dal}/#@fns.idx_html.rbm" + end def meta "#{@env.path.dal}/#@fns.meta" end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 3cf560c4..885643cf 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -693,6 +693,7 @@ WOK paranum=if ocn; para[m,2] else '' end + paranum = '' if paranum.to_i == 0 txt_obj={:txt =>parablock,:ocn =>paranum} do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj) para=do_duo.para_num if parablock -- cgit v1.2.3 From bb1e2142668528a5e584b6b493c00f23aa59c637 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 12 Sep 2008 01:46:25 -0400 Subject: dal_idx: strip before sort; fix bug where first lev is range --- lib/sisu/v0/dal_idx.rb | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index 74ec0d15..f8eb5e45 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -104,17 +104,6 @@ module SiSU_book_index end [tuned_file,sisu_markup_idx,html_idx] end - def output_html_idx(html_idx) - if @md.book_index - path="#{@env.path.output}/#{@md.fnb}" - Dir.mkdir(path) unless FileTest.directory?(path) - html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') - puts "#{path}/#{@md.fn[:book_index]}" - #html_file(the_idx) - html_idx.each {|x| html_index_file << x } - html_index_file.close - end - end def construct_idx_array(idx_array) idx_lst=[] idx_array.each do |idx| @@ -123,6 +112,7 @@ module SiSU_book_index g=idx_list.scan(/[^;]+/) idxl=[] g.each do |i| + i.strip! idxl << { :rough_idx => i, :ocn => ocn, :seg => seg } end idxl @@ -136,6 +126,7 @@ module SiSU_book_index @the_idx={} idx_array.each do |idx| idx_lst=idx[:rough_idx].scan(/[^|:]+/) + idx_lst[0].strip! if idx_lst[0] =~/.+?\+\d+/ use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] else use=idx_lst[0] @@ -144,7 +135,7 @@ module SiSU_book_index idx_lst.each do |i| i.strip! i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ - x=if idx_lst.length == 1 or idx_lst[0] == i + x=if idx_lst.length == 1 or idx_lst[0].gsub(/\+\d+/,'') == i @the_idx[use]['a1']=[] unless @the_idx[use]['a1'] and defined? @the_idx[use]['a1'] x=if r @the_idx[use]['a1'] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", :seg => idx[:seg] } @@ -278,6 +269,17 @@ module SiSU_book_index end end end + def output_html_idx(html_idx) + if @md.book_index + path="#{@env.path.output}/#{@md.fnb}" + Dir.mkdir(path) unless FileTest.directory?(path) + html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') + puts "#{path}/#{@md.fn[:book_index]}" + #html_file(the_idx) + html_idx.each {|x| html_index_file << x } + html_index_file.close + end + end def clean_and_insert_index(data,sisu_markup_idx) tuned_file=[] data.each do |para| -- cgit v1.2.3 From b3f2c67fd2d5b6c396eada917e2ef6dc069e5ea3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 13 Sep 2008 00:53:58 -0400 Subject: dal_idx: capitalize first letter of index lev1 for sort; provide letter a-z navigation --- lib/sisu/v0/dal_idx.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index f8eb5e45..9691a997 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -131,6 +131,7 @@ module SiSU_book_index use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] else use=idx_lst[0] end + use=use[0].chr.capitalize + use[1,use.length] @the_idx[use]={} unless @the_idx[use] and defined? @the_idx[use] idx_lst.each do |i| i.strip! @@ -168,12 +169,25 @@ module SiSU_book_index @idx[:sst] << "\n\n#{Mx[:br_page_new]}" @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" + @alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] + @idx[:html] << '

    ' + @alph.each {|x| @idx[:html] << %{#{x}, }} + @idx[:html] << '

    ' + @letter=@alph.shift + @idx[:html] << %{\n
    \n

    A

    } the_idx.each do |i| i.each do |x| if x.class == String + f=/^(\S)/.match(x)[1] + if @letter < f + while @letter < f + @letter=@alph.shift + @idx[:html] << %{\n
    \n

    #{@letter}

    } + end + end @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } aname=x.gsub(/\s+/,'_') - @idx[:html] << %{\n

    #{x}, } + @idx[:html] << %{\n

    #{x}, } @o=@idx[:sst].index(@idx[:sst].last) #@o=@idx[:sst].length - 1 @q=@idx[:html].index(@idx[:html].last) #@o=@idx[:html].length - 1 print "\n" + x + ', ' if @md.cmd =~/V/ -- cgit v1.2.3 From dbde53fbcfb79fd01762d97fac929af2a4cfc26a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 13 Sep 2008 23:27:28 -0400 Subject: dal_idx, and concordance, letter list for navigation --- lib/sisu/v0/concordance.rb | 25 +++++++++++++++++++------ lib/sisu/v0/dal_idx.rb | 14 +++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index fad91d14..dd4411ac 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -207,11 +207,11 @@ WOK def songsheet begin mkdir_p(@path) unless FileTest.directory?(@path) - @file_index_all=File.open("#@path/#{@md.fn[:concordance]}",'w') + @file_concordance=File.open("#@path/#{@md.fn[:concordance]}",'w') map_para rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error ensure - @file_index_all.close + @file_concordance.close end end protected @@ -315,20 +315,33 @@ WOK end scr='Full Text scroll: doc#  ' seg='' - @file_index_all << SiSU_Concordance::Source::Doc_title.new(@particulars).create + @file_concordance << SiSU_Concordance::Source::Doc_title.new(@particulars).create + alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] + @file_concordance << '

    ' + alph.each {|x| @file_concordance << %{#{x}, }} + @file_concordance << '

    ' + letter=alph.shift + @file_concordance << %{\n
    \n

    A

    } for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} + f=/^(\S)/.match(word)[1] + if letter < f.upcase + while letter < f.upcase + letter=alph.shift + @file_concordance << %{\n
    \n

    #{letter}

    } + end + end keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html if keyword !~ @rxp_excluded0 if @word_map[word][0] =~ /\d+/ wm=[] - @file_index_all << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} + @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} end - @file_index_all << '

    ' + @file_concordance << '

    ' end # special cases endnotes and header levels 1 - 3 end credits=@vz.credits_sisu - @file_index_all << %{
    #{credits}
    \n} # footer + @file_concordance << %{
    #{credits}
    \n} # footer tell=SiSU_Screen::Ansi.new(@md.cmd,@md.fns,"#{@env.path.output_tell}/#{@md.fn[:concordance]}") tell.flow if @md.cmd =~/[MV]/ end diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index 9691a997..a5806d06 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -169,20 +169,20 @@ module SiSU_book_index @idx[:sst] << "\n\n#{Mx[:br_page_new]}" @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" - @alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] + alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @idx[:html] << '

    ' - @alph.each {|x| @idx[:html] << %{#{x}, }} + alph.each {|x| @idx[:html] << %{#{x}, }} @idx[:html] << '

    ' - @letter=@alph.shift + letter=alph.shift @idx[:html] << %{\n
    \n

    A

    } the_idx.each do |i| i.each do |x| if x.class == String f=/^(\S)/.match(x)[1] - if @letter < f - while @letter < f - @letter=@alph.shift - @idx[:html] << %{\n
    \n

    #{@letter}

    } + if letter < f + while letter < f + letter=alph.shift + @idx[:html] << %{\n
    \n

    #{letter}

    } end end @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } -- cgit v1.2.3 From 87a7cfcd56eed6746b1500c88df3fc3e76a81668 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 15 Sep 2008 21:52:19 -0400 Subject: various small fixes * html segments, name more accurately * rough description of how book index markup works * clean out book index from these outputs * book markup sample, free as in freedom, start doing book index, only letter "A" done so far * texpdf, url matching, special characters * # Please enter the commit message for your changes. --- lib/sisu/v0/dal_idx.rb | 3 +-- lib/sisu/v0/html_segments.rb | 26 ++++++++++++++++++-------- lib/sisu/v0/manpage.rb | 1 + lib/sisu/v0/texinfo.rb | 1 + lib/sisu/v0/texpdf_format.rb | 19 ++++++++++++++++--- 5 files changed, 37 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index a5806d06..c2bba846 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -288,8 +288,7 @@ module SiSU_book_index path="#{@env.path.output}/#{@md.fnb}" Dir.mkdir(path) unless FileTest.directory?(path) html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') - puts "#{path}/#{@md.fn[:book_index]}" - #html_file(the_idx) + #puts "#{path}/#{@md.fn[:book_index]}" html_idx.each {|x| html_index_file << x } html_index_file.close end diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 796c3939..a280a8c8 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -63,18 +63,28 @@ module SiSU_HTML_seg require "#{SiSU_lib}/html" require "#{SiSU_lib}/html_promo" class Seg_output - def initialize(outputfile,seg,minitoc,type='') - @output_seg_file,@seg,@minitoc,@type=outputfile,seg,minitoc,type + def initialize(md,outputfile,seg,minitoc,type='') + @md,@output_seg_file,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type end def output #CONSIDER - if @seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... + if @seg[:title] =~/\S/ filename_seg=[] filename_seg << @seg[:title] << @seg[:tocband_banner] if @type =~/endnote/ -#p @seg[:headers] #FIX endnote header + @seg[:headers]=[] + format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + @seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator) + txt_obj={:txt =>'Endnotes',:ocn_display =>''} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + @seg[:headers] << format_seg.title_header1 filename_seg << @seg[:header_endnotes] << @minitoc << @seg[:headers] << %{\n
    \n} << @seg[:endnote_all] << '
    ' # << '
    ' elsif @type =~/idx/ -#p @seg[:headers] #FIX inserted index header + @seg[:headers]=[] + format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) + @seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator) + txt_obj={:txt =>'Index',:ocn_display =>''} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) + @seg[:headers] << format_seg.title_header1 filename_seg << @seg[:header_idx] << @minitoc << @seg[:headers] << %{\n
    \n} << @seg[:idx] << '
    ' # << '
    ' else filename_seg << @minitoc << @seg[:headers] << @seg[:main] << "\n
    \n" @@ -191,11 +201,11 @@ module SiSU_HTML_seg segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" @output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] if @@seg_name_html[tracking-1] !~/endnotes|idx/ - Seg_output.new(@output_seg_file,@@seg,@minitoc).output + Seg_output.new(@md,@output_seg_file,@@seg,@minitoc).output elsif @@seg_name_html[tracking-1] =~/endnotes/ - Seg_output.new(@output_seg_file,@@seg,@minitoc,'endnotes').output + Seg_output.new(@md,@output_seg_file,@@seg,@minitoc,'endnotes').output elsif @@seg_name_html[tracking-1] =~/idx/ - Seg_output.new(@output_seg_file,@@seg,@minitoc,'idx').output + Seg_output.new(@md,@output_seg_file,@@seg,@minitoc,'idx').output else p 'check' end Seg.new.reinitialise diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index 597099ed..ef9f6bab 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -266,6 +266,7 @@ WOK table_message='[table omitted, see other document formats]' fix=[] data.each do |para| + para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}") para.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ') # bullet markup, marked down diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index 3edf67e4..3ff5652c 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -267,6 +267,7 @@ module SiSU_TexInfo @submenu,@subsubmenu={},{} data.each do |para| para.gsub!(/\s*<:name#example>\s*/,' ') + para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove if para =~ /^#{Mx[:lv_o]}[1-3]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ txt_obj={:txt =>$1} toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 58a057d8..5c2b7ec5 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -1100,16 +1100,22 @@ WOK #string.gsub!(/<=lt>/,'\<') #string.gsub!(/<=gt>/,'\>') string.gsub!(/<=underscore>/,'\_') - string.gsub!(/((?:\\href|\\url)\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text + while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text + string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') + end string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') #string.gsub!(/<=caret>/,'\^{}') string.gsub!(/<=exclaim>/,'\Verbatim{!}') + string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text string.gsub!(/<=hash>/,'{\#}') #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}') #string.gsub!(/<=slash>/,'{\slash}') string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 + while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text + string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') + end string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}') string.gsub!(/<=slash>/,'{/}') @@ -1202,7 +1208,8 @@ WOK elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false end if @@flag_code; string.gsub!(/&/,'{\\\&}') - else string.gsub!(/(\s+&\s+)/,' and ') + else string.gsub!(/&/,'<=amp>') + #else string.gsub!(/(\s+&\s+)/,' and ') end string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ') string.gsub!(/£/u,'\pounds') @@ -1271,16 +1278,22 @@ WOK #string.gsub!(/<=lt>/,'\<') #string.gsub!(/<=gt>/,'\>') string.gsub!(/<=underscore>/,'\_') - string.gsub!(/((?:\\href|\\url)?\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text + while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text + string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') + end string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') #string.gsub!(/<=caret>/,'\^{}') string.gsub!(/<=exclaim>/,'\Verbatim{!}') + string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text string.gsub!(/<=hash>/,'{\#}') #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}') #string.gsub!(/<=slash>/,'{\slash}') string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 + while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text + string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') + end string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}') string.gsub!(/<=slash>/,'{/}') -- cgit v1.2.3 From f555e0777bb4408e2e380150f28f3d433cb66d66 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 16 Sep 2008 00:35:57 -0400 Subject: fixes: alphabet list (concordance, dal_idx), and file types (dal_expand_insertions) --- lib/sisu/v0/concordance.rb | 7 ++++-- lib/sisu/v0/dal.rb | 45 ------------------------------------ lib/sisu/v0/dal_expand_insertions.rb | 45 ++++++++++++++++++++++++++++++++++++ lib/sisu/v0/dal_idx.rb | 7 ++++-- 4 files changed, 55 insertions(+), 49 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index dd4411ac..babc6655 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -326,8 +326,11 @@ WOK f=/^(\S)/.match(word)[1] if letter < f.upcase while letter < f.upcase - letter=alph.shift - @file_concordance << %{\n
    \n

    #{letter}

    } + if alph.length > 0 + letter=alph.shift + @file_concordance << %{\n
    \n

    #{letter}

    } + else break + end end end keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index c01c2d0a..18e2f8dd 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -265,51 +265,6 @@ module SiSU_DAL outputdata end protected - def output_filetypes_in_cmd(cmd_shortcut,source=nil) - #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used - cf_defaults=SiSU_Env::Info_processing_flag.new - cmd_list=case cmd_shortcut.inspect - when /0/; cf_defaults.cf_0 - when /1/; cf_defaults.cf_1 - when /2/; cf_defaults.cf_2 - when /3/; cf_defaults.cf_3 - when /4/; cf_defaults.cf_4 - when /5/; cf_defaults.cf_5 - end - file_type_names={} - file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /y/; 'sisu_manifest.html' - end - file_type_names[:gen] <<= if cmd_list =~ /h/; ['toc.html', 'doc.html'] - end - file_type_names[:gen] <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] - end - #file_type_names[:gen] <<= if cmd_list =~ /i/; 'manpage.1' - #end - file_type_names[:gen] <<= if cmd_list =~ /o/; 'opendocument.odt' - end - file_type_names[:gen] <<= if cmd_list =~ /b/; 'scroll.xhtml' - end - file_type_names[:gen] <<= if cmd_list =~ /x/; 'sax.xml' - end - file_type_names[:gen] <<= if cmd_list =~ /X/; 'dom.xml' - end - file_type_names[:gen] <<= if cmd_list =~ /a/; 'plain.txt' - end - file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt' - end - file_type_names[:gen] <<= if cmd_list =~ /w/; 'concordance.html' - end - file_type_names[:gen] <<= if cmd_list =~ /N/; 'digest.txt' - end - file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; source - end - file_type_names[:src] <<= if cmd_shortcut =~ /S/; "#{source}.zip" - end - file_type_names[:gen]=file_type_names[:gen].flatten - file_type_names[:src]=file_type_names[:src].flatten - file_type_names - end end end __END__ diff --git a/lib/sisu/v0/dal_expand_insertions.rb b/lib/sisu/v0/dal_expand_insertions.rb index 1ab0c03b..17362092 100644 --- a/lib/sisu/v0/dal_expand_insertions.rb +++ b/lib/sisu/v0/dal_expand_insertions.rb @@ -64,6 +64,51 @@ module SiSU_insertions def initialize(data) @data=data end + def output_filetypes_in_cmd(cmd_shortcut,source=nil) + #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used + cf_defaults=SiSU_Env::Info_processing_flag.new + cmd_list=case cmd_shortcut.inspect + when /0/; cf_defaults.cf_0 + when /1/; cf_defaults.cf_1 + when /2/; cf_defaults.cf_2 + when /3/; cf_defaults.cf_3 + when /4/; cf_defaults.cf_4 + when /5/; cf_defaults.cf_5 + end + file_type_names={} + file_type_names[:gen],file_type_names[:src]=[],[] + file_type_names[:gen] <<= if cmd_list =~ /y/; 'sisu_manifest.html' + end + file_type_names[:gen] <<= if cmd_list =~ /h/; ['toc.html', 'doc.html'] + end + file_type_names[:gen] <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] + end + #file_type_names[:gen] <<= if cmd_list =~ /i/; 'manpage.1' + #end + file_type_names[:gen] <<= if cmd_list =~ /o/; 'opendocument.odt' + end + file_type_names[:gen] <<= if cmd_list =~ /b/; 'scroll.xhtml' + end + file_type_names[:gen] <<= if cmd_list =~ /x/; 'sax.xml' + end + file_type_names[:gen] <<= if cmd_list =~ /X/; 'dom.xml' + end + file_type_names[:gen] <<= if cmd_list =~ /a/; 'plain.txt' + end + file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt' + end + file_type_names[:gen] <<= if cmd_list =~ /w/; 'concordance.html' + end + file_type_names[:gen] <<= if cmd_list =~ /N/; 'digest.txt' + end + file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; source + end + file_type_names[:src] <<= if cmd_shortcut =~ /S/; "#{source}.zip" + end + file_type_names[:gen]=file_type_names[:gen].flatten + file_type_names[:src]=file_type_names[:src].flatten + file_type_names + end def expand_insertions? data=@data tuned_file,tuned_file_tmp=[],[] diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index c2bba846..d7d5223e 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -181,8 +181,11 @@ module SiSU_book_index f=/^(\S)/.match(x)[1] if letter < f while letter < f - letter=alph.shift - @idx[:html] << %{\n
    \n

    #{letter}

    } + if alph.length > 0 + letter=alph.shift + @idx[:html] << %{\n
    \n

    #{letter}

    } + else break + end end end @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } -- cgit v1.2.3

    #{@translate.filename}

    #{@translate.description}