diff options
author | Ralph Amissah <ralph@amissah.com> | 2007-09-03 21:47:05 +0100 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2007-09-03 21:47:05 +0100 |
commit | 97d41053a2ef2c2402524e1e73edfa2784efff1f (patch) | |
tree | 013697d5746f437df3387ef19d765961d3b30fed /lib | |
parent | Updated sisu-0.57.0 (diff) | |
parent | sisu-0.58 work towards making it possible to describe sisu and sisu markup wi... (diff) |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v0/css.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v0/dal.rb | 105 | ||||
-rw-r--r-- | lib/sisu/v0/dal_doc_str_code.rb | 37 | ||||
-rw-r--r-- | lib/sisu/v0/dal_doc_str_tables.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v0/dal_syntax.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v0/html.rb | 30 | ||||
-rw-r--r-- | lib/sisu/v0/html_scroll.rb | 3 | ||||
-rw-r--r-- | lib/sisu/v0/html_segments.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v0/html_tune.rb | 104 | ||||
-rw-r--r-- | lib/sisu/v0/odf.rb | 14 | ||||
-rw-r--r-- | lib/sisu/v0/param.rb | 9 | ||||
-rw-r--r-- | lib/sisu/v0/shared_html_lite.rb | 18 | ||||
-rw-r--r-- | lib/sisu/v0/shared_xml.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v0/texpdf.rb | 10 |
14 files changed, 194 insertions, 154 deletions
diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index d1e6832a..f5aabf7f 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -433,7 +433,7 @@ WOK list-style: none; } li { - background: url(../image/bullet_red.png) no-repeat 0px 6px; + background: url(../image/bullet_09.png) no-repeat 0px 6px; /* list-style-type: disc; */ padding-left: 20px; display: block; diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 2e5075d4..c2c92485 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -241,13 +241,15 @@ module SiSU_DAL para.gsub!(/\\trademark\b|\\tm\b/,'®') #non_utf8(para) para=para + "\n" - 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*/, %{~\{#{endnote_no} \\1 \}~}).strip - endnote_no+=1 - para=nil if para =~/\^~ .+/ #removes 'binary' endnote now in endnote array for later insertion + unless para =~/^<:code>/ + 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*/, %{~\{#{endnote_no} \\1 \}~}).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 @@ -770,20 +772,22 @@ module SiSU_DAL if @md.mod.inspect =~/--no-dagger|--no-annotate/ para.gsub!(/~\[[+]\s.+?\]~/,'') end - case para - # auto-numbered endnotes <!e!> <!e_!> --> - when /~\{\s+.+?\}~|~\[[*+]\s+.+?\]~/ - para.gsub!(/\s*(\}~|\]~)/,' \1') # required 2003w31 - word_mode=para.scan(/\S+/) - word_mode=endnote_call_number(word_mode) - para=word_mode.join(' ') - endnote_ref+=1 - when /~\^(?:\s|$)|<:e>/ - #%Note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop) - word_mode=para.scan(/\S+/) - word_mode=endnote_call_number(word_mode) - para=word_mode.join(' ') - endnote_ref+=1 + unless para =~/^<:code>/ + case para + # auto-numbered endnotes <!e!> <!e_!> --> + when /~\{\s+.+?\}~|~\[[*+]\s+.+?\]~/ + para.gsub!(/\s*(\}~|\]~)/,' \1') # required 2003w31 + word_mode=para.scan(/\S+/) + word_mode=endnote_call_number(word_mode) + para=word_mode.join(' ') + endnote_ref+=1 + when /~\^(?:\s|$)|<:e>/ + #%Note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop) + word_mode=para.scan(/\S+/) + word_mode=endnote_call_number(word_mode) + para=word_mode.join(' ') + endnote_ref+=1 + end end @tuned_file << para end @@ -791,23 +795,25 @@ module SiSU_DAL end def endnote_call_number(data) data.each do |word| - case word - when /~\{/ - unless word =~/~\{[*+]+/ - word.gsub!(/~\{/,"~\{#{@@endnote_counter} ") + unless data =~/^<:code>/ + case word + when /~\{/ + unless word =~/~\{[*+]+/ + word.gsub!(/~\{/,"~\{#{@@endnote_counter} ") + @@endnote_counter+=1 + end + when /~\[/ + if word =~/~\[[+]/ + word.gsub!(/~\[[+]/,"~\[\+#{@@endnote_counter_dag} ") + @@endnote_counter_dag+=1 + else + word.gsub!(/~\[[*]?/,"~\[\*#{@@endnote_counter_asterisk} ") + @@endnote_counter_asterisk+=1 + end + when /~\^|<:e>/ + word.gsub!(/~\^|<:e>/,"#{@@endnote_array[@@endnote_counter-1]}") @@endnote_counter+=1 end - when /~\[/ - if word =~/~\[[+]/ - word.gsub!(/~\[[+]/,"~\[\+#{@@endnote_counter_dag} ") - @@endnote_counter_dag+=1 - else - word.gsub!(/~\[[*]?/,"~\[\*#{@@endnote_counter_asterisk} ") - @@endnote_counter_asterisk+=1 - end - when /~\^|<:e>/ - word.gsub!(/~\^|<:e>/,"#{@@endnote_array[@@endnote_counter-1]}") - @@endnote_counter+=1 end end end @@ -973,19 +979,22 @@ module SiSU_DAL 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) - case para - when /~\{[\d*+]+\s+.+?\}~|~\[[*+]\d+\s+.+?\]~/ - en_and_para,en_and_para_digest=[],[] - para.gsub!(/\s*(\}~|\]~)/,' \1') #watch - para_plus_en=para.scan(/.*?~\{.+?\}~|.*?~\[.+?\]~/) - para_tail=if para =~/(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+([\s\S]+)/ - /(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+(.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+>)/.match(para)[1] - else '' + unless para =~/<:code>/ + case para + when /~\{[\d*+]+\s+.+?\}~|~\[[*+]\d+\s+.+?\]~/ + en_and_para,en_and_para_digest=[],[] + para.gsub!(/\s*(\}~|\]~)/,' \1') #watch + para_plus_en=para.scan(/.*?~\{.+?\}~|.*?~\[.+?\]~/) + para_tail=if para =~/(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+([\s\S]+)/ + /(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+(.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+>)/.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 + '<' + digest_strip + ':' + digest_all + '>' unless para.nil? + else @tuned << para + '<' + digest_strip + ':' + digest_all + '>' unless para.nil? 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 + '<' + digest_strip + ':' + digest_all + '>' unless para.nil? else @tuned << para + '<' + digest_strip + ':' + digest_all + '>' unless para.nil? end @tuned.join diff --git a/lib/sisu/v0/dal_doc_str_code.rb b/lib/sisu/v0/dal_doc_str_code.rb index 18ac03d8..52aa4a40 100644 --- a/lib/sisu/v0/dal_doc_str_code.rb +++ b/lib/sisu/v0/dal_doc_str_code.rb @@ -77,15 +77,15 @@ module SiSU_document_structure_code @verse_count=0 data.each do |para| para.gsub!(/(<:(?:code|verse|alt|group)>)\s/,'\1') #double check - para.gsub!(/(?:\n\s*\n)+/m,"\n") + para.gsub!(/(?:\n\s*\n)+/m,"\n") unless @@flag['code'] if para =~/^code\{/ @@flag['code']=true @@counter=1 para.gsub!(/^code\{.*/,'<:code>') - elsif para =~/^(?:poem)\{/ + elsif para =~/^(?:poem)\{/ and not @@flag['code'] @@flag['poem']=true para.gsub!(/^(poem)\{.*/,'<:verse>') - elsif para =~/^(?:alt|group)\{/ #group not tested, stub 2005 + elsif para =~/^(?:alt|group)\{/ and not @@flag['code'] #group not tested, stub 2005 @@flag['group']=true para.gsub!(/^(alt|group)\{.*/,'<:\1>') end @@ -94,22 +94,27 @@ module SiSU_document_structure_code para.gsub!(/^\}code.*/,'<:code-end>') @@flag['code']=false end - if @@flag['code'] #or para =~/<:code-end>/ #and para =~/\S/ - sub_array=para.dup + if @@flag['code'] or para =~/<:code-end>/ #and para =~/\S/ + sub_array=if para !~/<:code(?:-end)?>/; para.dup + '<:br>' + else para.dup + end @line_mode=sub_array.scan(/.+/) + #@line_mode=[] + #sub_array.scan(/.+/) {|w| @line_mode << w + '<:br>' if w =~/[\Ss]+/} SiSU_document_structure_code::Code.new(@md,@line_mode).code_lines('code') para=@line_mode.join end - elsif @@flag['poem'] or @@flag['group'] + elsif ( @@flag['poem'] or @@flag['group'] ) and not @@flag['code'] if @@flag['poem'] and para =~/^\}(?:poem)/ para.gsub!(/^\}(poem).*/,"\n<:verse-end>") @@flag['poem']=false - elsif @@flag['group'] and para =~/^\}(?:alt|group)/ + elsif ( @@flag['group'] and para =~/^\}(?:alt|group)/ ) and not @@flag['code'] para.gsub!(/^\}(alt|group).*/,'<:\1-end>') @@flag['group']=false end if @@flag['poem'] or @@flag['group'] and para =~/\S/ \ - and para !~/<:(verse|code|alt|group)(-end)?>/ + and para !~/<:(verse|code|alt|group)(-end)?>/ \ + and not @@flag['code'] sub_array=para.dup @line_mode=sub_array.scan(/.+/) type=if @@flag['poem']; 'poem' @@ -130,10 +135,11 @@ module SiSU_document_structure_code elsif para =~/<:(?:code|alt|group|verse)-end>/ @verse_count=0 @tuned_group << para - if para =~/<:group-end>/ - tuned_file << @tuned_group.join("\n") - else - tuned_file << @tuned_group.join + tuned_file <<= if para =~/<:group-end>/ + @tuned_group.join("\n") + else @tuned_group=@tuned_group.join + @tuned_group.gsub!(/<:br><:br>(<:code-end>)/,'\1') + @tuned_group end @tuned_group=[] else tuned_file << para @@ -144,17 +150,18 @@ module SiSU_document_structure_code def code_lines(type='') data=@data data.each do |line| - if line =~/\S/ and line !~/^(?:alt|code|group|poem)\{|^\}(?:alt|code|group|poem)|<:(?:code|verse|alt|group).+/ + if line =~/\S/ and line !~/^code\{|^\}code|<:code.+/ line.gsub!(/\s\s/,' ') line.gsub!(/^/,'<:codeline>') if type=='code' # try sort for texpdf special case if line =~/https?:\/\/\S+$/ line.gsub!(/$/,' <:br>') - else - line.gsub!(/$/,'<:br>') #unless type=='code' + else line.gsub!(/$/,'<:br>') #unless type=='code' end if @@flag['code']; @@counter+=1 else end + elsif line =~/^\s*$/ + line.gsub!(/$/,' <:br>') end end end diff --git a/lib/sisu/v0/dal_doc_str_tables.rb b/lib/sisu/v0/dal_doc_str_tables.rb index 2c128570..e0d019bb 100644 --- a/lib/sisu/v0/dal_doc_str_tables.rb +++ b/lib/sisu/v0/dal_doc_str_tables.rb @@ -131,13 +131,13 @@ module SiSU_document_structure_tables if para =~/^\{(?:t|table)(?:~h)?(?:\sc\d+;)?[\d; ]*\}/ @tuned_file << table_visual(para) @tuned_file=@tuned_file.flatten - elsif @@flag['table_to'] or para[/table\{(?:~h)?/] + elsif @@flag['table_to'] or para[/^table\{(?:~h)?/] if para[/table\{(?:~h)?\s+c(\d+;.+)/] instructions=$1 @@column=instructions.split(/;\s*/) @@columns=@@column[0] - para.gsub!(/table\{~h\s+(c\d+?;.+?)$/,'<!Th¡ \1!>') - para.gsub!(/table\{\s+(c\d+?;.+?)$/,'<!T¡ \1!>') + para.gsub!(/^table\{~h\s+(c\d+?;.+?)$/,'<!Th¡ \1!>') + para.gsub!(/^table\{\s+(c\d+?;.+?)$/,'<!T¡ \1!>') @@flag['table_to']=true end if @@flag['table_to'] and para =~/\}table/ diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 703d9f1b..292f7343 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -191,7 +191,7 @@ module Syntax # # #numbered (list) level 1 # _# #numbered (list) level 2 line=line.dup - if line !~/^0~|<:codeline>|<:code-end>/ + unless line =~/^0~|<:codeline>|<:code-end>/ #special characters: ~ { } < > - _ / also used : ^ ! # line_array=[] line.gsub!(/^%{1,4} .+/mi,'') #remove comments @@ -288,7 +288,7 @@ module Syntax else #code blocks line.gsub!(/(^|\s)(https?:\/\/\S+)/,'\1_\2') #line.gsub!(/(^|\s)(http:\/\/\S+)/,"\\1\\\\\\2") #escape urls line.gsub!(/(^|\s)<(https?:\/\/\S+)>([\s,.]|$)/,'\1\2\3') #clean/unescape urls with decoration, re-apply decoration later - line.gsub!(/<:codeline>/,"\n") + line.gsub!(/<:codeline>/,"\n ") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") end line end diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 0798e604..2894fa27 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -271,20 +271,22 @@ module SiSU_HTML @scr_endnotes << format_head_scroll.title_endnote @data.each do |para| pg=para.dup - if pg =~/~[{\[][\d*+]+ <a name="_[\d*+]+"/ - endnote_array=[] - if pg=~/~\{[\d*+].+?\}\~/m - endnote_array << pg.scan(/~\{[\d*+]+(.+?)\}\~/m) - end - if pg=~/~\[[\d*]+\s.+?\]\~/m - endnote_array << pg.scan(/~\[[\d*]+(.+?)\]\~/m) - end - if pg=~/~\[[\d+]+\s.+?\]\~/m - endnote_array << pg.scan(/~\[[\d+]+(.+?)\]\~/m) - end - endnote_array.flatten.each do |note| - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,note) - @scr_endnotes << format_scroll.endnote_body + unless pg =~/^<:code>/ + if pg =~/~[{\[][\d*+]+ <a name="_[\d*+]+"/ and not pg =~/^<:code>/ + endnote_array=[] + if pg=~/~\{[\d*+].+?\}\~/m + endnote_array << pg.scan(/~\{[\d*+]+(.+?)\}\~/m) + end + if pg=~/~\[[\d*]+\s.+?\]\~/m + endnote_array << pg.scan(/~\[[\d*]+(.+?)\]\~/m) + end + if pg=~/~\[[\d+]+\s.+?\]\~/m + endnote_array << pg.scan(/~\[[\d+]+(.+?)\]\~/m) + end + endnote_array.flatten.each do |note| + format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,note) + @scr_endnotes << format_scroll.endnote_body + end end end end diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index b2cfb497..629cfc0c 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -88,7 +88,8 @@ module SiSU_HTML_scroll end @rcdc=true if @rcdc==false and (para =~/^\d~metadata/ or para =~/^1~\s+Document Information/) if para !~/(^0~|<ENDNOTES>|<EOF>)/ - para.gsub!(/~[{\[].+?[}\]]~\s+/m,' ') + unless para =~/^<:code>/; para.gsub!(/~[{\[].+?[}\]]~\s+/m,' ') + end if para =~/.+?<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ paranum=para[/.+?<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,1] @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 44ab9033..a7e81624 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -425,7 +425,7 @@ module SiSU_HTML_seg @@seg_subtoc_array << para end if @md.flag_auto_endnotes - if para =~/~[{\[][\d*+]+ <a name="_[\d*+]+"/ # endnote- + if para =~/~[{\[][\d*+]+ <a name="_[\d*+]+"/ and not para =~/^<:code>/ # endnote- endnote_array=[] if para=~/~\{.+?\}\~/m endnote_array << para.scan(/~\{.+?\}\~/m) diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 7f91641e..7c829831 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -289,49 +289,51 @@ module SiSU_Tune para.gsub!(/<:p[bn]>/,'') para.gsub!(/<(p|br)>/,'<\1 />') para.gsub!(/<:br>/,'<br />') - if para =~/<::\s+/ #watch - para.gsub!(/<::\s+(\S+?)\s+!>/, - %{<img src="#{@env.url.images}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0">}) - end - if para =~/<:image\s+/ - para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0"></a>}) - para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/, - %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" naturalsizeflag="0" align="bottom" border="0"></a>}) - para.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{<img src="#{@env.url.images_local}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0">}) - para.gsub!(/<:image\s+(\S+)\s+>/, - %{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">}) - end - if para =~/\{.+?\}((?:http|ftp)\S+|image)/ - @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) - word_mode=urls(@word_mode) - words=word_mode.join(' ') - para.gsub!(/.+/,words) - end - if (para !~/^0~/) - para.gsub!(/\\copyright/i,%{<sup>©</sup>}) - if (para !~/\<:ad\s+\.\.\//) - para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, - %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n}) - else - para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, - %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n}) + unless para =~/^<:code>/ + if para =~/<::\s+/ #watch + para.gsub!(/<::\s+(\S+?)\s+!>/, + %{<img src="#{@env.url.images}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0">}) + end + if para =~/<:image\s+/ + para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0"></a>}) + para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/, + %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" naturalsizeflag="0" align="bottom" border="0"></a>}) + para.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{<img src="#{@env.url.images_local}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0">}) + para.gsub!(/<:image\s+(\S+)\s+>/, + %{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">}) end - para.gsub!(/!pick/, %{<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_choice}" alt="stellar">}) - para.gsub!(/!new/, %{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}) - para.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') - para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) - para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<<a href="mailto:\1">\1</a>>\2') + if para =~/\{.+?\}((?:http|ftp)\S+|image)/ + @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) + word_mode=urls(@word_mode) + words=word_mode.join(' ') + para.gsub!(/.+/,words) end - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration - if (para =~/..\/\S+/ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/) - para.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>') + if (para !~/^0~|^<:code>/) + para.gsub!(/\\copyright/i,%{<sup>©</sup>}) + if (para !~/\<:ad\s+\.\.\//) + para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n}) + else + para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n}) + end + para.gsub!(/!pick/, %{<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_choice}" alt="stellar">}) + para.gsub!(/!new/, %{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}) + para.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') + para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') + if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) + para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<<a href="mailto:\1">\1</a>>\2') + end + para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration + para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url + para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration + if (para =~/..\/\S+/ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/) + para.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>') + end + para.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}) end - para.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}) end @tuned_file << para end @@ -340,17 +342,19 @@ module SiSU_Tune data=@data @tuned_file=[] data.each do |para| - para.gsub!(/(~[{])(\d+) (.+?) <#@dp>([}]~)/, - ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- - '\1\2 <a name="_\2" href="#-\2"> <sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched) - para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/, - ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- - '\1\2 <a name="_\2" href="#-\2"> <sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched) - para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/, - ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- - '\1\2 <a name="_\2" href="#-\2"> <sup>\2</sup></a> \3 \4') #endnote- note- (careful may have switched) - @tuned_file << para + unless para =~/^<:code>/ + para.gsub!(/(~[{])(\d+) (.+?) <#@dp>([}]~)/, + ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- + '\1\2 <a name="_\2" href="#-\2"> <sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched) + para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/, + ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- + '\1\2 <a name="_\2" href="#-\2"> <sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched) + para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/, + ' <a name="-\2" href="#_\2"> <sup>\2</sup> </a> ' + #note- endnote- + '\1\2 <a name="_\2" href="#-\2"> <sup>\2</sup></a> \3 \4') #endnote- note- (careful may have switched) end + @tuned_file << para + end end def output data=@data diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 11d14bf2..16cea2f4 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -378,6 +378,7 @@ module SiSU_ODF parray=[] para.split(/<:?br(?: \/)?>/).each do |parablock| parablock=group_clean(parablock) + parablock.gsub!(/^\s*$/,'<br />') parablock.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, %{<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>\\2}) #http ftp matches escaped, no decoration parray << %{<text:p text:style-name="P5">#{parablock}</text:p>} if parablock =~/\S+/ @@ -398,8 +399,11 @@ module SiSU_ODF lv=nil if lv == 0 #extract_endnotes(para) #para=fontface(para) - para=if para =~/\{\s*\S+?\.(?:png|jpg|gif)\s.+?\}(?:(?:https?|ftp):\S+|image)/; image(para) - elsif para =~/\{.+?\}(?:(?:https?|ftp):\S+|image)/; text_link(para) + para=unless para=~/^<:code>/ + para=if para =~/\{\s*\S+?\.(?:png|jpg|gif)\s.+?\}(?:(?:https?|ftp):\S+|image)/; image(para) + elsif para =~/\{.+?\}(?:(?:https?|ftp):\S+|image)/; text_link(para) + else para + end else para end para=footnote(para) @@ -446,8 +450,8 @@ module SiSU_ODF (4..6).each { |x| @odf_contents_close[x]='' } odf_tail #($1,$2) fix=[] - bullet=image_src('bullet_red.png') - cp("#{bullet}/bullet_red.png","#{@env.path.odf}/Pictures/.") #if image_src('bullet_red.png') + 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| #p para if para =~safe_characters and @md.cmd =~/V/ #KEEP #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') @@ -465,7 +469,7 @@ module SiSU_ODF para=para_array.join(' ') para=para.strip end - para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.22cm" svg:height="0.22cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_red.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ') # bullet_red.png + para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.22cm" svg:height="0.22cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_09.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ') # bullet_09.png #para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1<text:span text:style-name="T6">●</text:span> ') #bullet #para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1● ') # bullet utf8, make smaller if used #para.gsub!(/^_\*\s+/,'<text:span text:style-name="T6">●</text:span> ') #bullet diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 9462d8d2..690163d4 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -178,7 +178,6 @@ module SiSU_Param @sfx=nil @flag_pdf=true #watch @flag_auto_heading_num=false -#watch if @fns =~ /[_-]?sst$/ #watch @env_out_root=@env.path.output @dir_out="#{@env.path.output}/#@fnb" @@ -235,13 +234,19 @@ module SiSU_Param tell=SiSU_Screen::Ansi.new(@cmd,'SiSU filetype indicator not provided') tell.warn unless @cmd =~/q/ end + @code_flag=false fns_array.each do |par| #% Scan document para=par.gsub(/\n/,' ') if para !~/^\%+\s/ and para =~/<![abcdeghijklmnopqrstuvwxyz]/i # <!f not included raise "Old markup style in file #@fns, current version #{@sisu_version[:project]} #{@sisu_version[:version]} #{@sisu_version[:date_stamp]} #{@sisu_version[:date]}:\n\t\t#{para}\n\n" end + @code_flag=case par + when /^code\{\s*$/; true + when /^\}code\s*$/; false + else @code_flag + end regx_header=/^(?:0~|@\S+?:[+-]?\s)/ - if para =~regx_header #or para=~/^(?:1|:?A)~/ + if para =~regx_header and not @code_flag #or para=~/^(?:1|:?A)~/ case para when /^(?:0~ocn|@ocn:)\s+(.+?)$/m; @ocn=$1 #% processing when /^(?:0~title|@title:)\s+(.+?)$/m #% metainfo DC diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 1218aa79..1046b6c4 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -125,15 +125,17 @@ module SiSU_Format_Shared @words end def markup(para) - if para =~/\{.+?\}((?:http|ftp)\S+|image)/ - wm=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) - word_mode=urls(wm) - words=word_mode.join(' ') - para.gsub!(/.+/,words) + unless para =~/^<:code>/ + if para =~/\{.+?\}((?:http|ftp)\S+|image)/ + wm=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) + word_mode=urls(wm) + words=word_mode.join(' ') + para.gsub!(/.+/,words) + end + para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration + para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url + para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration end - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration para end def paragraph diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index c54ab42d..4e77e995 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -352,8 +352,8 @@ module SiSU_XML_munge para.gsub!(/<+[-~]#>+/,'') para.gsub!(/<0;\w\d+;[um]\d+><#@dp:#@dp>/,'') #embeds a red-bullet image --> - #para.gsub!(/^(<:i[1-9]>\s*_\*)\s+/,'\1 <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_red.png" width="12" height="12" alt="*" /> ') - #para.gsub!(/^_\*\s+/,'<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_red.png" width="12" height="12" alt="*" /> ') + #para.gsub!(/^(<:i[1-9]>\s*_\*)\s+/,'\1 <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_09.png" width="12" height="12" alt="*" /> ') + #para.gsub!(/^_\*\s+/,'<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_09.png" width="12" height="12" alt="*" /> ') para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\2" width="\\3" height="\\4" />[\\2] \\5}) para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\2"/>\\2}) para.gsub!(/(^|\s)\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/, diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 22c2681d..8bd5b6f2 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -432,7 +432,10 @@ WOK if para =~/<:(code|alt|verse|group)>/ @lineone=case para when /<:(alt|verse|group)>/; para - when /<:code>/; "#{@tex.paraskip_small} \\begin{footnotesize} \\begin{ttfamily} " + para + when /<:code>/; "#{@tex.paraskip_small} \\begin{tiny} " + para + #when /<:code>/; "#{@tex.paraskip_small} \\begin{footnotesize} " + para + ##when /<:code>/; "#{@tex.paraskip_small} \\begin{texttt} " + para + #when /<:code>/; "#{@tex.paraskip_small} \\begin{small} \\begin{ttfamily} " + para else 'error' #should never occur end end @@ -462,7 +465,10 @@ WOK #@lineone.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') insert=[] if para =~/<:code-end>/ - insert << y + @lineone << @group_collect << ' \end{ttfamily} \end{footnotesize}' << " #{@tex.paraskip_normal}" + insert << y + @lineone << @group_collect << ' \end{tiny}' << " #{@tex.paraskip_normal}" + #insert << y + @lineone << @group_collect << ' \end{footnotesize}' << " #{@tex.paraskip_normal}" + #insert << y + @lineone << @group_collect << ' \end{texttt}' << " #{@tex.paraskip_normal}" + #insert << y + @lineone << @group_collect << ' \end{ttfamily} \end{small}' << " #{@tex.paraskip_normal}" else insert << y + @lineone << @group_collect end @@flag_group,@@flag_code=false,false |