From 2cd558f67f44cca787013c02b665533b97c90f0e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 3 Sep 2007 21:46:47 +0100 Subject: sisu-0.58 work towards making it possible to describe sisu and sisu markup within sisu --- lib/sisu/v0/css.rb | 2 +- lib/sisu/v0/dal.rb | 105 +++++++++++++++++++++----------------- lib/sisu/v0/dal_doc_str_code.rb | 37 ++++++++------ lib/sisu/v0/dal_doc_str_tables.rb | 6 +-- lib/sisu/v0/dal_syntax.rb | 4 +- lib/sisu/v0/html.rb | 30 ++++++----- lib/sisu/v0/html_scroll.rb | 3 +- lib/sisu/v0/html_segments.rb | 2 +- lib/sisu/v0/html_tune.rb | 104 +++++++++++++++++++------------------ lib/sisu/v0/odf.rb | 14 +++-- lib/sisu/v0/param.rb | 9 +++- lib/sisu/v0/shared_html_lite.rb | 18 ++++--- lib/sisu/v0/shared_xml.rb | 4 +- lib/sisu/v0/texpdf.rb | 10 +++- 14 files changed, 194 insertions(+), 154 deletions(-) (limited to 'lib') 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 --> - 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 /^(|[-~]\{{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 --> + 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 /^(|[-~]\{{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+?;.+?)$/,'') - para.gsub!(/table\{\s+(c\d+?;.+?)$/,'') + para.gsub!(/^table\{~h\s+(c\d+?;.+?)$/,'') + para.gsub!(/^table\{\s+(c\d+?;.+?)$/,'') @@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*+]+ / + if pg =~/~[{\[][\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 + 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~||)/ - 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*+]+ / # 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>/,'
') - if para =~/<::\s+/ #watch - para.gsub!(/<::\s+(\S+?)\s+!>/, - %{\\1}) - end - if para =~/<:image\s+/ - para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{
}) - para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/, - %{}) - para.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{}) - para.gsub!(/<:image\s+(\S+)\s+>/, - %{}) - 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,%{©}) - if (para !~/\<:ad\s+\.\.\//) - para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, - %{\n
\\3
\n}) - else - para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, - %{\n
\\3
\n}) + unless para =~/^<:code>/ + if para =~/<::\s+/ #watch + para.gsub!(/<::\s+(\S+?)\s+!>/, + %{\\1}) + end + if para =~/<:image\s+/ + para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{}) + para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/, + %{}) + para.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{}) + para.gsub!(/<:image\s+(\S+)\s+>/, + %{}) end - para.gsub!(/!pick/, %{stellar}) - para.gsub!(/!new/, %{ new}) - para.gsub!(/<:h(.{1,7}?)>/,'\1') - para.gsub!(/<:to(\d{1,7}?)>/,'to { \1 } ') - if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) - para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<\1>\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|$))/,'\1\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|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+<)/) - para.gsub!(/(\.\.\/\S+)/,'\1') + if (para !~/^0~|^<:code>/) + para.gsub!(/\\copyright/i,%{©}) + if (para !~/\<:ad\s+\.\.\//) + para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + %{\n
\\3
\n}) + else + para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + %{\n
\\3
\n}) + end + para.gsub!(/!pick/, %{stellar}) + para.gsub!(/!new/, %{ new}) + para.gsub!(/<:h(.{1,7}?)>/,'\1') + para.gsub!(/<:to(\d{1,7}?)>/,'to { \1 } ') + if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) + para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<\1>\2') + end + para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration + para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url + para.gsub!(/(^|\s)((?:https?|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+<)/) + para.gsub!(/(\.\.\/\S+)/,'\1') + end + para.gsub!(/([}]~)/, - '  \2  ' + #note- endnote- - '\1\2  \2. \3 \4') #endnote- note- (careful may have switched) - para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/, - '  \2  ' + #note- endnote- - '\1\2  \2. \3 \4') #endnote- note- (careful may have switched) - para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/, - '  \2  ' + #note- endnote- - '\1\2  \2 \3 \4') #endnote- note- (careful may have switched) - @tuned_file << para + unless para =~/^<:code>/ + para.gsub!(/(~[{])(\d+) (.+?) <#@dp>([}]~)/, + '  \2  ' + #note- endnote- + '\1\2  \2. \3 \4') #endnote- note- (careful may have switched) + para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/, + '  \2  ' + #note- endnote- + '\1\2  \2. \3 \4') #endnote- note- (careful may have switched) + para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/, + '  \2  ' + #note- endnote- + '\1\2  \2 \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*$/,'
') parablock.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, %{\\1\\2}) #http ftp matches escaped, no decoration parray << %{#{parablock}} 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 ') # bullet_red.png + para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1 ') # bullet_09.png #para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1 ') #bullet #para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\1● ') # bullet utf8, make smaller if used #para.gsub!(/^_\*\s+/,' ') #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 =~// + 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|$))/,'\1\2') #http ftp matches escaped, no decoration + para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url + para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration end - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@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 * ') - #para.gsub!(/^_\*\s+/,'* ') + #para.gsub!(/^(<:i[1-9]>\s*_\*)\s+/,'\1 * ') + #para.gsub!(/^_\*\s+/,'* ') para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1[\\2] \\5}) para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1\\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 -- cgit v1.2.3