From e1ec4bd2dad2bd22ad97cea398ae1cfcfae183a2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 15 Oct 2007 19:27:16 +0100 Subject: mostly the arrangement of conditionals --- lib/sisu/v0/dal_doc_str_code.rb | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'lib/sisu/v0/dal_doc_str_code.rb') diff --git a/lib/sisu/v0/dal_doc_str_code.rb b/lib/sisu/v0/dal_doc_str_code.rb index c45d95f1..9032d54e 100644 --- a/lib/sisu/v0/dal_doc_str_code.rb +++ b/lib/sisu/v0/dal_doc_str_code.rb @@ -82,19 +82,23 @@ module SiSU_document_structure_code @@flag['code']=true @@counter=1 para.gsub!(/^code\{.*/,'<:code>') - elsif para =~/^(?:poem)\{/ and not @@flag['code'] + elsif para =~/^(?:poem)\{/ \ + and not @@flag['code'] @@flag['poem']=true para.gsub!(/^(poem)\{.*/,'<:verse>') - elsif para =~/^(?:alt|group)\{/ and not @@flag['code'] #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 if @@flag['code'] - if @@flag['code'] and para =~/^\}code/ + if @@flag['code'] \ + and para =~/^\}code/ para.gsub!(/^\}code.*/,'<:code-end>') @@flag['code']=false end - if @@flag['code'] or para =~/<:code-end>/ #and para =~/\S/ + if @@flag['code'] \ + or para =~/<:code-end>/ #and para =~/\S/ sub_array=if para !~/<:code(?:-end)?>/; para.dup + '<:br>' else para.dup end @@ -104,15 +108,22 @@ module SiSU_document_structure_code SiSU_document_structure_code::Code.new(@md,@line_mode).code_lines('code') para=@line_mode.join end - elsif ( @@flag['poem'] or @@flag['group'] ) and not @@flag['code'] - if @@flag['poem'] and para =~/^\}(?:poem)/ + 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)/ ) and not @@flag['code'] + 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/ \ + if @@flag['poem'] \ + or @@flag['group'] \ + and para =~/\S/ \ and para !~/<:(verse|code|alt|group)(-end)?>/ \ and not @@flag['code'] sub_array=para.dup @@ -121,7 +132,8 @@ module SiSU_document_structure_code else 'group' end SiSU_document_structure_code::Code.new(@md,@line_mode).code_lines(type) - div=if @@flag['poem'] and @verse_count > 0 + div=if @@flag['poem'] \ + and @verse_count > 0 "\n" + '<:verse-end>' + "\n\n" + '<:verse>' else '' end @@ -130,7 +142,9 @@ module SiSU_document_structure_code else para end end - if @@flag['code'] or @@flag['poem'] or @@flag['group'] + if @@flag['code'] \ + or @@flag['poem'] \ + or @@flag['group'] @tuned_group << para if para =~/\S+/ elsif para =~/<:(?:code|alt|group|verse)-end>/ @verse_count=0 @@ -150,7 +164,8 @@ module SiSU_document_structure_code def code_lines(type='') data=@data data.each do |line| - if line =~/\S/ and line !~/^code\{|^\}code|<:code.+/ + 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?|file|ftp):\/\/\S+$/ -- cgit v1.2.3