diff options
author | Ralph Amissah <ralph@amissah.com> | 2007-09-03 21:46:47 +0100 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2007-09-03 21:46:47 +0100 |
commit | 2cd558f67f44cca787013c02b665533b97c90f0e (patch) | |
tree | b3b596e2d094014b897dabd1c93e91623b1663d0 /lib/sisu/v0/dal.rb | |
parent | sisu-0.57.0 md5s (diff) |
sisu-0.58 work towards making it possible to describe sisu and sisu markup within sisu
Diffstat (limited to 'lib/sisu/v0/dal.rb')
-rw-r--r-- | lib/sisu/v0/dal.rb | 105 |
1 files changed, 57 insertions, 48 deletions
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 |