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/sisu/v0/dal_doc_str_code.rb | |
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/sisu/v0/dal_doc_str_code.rb')
-rw-r--r-- | lib/sisu/v0/dal_doc_str_code.rb | 37 |
1 files changed, 22 insertions, 15 deletions
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 |