From 459119df8d101ca0cf21c9cfede5ce502ff402ba Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 5 Sep 2007 20:57:59 +0100 Subject: code-block exceptions for composite documents sisu-0.58.2 --- CHANGELOG | 8 ++++++++ lib/sisu/v0/composite.rb | 17 ++++++++++++----- lib/sisu/v0/texinfo.rb | 25 +++++++++++++++---------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1ec36c32..06edce7d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,14 @@ Reverse Chronological: %% STABLE MANIFEST +%% sisu_0.58.2.orig.tar.gz (2007-09-05:36/3) +http://www.jus.uio.no/sisu/pkg/src/sisu_0.58.2.orig.tar.gz + sisu_0.58.2.orig.tar.gz + sisu_0.58.2-1.dsc + sisu_0.58.2-1.diff.gz + + * code-block exceptions for composite documents + %% sisu_0.58.1.orig.tar.gz (2007-09-04:36/2) http://www.jus.uio.no/sisu/pkg/src/sisu_0.58.1.orig.tar.gz 2b46ddfcfd9985c13535733eb822cdbd 1277392 sisu_0.58.1.orig.tar.gz diff --git a/lib/sisu/v0/composite.rb b/lib/sisu/v0/composite.rb index 2569474b..6223743c 100644 --- a/lib/sisu/v0/composite.rb +++ b/lib/sisu/v0/composite.rb @@ -151,12 +151,19 @@ module SiSU_Assemble rgx_image=/([a-zA-Z0-9._-]+?\.(?:png|jpg|gif))/ #file[:prepared] << "#% Date " << "\n" file[:prepared] << "\n% |#{fni}|@|^|>>ok\n" + @code_flag=false insert_array.each do |i| - i.gsub!(/^([12]|:?[AB])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) - if i =~/^0~|^@\S+?:/ - i.gsub!(/\n/m,"\n% ") - i.gsub!(/\n%\s+$/m,'') - i.gsub!(/^0~|^@\S+?:/m,"\n% [imported header:] ") #off imported headers + @code_flag=if i =~/^code\{/; true + elsif i =~/^\}code/; false + else @code_flag + end + unless @code_flag + i.gsub!(/^([12]|:?[AB])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + if i =~/^0~|^@\S+?:/ + i.gsub!(/\n/m,"\n% ") + i.gsub!(/\n%\s+$/m,'') + i.gsub!(/^0~|^@\S+?:/m,"\n% [imported header:] ") #off imported headers + end end file[:prepared] << i file[:images] << i.scan(rgx_image).uniq if i =~rgx_image #flag diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index c46f81ba..6c47ae4c 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -191,17 +191,17 @@ module SiSU_TexInfo @@counting=0 data.each do |para| if para =~ /<:code>/ - @@flag['code']=1 + @@flag['code']=true @@counting=1 end if para =~ /<:verse>/ @@flag['poem']=1 end - if @@flag['code']==1 - if @@flag['code']==1 and para =~ /<:code[-_](?:end|close)>/ #watch change not tested 200501 - @@flag['code']=0 + if @@flag['code'] + if @@flag['code'] and para =~ /<:code[-_](?:end|close)>/ #watch change not tested 200501 + @@flag['code']=false end - if @@flag['code']==1 and para =~ /\S/ + if @@flag['code'] and para =~ /\S/ sub_array=para.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -225,9 +225,9 @@ module SiSU_TexInfo data=@data data.each do |line| if line =~ /\S/ and line !~ /<:(code|verse).+/ - if @@flag['code']==1 + if @@flag['code'] line.gsub!(/^\s*(.+)/m, "\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") - @@counting+=1 if @@flag['code']==1 + @@counting+=1 if @@flag['code'] else line.gsub!(/(.+)/m,'\noindent\1') end end @@ -248,6 +248,8 @@ module SiSU_TexInfo def markup data=@data @tex_file=[] + @row_break='\\\\\\' + @break_page="#@row_break\n#@row_break \n" md={} @tex_file << TexInfoFormat::Texinfo.new('',@md).head mono=TexInfoFormat::Texinfo.new(@md.title,@md) @@ -256,11 +258,11 @@ module SiSU_TexInfo n_menu,n_submenu=0,0 @submenu,@subsubmenu={},{} data.each do |para| + para.gsub!(/\s*<:name#example>\s*/,' ') if para =~ /^[1-3]\\+~\S*(.+?)\s*$/ toc=TexInfoFormat::Texinfo.new($1,@md) texinfo_menu << toc.menu - end - if para =~ /^[4-6]\\+~(?:\S+)?\s+(.+?)\s*$/ + elsif para =~ /^[4-6]\\+~(?:\S+)?\s+(.+?)\s*$/ toc=TexInfoFormat::Texinfo.new($1,@md) texinfo_menu << toc.menu case para @@ -276,6 +278,9 @@ module SiSU_TexInfo @subsubmenu[n_submenu]=[] @subsubmenu[n_submenu] << toc.menu end + else + #para.gsub!(/\s*(?:<:?br>|
)\s*/,"\n#@row_break ") + para.gsub!(/\s*(?:<:?br>|
)\s*/,"\n\n") end end texinfo_menu.compact! @@ -332,7 +337,7 @@ module SiSU_TexInfo para.gsub!(/<\\~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'<\1>') #para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/,'<\1>') #para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/,'<\1>') - para=para + para end end #%case with endnotes -- cgit v1.2.3