diff options
-rw-r--r-- | CHANGELOG | 29 | ||||
-rw-r--r-- | Rantfile | 34 | ||||
-rw-r--r-- | data/sisu/conf/convert/sisu_convert | 395 | ||||
-rw-r--r-- | data/sisu/conf/vim/addons/syntax/sisu.vim | 8 | ||||
-rw-r--r-- | lib/sisu/v0/css.rb | 141 | ||||
-rw-r--r-- | lib/sisu/v0/dal_syntax.rb | 37 | ||||
-rw-r--r-- | lib/sisu/v0/db_import.rb | 3 | ||||
-rw-r--r-- | lib/sisu/v0/defaults.rb | 21 | ||||
-rw-r--r-- | lib/sisu/v0/html.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v0/html_format.rb | 38 | ||||
-rw-r--r-- | lib/sisu/v0/html_scroll.rb | 172 | ||||
-rw-r--r-- | lib/sisu/v0/html_segments.rb | 15 | ||||
-rw-r--r-- | lib/sisu/v0/html_tune.rb | 98 | ||||
-rw-r--r-- | lib/sisu/v0/odf.rb | 81 | ||||
-rw-r--r-- | lib/sisu/v0/plaintext.rb | 44 | ||||
-rw-r--r-- | lib/sisu/v0/shared_html_lite.rb | 68 | ||||
-rw-r--r-- | lib/sisu/v0/shared_xml.rb | 20 | ||||
-rw-r--r-- | lib/sisu/v0/texpdf.rb | 3 | ||||
-rw-r--r-- | lib/sisu/v0/texpdf_format.rb | 22 | ||||
-rw-r--r-- | lib/sisu/v0/xhtml.rb | 26 | ||||
-rw-r--r-- | lib/sisu/v0/xml.rb | 22 | ||||
-rw-r--r-- | lib/sisu/v0/xml_dom.rb | 26 |
22 files changed, 804 insertions, 505 deletions
@@ -6,6 +6,33 @@ Reverse Chronological: %% STABLE MANIFEST +%% sisu_0.54.0.orig.tar.gz (2007-06-14::24/4) +http://www.jus.uio.no/sisu/pkg/src/sisu_0.54.0.orig.tar.gz + sisu_0.54.0.orig.tar.gz + sisu_0.54.0-1.dsc + sisu_0.54.0-1.diff.gz + + * indent levels (1-9) added [previously two levels] done for plaintext, html, + xml, odf, latex/pdf [minor syntax addition (_3 - _9), version number + change] + + * bullet indent levels (1-9) added [previously two levels] done for + plaintext, html, odf, latex/pdf [minor syntax addition (_3* - _9*), version + number change] + + * url decoration, open close, default angle brackets <http://url> + + * fixes, some line-breaking for plaintext (and text groups for) odf and xml + + * css, modifications for extended indents in html and xml [sisu -CC (for + update)] + + * vim syntax highlighter updated to take account of extended indent range + + * rant installer minor changes for future ruby + + * conversion script in data/sisu/conf/convert/sisu_convert + %% sisu_0.53.0.orig.tar.gz (2007-06-02::22/6) http://www.jus.uio.no/sisu/pkg/src/sisu_0.53.0.orig.tar.gz b8f28c2cade1f95956f5cdaef7af7fbd 1254059 sisu_0.53.0.orig.tar.gz @@ -23,7 +50,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_0.53.0.orig.tar.gz * Note: dcc, several hash values change. - * moved to git for scm including git-buildpackage + * moved to git for scm including git-buildpackage (from a combination of mercurial and dars + darcs-buildpackage, [don't ask, it served me quite well though]) @@ -11,8 +11,8 @@ raise 'Please, use ruby1.8.4 or later.' if RUBY_VERSION < '1.8.4' Rant is a Ruby 'ant' by Stefan Lang For Setup/Installation SiSU uses either: - * Minero Aoki's setup.rb, provided along with SiSU, or - * Rant which may be downloaded and installed from: + * Minero Aoki's setup.rb, provided along with SiSU, or + * Rant which may be downloaded and installed from: http://make.rubyforge.org/ * Name: Rant install/setup file for SiSU - Simple information Structuring Universe, Serialised information Structured Units @@ -110,10 +110,10 @@ def answer?(ask) print ask + " ['yes', 'no' or 'quit']: " resp=File.new('/dev/tty').gets.strip #resp=gets.strip - ans=if resp == 'yes': true - elsif resp == 'no': false - elsif resp =~/^quit|exit$/: exit - else puts "[please type: 'yes', 'no' or 'quit']" + ans=if resp == 'yes'; true + elsif resp == 'no'; false + elsif resp =~/^quit|exit$/; exit + else puts "[please type: 'yes', 'no' or 'quit']" answer?(ask) end end @@ -129,17 +129,17 @@ def get_username gets.strip end def chmod_file(place) - if place =~/\/bin/: File.chmod(0755,place) + if place =~/\/bin/; File.chmod(0755,place) else File.chmod(0644,place) end end def chmod_util(place) - if place =~/\/bin/: chmod(0755,place) - else chmod(0644,place) + if place =~/\/bin/; chmod(0755,place) + else chmod(0644,place) end end #%% using a directory and its mapping -def setup_find_create(dir_get,dir_put) #primary, +def setup_find_create(dir_get,dir_put) #primary, Find.find("#@pwd/#{dir_get}") do |f| stub=f.scan(/#@pwd\/#{dir_get}\/(\S+)/).join place="#{dir_put}/#{stub}" @@ -223,7 +223,7 @@ def rant_system_info host: #@host arch: #{@dir[:arch]} sitearch: #{@dir[:sitearch]} - + Directories for installation bin: #{@dir[:bin]} lib (site-ruby): #{@dir[:lib]}/#{@dir[:proj]}/#{Version} @@ -252,15 +252,15 @@ Commands quick start list #{@proj[:name]} Rant Help: (This Rantfile uses the same directory structure as setup.rb) rant -T # a task list, (generated by Rant) for more complete and up to date help rant system # system info used - + Quick start install and remove project #{@proj[:name]} as root: rant # install #{@proj[:name]} - + rant setup # install #{@proj[:name]} (without additonal configuration and generating of test file) - + rant reinstall # reinstall #{@proj[:name]} - + rant remove # clobber/remove #{@proj[:name]}, current version: #{Version} rant remove_package # clobber/remove #{@proj[:name]}, all versions @@ -465,7 +465,7 @@ end task :setup_vim do #man setup_find_create('data/vim',@dir[:vim]) if File.directory?('data/vim') #man pages end - #%% post install + #%% post install #%% clobber/remove tasks task :remove_bin do rm_r "#{@dir[:bin]}/#{@dir[:proj]}" if FileTest.file?("#{@dir[:bin]}/#{@dir[:proj]}") @@ -494,7 +494,7 @@ task :remove_package do rm_r "#{@dir[:conf]}/#{@dir[:proj]}" if FileTest.directory?("#{@dir[:conf]}/#{@dir[:proj]}") end task :post_install_note do - puts <<WOK + puts <<WOK sisu markup samples are now packaged separately in sisu-markup-samples visit: diff --git a/data/sisu/conf/convert/sisu_convert b/data/sisu/conf/convert/sisu_convert index d7876083..9a734678 100644 --- a/data/sisu/conf/convert/sisu_convert +++ b/data/sisu/conf/convert/sisu_convert @@ -27,47 +27,47 @@ module CONVERT end def headerBasic <<WOK -0~title +@title: -0~subtitle +@subtitle: -0~creator +@creator: -0~type +@type: -0~subject +@subject: -0~date +@date: -0~date.available +@date.available: -0~publisher SiSU +@publisher: SiSU -0~rights +@rights: -0~level +@level: WOK end def headerDefault <<WOK -0~title +@title: -0~subtitle +@subtitle: -0~creator +@creator: -0~type +@type: -0~subject +@subject: -0~date +@date: -0~date.available +@date.available: -0~publisher SiSU +@publisher: SiSU -0~rights ... +@rights: WOK end @@ -79,7 +79,7 @@ WOK else pre << headerBasic end - @filename_wv=File.new(%{,,#{@filename}.er9}, "w+") + @filename_wv=File.new(%{,,#{@filename}.sst},'w+') @filename_wv << pre @data.each do |x| y = x.split("\n") @@ -98,11 +98,11 @@ WOK end def songsheet data=@data - print "Convert to SiSU file from Word97 << gvim ,,#{@filename}.er9 >\n" #: <<#{@@html_title}>> - data=WareWord97.new(data.collect, @filename, @instruct).strip - data=WareWord97.new(data.collect, @filename, @instruct).strip - data=WareWord97.new(data.collect, @filename, @instruct).markup_rules - data=MyOutput.new(data.collect, @filename, @instruct).hardOutput + print "Convert to SiSU file from Word97 << gvim ,,#{@filename}.sst >\n" #: <<#{@@html_title}>> + data=WareWord97.new(data.collect,@filename,@instruct).strip + data=WareWord97.new(data.collect,@filename,@instruct).strip + data=WareWord97.new(data.collect,@filename,@instruct).markup_rules + data=MyOutput.new(data.collect,@filename,@instruct).hardOutput end def strip data=@data @@ -110,12 +110,12 @@ WOK endnote_no=1 data.each do |para| para.strip! - para.gsub!(/<u>\s*<\/u>/, '') - para.gsub!(/<\/u>\s*<u>/, '') - para.gsub!(/<b>\s*<\/b>/, '') - para.gsub!(/<\/b>\s*<b>/, '') - para.gsub!(/<i>\s*<\/i>/, '') - para.gsub!(/<\/i>\s*<i>/, '') + para.gsub!(/<u>\s*<\/u>/,'') + para.gsub!(/<\/u>\s*<u>/,'') + para.gsub!(/<b>\s*<\/b>/,'') + para.gsub!(/<\/b>\s*<b>/,'') + para.gsub!(/<i>\s*<\/i>/,'') + para.gsub!(/<\/i>\s*<i>/,'') tuned_file << para unless para == nil end tuned_file @@ -126,15 +126,16 @@ WOK endnote_no=1 data.each do |para| para.strip! - para.gsub!(/\s+/, ' ') - para.gsub!(/^<b>(Chapter|Article)(.+?)<\/b>/i, "4{ \\1 \\2") #watch case insensitivity - para.gsub!(/^<b>(Part|Section|Book)(.+?)<\/b>/i, "3{ \\1 \\2") #watch case insensitivity - para.gsub!(/^<b>(\d+\.\d+\.\d+)(.+?)<\/b>/i, "6{ \\1 \\2") #numeric, decide what to do, can be different - para.gsub!(/^<b>(\d+\.\d+)(.+?)<\/b>/i, "5{ \\1 \\2") #numeric, decide what to do, can be different - para.gsub!(/^<b>(\d+)(.+?)<\/b>/i, "4{ \\1 \\2") #numeric, decide what to do, can be different - para.gsub!(/<u>(.+?)<\/u>/, "_{\\1}_") - para.gsub!(/<b>(.+?)<\/b>/, "*{\\1}*") - para.gsub!(/<i>(.+?)<\/i>/, "/{\\1}/") + para.gsub!(/\s+/,' ') + para.gsub!(/^<b>(Chapter|Article)(.+?)<\/b>/i,'4~ \1 \2') #watch case insensitivity + para.gsub!(/^<b>(Part|Section|Book)(.+?)<\/b>/i,'3~ \1 \2') #watch case insensitivity + para.gsub!(/^<b>(\d+\.\d+\.\d+\.?)(.+?)<\/b>/i,'6~ \1 \2') #numeric, decide what to do, can be different + para.gsub!(/^<b>(\d+\.\d+\.?)(.+?)<\/b>/i,'5~ \1 \2') #numeric, decide what to do, can be different + para.gsub!(/^<b>(\d.+?)<\/b>/i,'4~ \1 \2') #numeric, decide what to do, can be different + #para.gsub!(/^<b>([\d.]+?)<\/b>/i,'4~ \1 \2') #numeric, decide what to do, can be different + para.gsub!(/<u>(.+?)<\/u>/,'_{\1}_') + para.gsub!(/<b>(.+?)<\/b>/,'*{\1}*') + para.gsub!(/<i>(.+?)<\/i>/,'/{\1}/') tuned_file << para unless para == nil end tuned_file @@ -148,10 +149,11 @@ WOK end def songsheet data=@data - print "Convert to SiSU file from #{@filename}.html << gvim ,,#{@filename}.er9 >\n" #: <<#{@@html_title}>> + print "Convert to SiSU file from #{@filename}.html << gvim ,,#{@filename}.sst >\n" #: <<#{@@html_title}>> #data=Html.new(data.collect, @filename, @instruct).space_paragraphs #data=Html.new(data.split(''), @filename, @instruct).space_paragraphs - data=Html.new(data.split("\n"), @filename, @instruct).space_paragraphs + data=Html.new(data.join.split(/\n\n+/), @filename, @instruct).space_paragraphs + #data=Html.new(data.split("\n"), @filename, @instruct).space_paragraphs #data=Html.new(data.collect.join.split("\n"), @filename, @instruct).space_paragraphs data=Html.new(data.collect, @filename, @instruct).multiline data=Html.new(data.collect.join.split("\n\n"), @filename, @instruct).markup_rules @@ -164,18 +166,18 @@ WOK tuned_file=Array.new data.each do |para| para.strip! - para.gsub!(/\r/, '') + para.gsub!(/\r/,'') #para.gsub!(/\n/, ' ') #PROBLEM, serious time issues on a few files also for \n (or multiline matches which is less surprising), edit out if necessary - para.gsub!(/<\/?p>/i, 'zZz') - para.gsub!(/<\/?\s*p(?:\s+ALIGN=.+?)?>/i, "zZz") #all manner of <p> para.gsub!(/<\/?p>/i, "\n\n") - para.gsub!(/<p\s+(class|align).+?>/i, "zZz") # - para.gsub!(/<\/p>/i, "zZz") # repeat actually - para.gsub!(/<(?:dir|tr|br)>/i, "zZz") # + para.gsub!(/<\/?p>/i,'zZz') + para.gsub!(/<\/?\s*p(?:\s+ALIGN=.+?)?>/i,'zZz') #all manner of <p> para.gsub!(/<\/?p>/i, "\n\n") + para.gsub!(/<p\s+(class|align).+?>/i,'zZz') # + para.gsub!(/<\/p>/i,'zZz') # repeat actually + para.gsub!(/<(?:dir|tr|br)>/i,'zZz') # #para.gsub!(/<(?:\/\s*)?(?:dir|tr|br)>/i, "zZz") # - para.gsub!(/(<\/center>)/i, "\\1zZz") - para.gsub!(/(<\/h[1-6]>)/i, "\\1zZz") - para.gsub!(/ \s+/i, ' ') - para.gsub!(/(?:\s*zZz\s*)+/i, "zZz") # + para.gsub!(/(<\/center>)/i,'\1zZz') + para.gsub!(/(<\/h[1-6]>)/i,'\1zZz') + para.gsub!(/ \s+/i,' ') + para.gsub!(/(?:\s*zZz\s*)+/i,'zZz') # tuned_file << para unless para == nil end tuned_file @@ -185,10 +187,10 @@ WOK sub.each do |x| if x=~/(<\/blockquote>)/i m = $1 - res << x[/(.+?)#{m}/mi, 1].gsub!(/zZz/,"zZz_1 ") if x =~/.+?#{m}/mi - res << x[/#{m}(.+)/mi, 1] + res << x[/(.+?)#{m}/mi,1].gsub!(/zZz/,'zZz_1 ') if x =~/.+?#{m}/mi + res << x[/#{m}(.+)/mi,1] else - res << x #[/(.+)/mi, 1] + res << x #[/(.+)/mi,1] end end res.join @@ -197,26 +199,27 @@ WOK data=@data tuned_file=Array.new data.each do |para| - para.gsub!(/\n/, ' ') - para.gsub!(/ \s+/mi, ' ') + para.gsub!(/\n/,' ') + para.gsub!(/ \s+/mi,' ') #ALL HERE could be very time EXPENSIVE but tamed? compromise ... /mi - para.gsub!(/<([biu]|h[1-6])>(?:zZz)?([^<]+)?zZz(.+?)<\/\1>/i, "zZz<\\1>\\2 \\3</\\1>") - para.gsub!(/<([biu]|h[1-6])>(?:<center>|zZz)+(.+?)(?:<\/center>)?zZz(.+?)?<\/\1>/i, "zZz<\\1>\\2 \\3</\\1>") - #para.gsub!(/<([biu]|h[1-6])>(?:<center>|zZz)+(.+?)<\/center>zZz(.+?)?<\/\1>/i, "zZz<\\1>\\2 \\3</\\1>") - para.gsub!(/<([biu]|h[1-6])>(?:<center>|zZz)+(.+?)<\/\1>/i, "zZz<\\1>\\2</\\1>") - para.gsub!(/<(h[1-6])>(.+?)(?:<center>|zZz)+<\/\1>/i, "zZz<\\1>\\2</\\1>zZz") #does catch some h1, h2 etc, too expensive to have biu - #para.gsub!(/<([biu]|h[1-6])>(.+?)(?:<center>|zZz)+<\/\1>/i, "zZz<\\1>\\2 \\3</\\1>") #may go too far? useful for h1 h2 etc, remove biu? - #para.gsub!(/<([biu]|h[1-6])>([^<]+)?zZz(.+?)<\/\1>/i, "zZz<\\1>\\2 \\3</\\1>") - #para.gsub!(/<([biu]|h[1-6])>([^<]+)?zZz(.+?)<\/\1>/i, "zZz<\\1>\\2 \\3</\\1>") + para.gsub!(/<([biu]|h[1-6])>(?:zZz)?([^<]+)?zZz(.+?)<\/\1>/i,'zZz<\1>\2 \3</\1>') + para.gsub!(/<([biu]|h[1-6])>(?:<center>|zZz)+(.+?)(?:<\/center>)?zZz(.+?)?<\/\1>/i,'zZz<\1>\2 \3</\1>') + #para.gsub!(/<([biu]|h[1-6])>(?:<center>|zZz)+(.+?)<\/center>zZz(.+?)?<\/\1>/i,'zZz<\1>\2 \3</\1>') + para.gsub!(/<([biu]|h[1-6])>(?:<center>|zZz)+(.+?)<\/\1>/i,'zZz<\1>\2</\1>') + para.gsub!(/<(h[1-6])>(.+?)(?:<center>|zZz)+<\/\1>/i,'zZz<\1>\2</\1>zZz') #does catch some h1, h2 etc, too expensive to have biu + #para.gsub!(/<([biu]|h[1-6])>(.+?)(?:<center>|zZz)+<\/\1>/i,'zZz<\1>\2 \3</\1>') #may go too far? useful for h1 h2 etc, remove biu? + #para.gsub!(/<([biu]|h[1-6])>([^<]+)?zZz(.+?)<\/\1>/i,'zZz<\1>\2 \3</\1>') + #para.gsub!(/<([biu]|h[1-6])>([^<]+)?zZz(.+?)<\/\1>/i,'zZz<\1>\2 \3</\1>') ### SERIOUS PROBLEM INTRODUCED # sub = para.split(/<blockquote>/i) # para = blockquotes(sub) if sub.length > 0 #check was on >1 could have serious repercussions 2004w29 - para.gsub!(/zZz(\s*zZz)*/, "\n\n") + para.gsub!(/zZz(\s*zZz)*/,"\n\n") tuned_file << para << "\n\n" unless para == nil end tuned_file end def markup_rules + @@flag_blockquote=false data=@data tuned_file=Array.new data.each do |para| @@ -224,65 +227,186 @@ WOK #p para.grep(/<a href="(http:\/\/.+?)">/i) #m=$1 #para.gsub!(/(?:<\s*)?<a href="#{m}">#{m}<\/a>(?:\s*>)?\.?/i, "#{m}") - para.gsub!(/(?:<\s*)?<a href="(http:\/\/.+?)">http:\/\/.+?<\/a>(?:\s*>)?\.?/i, "\\1") #risk that url & url are not to match + para.gsub!(/(?:<\s*)?<a href="(http:\/\/.+?)">http:\/\/.+?<\/a>(?:\s*>)?\.?/i,'\1') #risk that url & url are not to match #para.gsub!(/(?:<\s*)?<a href="(\w+\.html)">(http:\/\/.+?\/\1)<\/a>(?:\s*>)?\.?/i, "\\2") #does not match end + if para=~/<BLOCKQUOTE>/i + @@flag_blockquote=true + end + if @@flag_blockquote + para.gsub!(/^/,'_1 ') unless para.empty? or para =~/^\s*<\/?blockquote?>\s*$/i + end + if para=~/<\/BLOCKQUOTE>/i + @@flag_blockquote=false + end + para.gsub!(/<\/?blockquote?>/i,'') ### clean - para.gsub!(/^\s+/i, '') - para.gsub!(/<([bui]|em|su[pb])>\s*<\/\1>/i, '') - para.gsub!(/<\/?center>/i, '') - para.gsub!(/\s*<\/dir>/i, '') - para.gsub!(/<hr>/i, '') - para.gsub!(/\s*<a href=".+?\.html#(?:[a-z_]+)?(?:[a-z0-9_-]|\*)+">\[(\*+)\]<\/a>/i, "^{[\\1]}^ ") #other endnote marker - para.gsub!(/<a href=".+?\.html#(?:[a-z_$]+)?[0-9_-]+"(?:\s+name=".+?")?>\[[a-z]?\d+\](?:<\/[bi]>)?<\/a>/i, '~e ') #endnote marker - para.gsub!(/<a name=".+?"\s+href=".+?\.html#(?:[a-z_$]+)?[0-9_-]+"?>\[[a-z]?\d+\](?:<\/[bi]>)?<\/a>/i, '~e ') #endnote marker - para.gsub!(/<a name="(?:[a-z$]+)?[0-9_-]+">\s*(<\/a>)?\s*\d+\.?\s*(<\/a>)?\s*/i, '~{{ ') #endnote - #para.gsub!(/<h([1-6])>\s*(.+?)\s*<\/h\1>\s*/i, "\\1{ \\2") # - para.gsub!(/<h([1-6])(?: align=.+?)?>\s*(.+?)\s*<\/h\1>\s*/i, "\\1{ \\2") # - para.gsub!(/^<b>(Chapter|Article)(.+?)<\/b>/i, "4{ \\1 \\2") #watch case insensitivity - para.gsub!(/^<b>(Part|Section|Book)(.+?)<\/b>/i, "3{ \\1 \\2") #watch case insensitivity - para.gsub!(/^<b>(\d+\.\d+\.\d+)(.+?)<\/b>/i, "6{ \\1 \\2") #numeric, decide what to do, can be different - para.gsub!(/^<b>(\d+\.\d+)(.+?)<\/b>/i, "5{ \\1 \\2") #numeric, decide what to do, can be different - para.gsub!(/^<b>(\d+)(.+?)<\/b>/i, "4{ \\1 \\2") #numeric, decide what to do, can be different + para.gsub!(/^\s+/i,'') + para.gsub!(/<([bui]|em|su[pb])>\s*<\/\1>/i,'') + para.gsub!(/<\/?center>/i,'') + para.gsub!(/\s*<\/dir>/i,'') + para.gsub!(/<hr>/i,'') + para.gsub!(/\s*<a href=".+?\.html#(?:[a-z_]+)?(?:[a-z0-9_-]|\*)+">\[(\*+)\]<\/a>/i,'^{[\1]}^ ') #other endnote marker + para.gsub!(/<a href=".+?\.html#(?:[a-z_$]+)?[0-9_-]+"(?:\s+name=".+?")?>\[[a-z]?\d+\](?:<\/[bi]>)?<\/a>/i,'~^ ') #endnote marker + para.gsub!(/<a name=".+?"\s+href=".+?\.html#(?:[a-z_$]+)?[0-9_-]+"?>\[[a-z]?\d+\](?:<\/[bi]>)?<\/a>/i,'~^ ') #endnote marker + para.gsub!(/<a name="(?:[a-z$]+)?[0-9_-]+">\s*(<\/a>)?\s*\d+\.?\s*(<\/a>)?\s*/i,'^~ ') #endnote + #para.gsub!(/<h([1-6])>\s*(.+?)\s*<\/h\1>\s*/i,'\1~ \2') # + para.gsub!(/<h([1-6])(?: align=.+?)?>\s*(.+?)\s*<\/h\1>\s*/i,'\1~ \2') # + para.gsub!(/^<b>(Chapter|Article)(.+?)<\/b>/i,'4~ \1 \2') #watch case insensitivity + para.gsub!(/^<b>(Part|Section|Book)(.+?)<\/b>/i,'3~ \1 \2') #watch case insensitivity + para.gsub!(/^<b>(\d+\.\d+\.\d+\.?)(.+?)<\/b>/i,'6~ \1 \2') #numeric, decide what to do, can be different + para.gsub!(/^<b>(\d+\.\d+\.?)(.+?)<\/b>/i,'5~ \1 \2') #numeric, decide what to do, can be different + para.gsub!(/^<b>(\d+\.?)(.+?)<\/b>/i,'4~ \1 \2') #numeric, decide what to do, can be different #<a name="ii"></a><B> - para.gsub!(/^(<a name=".+?">)(?:<small>)?<(?:b|strong)>\s*(.+?)\s*<\/(?:b|strong)>/i, "5{ \\2 \\1") #watch - para.gsub!(/^(<(a name|A NAME)=".+?">)(\s*|<\/[aA]>)?([A-Z][A-Z])+/, "5{ \\2 \\1") #watch - para.gsub!(/^(\s+|<p>)?(<a name=".+?">)(\s*|<\/a>)?<b>/i, "5{ \\2 \\1") #watch - para.gsub!(/<h([1-6])>\s*(.+?)\s*<\/h\1>\s*/i, "\\1{ \\2") # - para.gsub!(/^<b>\s*(.+?)<\/b>\s*(<\/i>\s*)?$/i, "4{ \\1\\2") # wish it all were less messy - para.gsub!(/^<i>\s*([^"(].+?)<\/i>\s*(<\/b>\s*)?$/i, "5{ \\1\\2") # wish it all were less messy - para.gsub!(/<\/?[biu]>/i, '') if para =~/[1-6]\{/ - para.gsub!(/<u>\s*(.+?)\s*<\/u>/i, "_{\\1}_") - para.gsub!(/<(b|strong)>\s*(.+?)\s*<\/\1>/i, "*{\\2}*") - para.gsub!(/<(i|em)>\s*(.+?)\s*<\/\1>/i, "/{\\2}/") - para.gsub!(/<sup>\s*(.+?)\s*<\/sup>/i, "^{\\1}^") - para.gsub!(/(([\/\*!_])\{.+?\}\2)\s\s+/i, "\\1 ") - para.gsub!(/(([\/\*!_])\{.+?\}\2)\s+([.,;?\)])\s+/i, "\\1\\3 ") - para.gsub!(/(([\/\*!_])\{.+?\}\2)(["'])\s+/i, "\\1\\3 ") - para.gsub!(/(([\/\*!_])\{.+?\}\2)\s*([a-z0-9])/i, "\\1 \\3") - para.gsub!(/(([\/\*_])\{.+?\}\2)\s*([a-z0-9])/i, "\\1 \\3") - para.gsub!(/([a-z0-9])(([\/\*_])\{.+?\}\3)/i, " \\1 \\2") #eg this/{problem}/ - para.gsub!(/([\/\*_])\{([,.;; ]+)\}\1/i, "\\2") #eg /{,}/ or *{ }* etc. - para.gsub!(/ \s+/i, ' ') + para.gsub!(/^(<a name=".+?">)(?:<small>)?<(?:b|strong)>\s*(.+?)\s*<\/(?:b|strong)>/i,'5~ \2 \1') #watch + para.gsub!(/^(<(a name|A NAME)=".+?">)(\s*|<\/[aA]>)?([A-Z][A-Z])+/,'5~ \2 \1') #watch + para.gsub!(/^(\s+|<p>)?(<a name=".+?">)(\s*|<\/a>)?<b>/i,'5~ \2 \1') #watch + para.gsub!(/<h([1-6])>\s*(.+?)\s*<\/h\1>\s*/i,'\1~ \2') # + para.gsub!(/^<b>\s*(.+?)<\/b>\s*(<\/i>\s*)?$/i,'4~ \1\2') # wish it all were less messy + para.gsub!(/^<i>\s*([^"(].+?)<\/i>\s*(<\/b>\s*)?$/i,'5~ \1\2') # wish it all were less messy + para.gsub!(/<\/?[biu]>/i,'') if para =~/[1-6]\{/ + para.gsub!(/<u>\s*(.+?)\s*<\/u>/i,'_{\1}_') + para.gsub!(/<(b|strong)>\s*(.+?)\s*<\/\1>/i,'*{\2}*') + para.gsub!(/<(i|em)>\s*(.+?)\s*<\/\1>/i,'/{\2}/') + para.gsub!(/<sup>\s*(.+?)\s*<\/sup>/i,'^{\1}^') + para.gsub!(/(([\/\*!_])\{.+?\}\2)\s\s+/i,'\1 ') + para.gsub!(/(([\/\*!_])\{.+?\}\2)\s+([.,;?\)])\s+/i,'\1\3 ') + para.gsub!(/(([\/\*!_])\{.+?\}\2)(["'])\s+/i,'\1\3 ') + para.gsub!(/(([\/\*!_])\{.+?\}\2)\s*([a-z0-9])/i,'\1 \3') + para.gsub!(/(([\/\*_])\{.+?\}\2)\s*([a-z0-9])/i,'\1 \3') + para.gsub!(/([a-z0-9])(([\/\*_])\{.+?\}\3)/i,' \1 \2') #eg this/{problem}/ + para.gsub!(/([\/\*_])\{([,.;; ]+)\}\1/i,'\2') #eg /{,}/ or *{ }* etc. + para.gsub!(/ \s+/i,' ') #para.gsub!(/\/\{\*\{/i, '*{/{') #para.gsub!(/\}\*\}\//i, '}/}*') - para.gsub!(/"/i, '"') - para.gsub!(/&/i, 'and') - para.gsub!(/<!doctype html public .+/i, '') - para.gsub!(/<\/?(?:html|head|body|font|small)>/i, '') - para.gsub!(/<\/(?:title)>/i, '') - para.gsub!(/<title>/i, '#{~title? ') - para.gsub!(/<blockquote>(.+?)<\/blockquote>/mi, "\n\n_1 \\1\n\n") - para.gsub!(/<div align=.+?>|<\/div>|<font size=.+?>|<\/a><\/em><\/strong>/i, '') - para.gsub!(/~e\s+\.\s*/i, ".~e ") #check vim equiv # %s/\~e\s\+\.\s*/.\~e /c - para.gsub!(/\s+~e\s+/i, "~e ") - para.gsub!(/ \s+/i, ' ') - para.gsub!(/\s+$/i, '') - para.gsub!(/^(?:<\/[bi]>)+$/i, '') - para.gsub!(/^(?:(?:<i>)+<b>|(?:<b>)+<i>)\s*([^"(].+?)/i, "5{ \\1\\2") # wish it all were less messy - para.gsub!(/^(?:<\/?(?:[ib]|em)>\s*)+$/i, '') # cleaning up left over <i> etc. - para.gsub!(/<(?:i|em)>\s*(.+)/i, "/{\\1}/") # using up left over <i> - para.gsub!(/<b>\s*(.+)/i, "*{\\1}*") # using up left over <b> + para.gsub!(/"/i,'"') + para.gsub!(/&/i,'and') + para.gsub!(/<!doctype html public .+/i,'') + para.gsub!(/<\/?(?:html|head|body|font|small)>/i,'') + para.gsub!(/<\/(?:title)>/i,'') + para.gsub!(/<title>/i,'#{~title? ') + para.gsub!(/<blockquote>(.+?)<\/blockquote>/mi,"\n\n_1 \\1\n\n") + para.gsub!(/<div align=.+?>|<\/div>|<font size=.+?>|<\/a><\/em><\/strong>/i,'') + para.gsub!(/~^\s+\.\s*/i,'.~^ ') #check vim equiv # %s/\~e\s\+\.\s*/.\~e /c + para.gsub!(/\s+~^\s+/i,'~^ ') + para.gsub!(/ \s+/i,' ') + para.gsub!(/\s+$/i,'') + para.gsub!(/^(?:<\/[bi]>)+$/i,'') + para.gsub!(/^(?:(?:<i>)+<b>|(?:<b>)+<i>)\s*([^"(].+?)/i,'5~ \1\2') # wish it all were less messy + para.gsub!(/^(?:<\/?(?:[ib]|em)>\s*)+$/i,'') # cleaning up left over <i> etc. + para.gsub!(/<(?:i|em)>\s*(.+)/i,'/{\1}/') # using up left over <i> + para.gsub!(/<b>\s*(.+)/i,'*{\1}*') # using up left over <b> + para.gsub!(/<dd>([\d.]+)/i,'5~ \1') + para.gsub!(/<dd>(?: )+([\d.]+)/i,'6~ \1') + para.gsub!(/<dd>(\([a-z]\))/i,'7~ \1') + para.gsub!(/^([1-9]~)( .+?)<a name="(\S+?)">(.+?)(<\/a>)/i,'\1\3\2\4') + para.gsub!(/^([1-9]~)( .+?)<a name="(\S+?)">/i,'\1\3\2') + para.gsub!(/http\/\/(\S+)/i,'http:\/\/\1') + para.gsub!(/\s*<a href="\S+?">(http:\/\/\S+?)<\/a>\s*/i,' \1 ') + para.gsub!(/([a-zA-Z.,!?;:])([*\/_-]\{)/,'\1 \2') + para.gsub!(/^\s*( ){10,12}/i,'_2 ') + para.gsub!(/^\s*( ){4,5}/i,'_1 ') + para.gsub!(/	/,' ') #check + ## glyphs & tildes + para.gsub!(/¡/, '¡') #'Inverted exclamation + para.gsub!(/¢/, '¢') #'Cent sign ¢ + para.gsub!(/£/, '£') #'Pound sign £ + para.gsub!(/¤/, '¤') #'General currency sign + para.gsub!(/¥/, '¥') #'Yen sign ¥ + para.gsub!(/¦/, '¦') #'Broken vertical bar + para.gsub!(/§/, '§') #'Section sign § + para.gsub!(/¨/, '¨') #'Umlaut + para.gsub!(/©/, '©') #'Copyright © + para.gsub!(/ª/, 'ª') #'Feminine ordinal ª + para.gsub!(/«/, '«') #'Left angle quote « + para.gsub!(/¬/, '¬') #'Not sign + para.gsub!(/­/, '') #'Soft hyphen + para.gsub!(/®/, '®') #'Registered trademark ® + para.gsub!(/¯/, '¯') #'Macron accent + para.gsub!(/°/, '°') #'Degree sign ° + para.gsub!(/&plusmin;/,'±') #'Plus or minus ± + para.gsub!(/²/, '²') #'Superscript 2 ² + para.gsub!(/³/, '³') #'Superscript 3 ³ + para.gsub!(/´/, '') #'Acute accent + para.gsub!(/µ/, 'µ') #'Micro sign (Greek mu) µ + para.gsub!(/¶/, '¶') #'Paragraph sign ¶ + para.gsub!(/·/, '·') #'Middle dot + para.gsub!(/¸/, '¸') #'Cedilla + para.gsub!(/¹/, '¹') #'Superscript 1 ¹ + para.gsub!(/º/, 'º') #'Masculine ordinal º + para.gsub!(/»/, '»') #'Right angle quote + para.gsub!(/¼/, '¼') #'Fraction one quarter ¼ + para.gsub!(/½/, '½') #'Fraction on half ½ + para.gsub!(/¾/, '¾') #'Fraction three quarters ¾ + para.gsub!(/¿/, '¿') #'Inverted question mark ¿ + para.gsub!(/À/, 'À') #'Capital A, grave accent À + para.gsub!(/Á/, 'Á') #'Capital A, acute accent Á + para.gsub!(/Â/, 'Â') #'Capital A, circumflex accent  + para.gsub!(/Ã/, 'Ã') #'Capital A, tilde à + para.gsub!(/Ä/, 'Ä') #'Capital A, umlaut Ä + para.gsub!(/Å/, 'Å') #'Capital A, ring Å + para.gsub!(/Æ/, 'Æ') #'Capital AE ligature Æ + para.gsub!(/Ç/, 'Ç') #'Capital C, cedilla Ç + para.gsub!(/È/, 'È') #'Capital E, grave accent È + para.gsub!(/É/, 'É') #'Capital E, acute accent É + para.gsub!(/Ê/, 'Ê') #'Capital E, circumflex accent Ê + para.gsub!(/Ë/, 'Ë') #'Capital E, umlaut Ë + para.gsub!(/Ì/, 'Ì') #'Capital I, grave accent Ì + para.gsub!(/Í/, 'Í') #'Capital I, acute accent Í + para.gsub!(/Î/, 'Î') #'Capital I, circumflex accent Î + para.gsub!(/Ï/, 'Ï') #'Capital I, umlaut Ï + para.gsub!(/Ð/, 'Ð') #'Capital eth, Icelandic + para.gsub!(/Ñ/, 'Ñ') #'Capital N, tilde Ñ + para.gsub!(/Ò/, 'Ò') #'Capital O, grave accent Ò + para.gsub!(/Ó/, 'Ó') #'Capital O, acute accent Ó + para.gsub!(/Ô/, 'Ô') #'Capital O, circumflex accent Ô + para.gsub!(/Õ/, 'Õ') #'Capital O, tilde Õ + para.gsub!(/Ö/, 'Ö') #'Capital O, umlaut Ö + para.gsub!(/×/, '×') #'Multiply sign × + para.gsub!(/Ø/, 'Ø') #'Capital O, slash Ø + para.gsub!(/Ù/, 'Ù') #'Capital U, grave accent Ù + para.gsub!(/Ú/, 'Ú') #'Capital U, acute accent Ú + para.gsub!(/Û/, 'Û') #'Capital U, circumflex accent Û + para.gsub!(/Ü/, 'Ü') #'Capital U, umlaut Ü + para.gsub!(/Ý/, 'Ý') #'Capital Y, acute accent Ý + para.gsub!(/Þ/, 'Þ') #'Capital thorn, Icelandic Þ + para.gsub!(/ß/, 'ß') #'Small sz ligature, German ß + para.gsub!(/à/, 'à') #'Small a, grave accent à + para.gsub!(/á/, 'á') #'Small a, acute accent á + para.gsub!(/â/, 'â') #'Small a, circumflex accent â + para.gsub!(/ã/, 'ã') #'Small a, tilde ã + para.gsub!(/ä/, 'ä') #'Small a, umlaut ä + para.gsub!(/å/, 'å') #'Small a, ring å + para.gsub!(/æ/, 'æ') #'Small ae ligature æ + para.gsub!(/ç/, 'ç') #'Small c, cedilla ç + para.gsub!(/è/, 'è') #'Small e, grave accent è + para.gsub!(/é/, 'é') #'Small e, acute accent é + para.gsub!(/ê/, 'ê') #'Small e, circumflex accent ê + para.gsub!(/ë/, 'ë') #'Small e, umlaut ë + para.gsub!(/ì/, 'ì') #'Small i, grave accent ì + para.gsub!(/í/, 'í') #'Small i, acute accent í + para.gsub!(/î/, 'î') #'Small i, circumflex accent î + para.gsub!(/ï/, 'ï') #'Small i, umlaut ï + para.gsub!(/ð/, 'ð') #'Small eth, Icelandic ð + para.gsub!(/ñ/, 'ñ') #'Small n, tilde ñ + para.gsub!(/ò/, 'ò') #'Small o, grave accent ò + para.gsub!(/ó/, 'ó') #'Small o, acute accent ó + para.gsub!(/ô/, 'ô') #'Small o, circumflex accent ô + para.gsub!(/õ/, 'õ') #'Small o, tilde õ + para.gsub!(/ö/, 'ö') #'Small o, umlaut ö + para.gsub!(/÷/, '÷') #'Divide sign ÷ + para.gsub!(/ø/, 'ø') #'Small o, slash ø + para.gsub!(/ù/, 'ù') #'Small u, grave accent ù + para.gsub!(/ú/, 'ú') #'Small u, acute accent ú + para.gsub!(/û/, 'û') #'Small u, circumflex accent û + para.gsub!(/ü/, 'ü') #'Small u, umlaut ü + para.gsub!(/ý/, 'ý') #'Small y, acute accent ý + para.gsub!(/þ/, 'þ') #'Small thorn, Icelandic þ + para.gsub!(/ÿ/, 'ÿ') #'Smally y, umlaut ÿ + ## + para.gsub!(/\s\s+/,' ') + para.gsub!(/\t+/,' ') + #para.gsub!(/ +/,' ') #para.gsub!(/^(?:<(?:\/)?[bi]>)+$/i, '') tuned_file << para unless para == nil end @@ -297,7 +421,7 @@ WOK end def songsheet data=@data - print "Convert to SiSU file from #{@filename}.html << gvim ,,#{@filename}.er9 >\n" #: <<#{@@html_title}>> + print "Convert to SiSU file from #{@filename}.html << gvim ,,#{@filename}.sst >\n" #: <<#{@@html_title}>> data=Default.new(data.collect, @filename, @instruct).space_paragraphs data=Default.new(data.collect, @filename, @instruct).multiline data=Default.new(data.collect.join.split("\n\n"), @filename, @instruct).markup_rules @@ -308,9 +432,9 @@ WOK data=@data tuned_file=Array.new data.each do |para| - para.gsub!(/<i>(Id\.?)(\s|$)/i, "/\{\\1\}\\2/") - para.gsub!(/^(~\{\{ .+?)(<\/LI>\s*|<\/OL>\s*)+$/i, "\\1") - para.gsub!(/\/\{Id\.\s*<\/LI>\s*\}\//i, '/{Id.}/') + para.gsub!(/<i>(Id\.?)(\s|$)/i,'/\{\1\}\2/') + para.gsub!(/^(~\{\{ .+?)(<\/LI>\s*|<\/OL>\s*)+$/i,'\1') + para.gsub!(/\/\{Id\.\s*<\/LI>\s*\}\//i,'/{Id.}/') tuned_file << para unless para == nil end tuned_file @@ -328,7 +452,7 @@ initial SiSU markup from other file formats WOK end -def doWord(argv, instruct) +def do_word(argv, instruct) argv.each do |f| if f =~/.+?\.doc$/ @argv << f[/(.+?)\.doc$/, 1] @@ -337,12 +461,12 @@ def doWord(argv, instruct) end end @argv.each do |filename| - system(%{wvWare -x #{@dir.home}/.sisu/convert/wvSiSU.xml #{filename}.doc > #{filename}.wv}) + system(%{wvWare -x #{@dir.path.home}/.sisu/convert/wvSiSU.xml #{filename}.doc > #{filename}.wv}) file_array=IO.readlines("#{filename}.wv", "") CONVERT::WareWord97.new(file_array, filename, instruct).songsheet # metaverse created here end end -def doHtml(argv, instruct) +def do_html(argv, instruct) argv.each do |f| if f =~/.+?\.html$/ @argv << f[/(.+?)\.html$/, 1] @@ -351,11 +475,11 @@ def doHtml(argv, instruct) end end @argv.each do |filename| - file_array=IO.readlines("#{filename}.html", "\n\r") - CONVERT::Html.new(file_array, filename, instruct).songsheet # metaverse created here + file_array=IO.readlines("#{filename}.html","\n\r") + CONVERT::Html.new(file_array,filename,instruct).songsheet # metaverse created here end end -def doDefault(argv, instruct) +def do_default(argv, instruct) argv.each do |f| if f =~/.+?\.html$/ @argv << f[/(.+?)\.html$/, 1] @@ -371,18 +495,21 @@ end def cases(argv, instruct) case instruct when/^--(word(97)?|doc)$/i #creates minimal sisu_small.gz package to send - doWord(argv, instruct) + do_word(argv, instruct) when/^--(html)$/i #creates sisu.gz package to send - doHtml(argv, instruct) + do_html(argv, instruct) when/^--(default)$/i #creates sisu.gz package to send - doDefault(argv, instruct) + do_default(argv, instruct) else help end end -require 'zxy_sysenv.rb' +$KCODE='u' +branch='v0' +SiSU_lib="sisu/#{branch}" +require "#{SiSU_lib}/sysenv" include SiSU_Env -@dir=SiSU_Env::Info_dir.new +@dir=SiSU_Env::Info_env.new @argv=Array.new argv=$* instruct = "#{argv[0].to_s}" diff --git a/data/sisu/conf/vim/addons/syntax/sisu.vim b/data/sisu/conf/vim/addons/syntax/sisu.vim index 13d22bb1..8a114b64 100644 --- a/data/sisu/conf/vim/addons/syntax/sisu.vim +++ b/data/sisu/conf/vim/addons/syntax/sisu.vim @@ -10,7 +10,7 @@ else endif "% 11 Errors? syn match sisu_error contains=sisu_link,sisu_error_wspace "<![^ei]\S\+!>" -"% 10 Markers: Endnote Identifiers, Pagebreaks etc.: +"% 10 Markers: Endnote Identifiers, Pagebreaks etc.: if !exists("sisu_no_identifiers") syn match sisu_mark_endnote "\~^" syn match sisu_contain contains=@NoSpell "</\?sub>" @@ -26,7 +26,7 @@ if !exists("sisu_no_identifiers") "metaverse specific syn match sisu_ocn contains=@NoSpell "<\~\d\+;\w\d\+;\w\d\+>" syn match sisu_marktail "<\~#>" - syn match sisu_markpara contains=@NoSpell "<:i[12]>" + syn match sisu_markpara contains=@NoSpell "<:i[1-9]>" syn match sisu_link " \*\~\S\+" syn match sisu_action "^<:insert\d\+>" syn match sisu_contain "<:e>" @@ -63,7 +63,7 @@ syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_co syn region sisu_linked contains=sisu_fontface,sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_link start="{" end="}image" oneline "% some line operations syn region sisu_control contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_error,sisu_error_wspace matchgroup=sisu_control start="\(\(^\| \)!_ \|<:b>\)" end="$" -syn region sisu_normal contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_\([12*]\|[12]\*\) " end="$" +syn region sisu_normal contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^_\([1-9*]\|[1-9]\*\) " end="$" syn region sisu_normal contains=sisu_strikeout,sisu_identifier,sisu_content_endnote,sisu_mark_endnote,sisu_link,sisu_linked,sisu_error,sisu_error_wspace matchgroup=sisu_markpara start="^\(#[ 1]\|_# \)" end="$" syn region sisu_comment matchgroup=sisu_comment start="^%\{1,2\} " end="$" "% font face curly brackets @@ -74,7 +74,7 @@ syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_control,sisu syn region sisu_underline contains=sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="+{" end="}+" syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start="\^{" end="}\^" syn region sisu_identifier contains=sisu_strikeout,sisu_number,sisu_control,sisu_identifier,sisu_error matchgroup=sisu_fontface start=",{" end="}," -syn region sisu_strikeout contains=sisu_error matchgroup=sisu_fontface start="-{" end="}-" +syn region sisu_strikeout contains=sisu_error matchgroup=sisu_fontface start="-{" end="}-" syn region sisu_html contains=sisu_error contains=sisu_strikeout matchgroup=sisu_contain start="<a href=\".\{-}\">" end="</a>" oneline "% single words bold italicise etc. "workon syn region sisu_control contains=sisu_error matchgroup=sisu_control start="\([ (]\|^\)\*[^\|{\n\~\\]"hs=e-1 end="\*"he=e-0 skip="[a-zA-Z0-9']" oneline diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index f8c7d25b..e2035d95 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -387,6 +387,9 @@ WOK p.i4 {margin-left: 35mm;} p.i5 {margin-left: 40mm;} p.i6 {margin-left: 45mm;} + p.i7 {margin-left: 50mm;} + p.i8 {margin-left: 55mm;} + p.i9 {margin-left: 60mm;} table { } tr { } @@ -452,11 +455,53 @@ WOK margin-bottom: 3px; } li.i2 { + margin-left: 25mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } + li.i3 { margin-left: 30mm; line-height: 150%; margin-top: 3px; margin-bottom: 3px; } + li.i4 { + margin-left: 35mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } + li.i5 { + margin-left: 40mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } + li.i6 { + margin-left: 45mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } + li.i7 { + margin-left: 50mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } + li.i8 { + margin-left: 55mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } + li.i9 { + margin-left: 60mm; + line-height: 150%; + margin-top: 3px; + margin-bottom: 3px; + } #horizontal_links { background: #eeeeee; margin-left: 5%; @@ -1338,6 +1383,54 @@ WOK text[class|="indent2"] { margin-left: 15%; } + text[class|="indent3"] { + margin-left: 20%; + } + text[class|="indent4"] { + margin-left: 25%; + } + text[class|="indent5"] { + margin-left: 30%; + } + text[class|="indent6"] { + margin-left: 35%; + } + text[class|="indent7"] { + margin-left: 40%; + } + text[class|="indent8"] { + margin-left: 45%; + } + text[class|="indent9"] { + margin-left: 50%; + } + text[class|="indent_bullet1"] { + margin-left: 10%; + } + text[class|="indent_bullet2"] { + margin-left: 15%; + } + text[class|="indent_bullet3"] { + margin-left: 20%; + } + text[class|="indent_bullet4"] { + margin-left: 25%; + } + text[class|="indent_bullet5"] { + margin-left: 30%; + } + text[class|="indent_bullet6"] { + margin-left: 35%; + } + text[class|="indent_bullet7"] { + margin-left: 40%; + } + text[class|="indent_bullet8"] { + margin-left: 45%; + } + text[class|="indent_bullet9"] { + margin-left: 50%; + } text[class|="verse"], text[class|="group"], text[class|="code"] { text-align: left; } @@ -1550,6 +1643,54 @@ WOK text[class|="indent2"] { margin-left: 15%; } + text[class|="indent3"] { + margin-left: 20%; + } + text[class|="indent4"] { + margin-left: 25%; + } + text[class|="indent5"] { + margin-left: 30%; + } + text[class|="indent6"] { + margin-left: 35%; + } + text[class|="indent7"] { + margin-left: 40%; + } + text[class|="indent8"] { + margin-left: 45%; + } + text[class|="indent9"] { + margin-left: 50%; + } + text[class|="indent_bullet1"] { + margin-left: 10%; + } + text[class|="indent_bullet2"] { + margin-left: 15%; + } + text[class|="indent_bullet3"] { + margin-left: 20%; + } + text[class|="indent_bullet4"] { + margin-left: 25%; + } + text[class|="indent_bullet5"] { + margin-left: 30%; + } + text[class|="indent_bullet6"] { + margin-left: 35%; + } + text[class|="indent_bullet7"] { + margin-left: 40%; + } + text[class|="indent_bullet8"] { + margin-left: 45%; + } + text[class|="indent_bullet9"] { + margin-left: 50%; + } text[class|="verse"], text[class|="group"], text[class|="code"] { text-align: left; } diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 513dc721..d0014ad6 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -61,7 +61,7 @@ module Syntax @manmkp_ital='[i/]\\{.+?\\}[i/]' tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)} tail_m_bold=%q{(?:(?:<\/i>)?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} - bold_line=%q{^!_\s.+?(?:\n|$)} + bold_line=%q{^!_\s.+?(?:<br>|\n|$)} @line_scan_ital=if defined? @md.make_italic[:str] and defined? @vz.markup_make_italic[:str] /#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|(?:#{@md.make_italic[:str]}|#{@vz.markup_make_italic[:str]})#{tail_m_ital}|\S+|\n/ elsif defined? @md.make_italic[:str] @@ -120,9 +120,10 @@ module Syntax line end def embolden(given) - given.gsub!(/(?:^!_|^[789]~)\s+(.+?)\s+((?:[*]~\S+\s*)+)/,'<b>\1</b> \2') - given.gsub!(/(?:^!_|^[789]~)\s+(.+?)\s*([~-]#)$/,'<b>\1</b> \2') - given.gsub!(/(?:^!_\s+|^[789]~\s+)(.*)?\s*$/,'<b>\1</b>') + given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)(<br>)/,'<b>\1</b>\2') + given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)\s+((?:[*]~\S+\s*)+)/,'<b>\1</b> \2') + given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)\s*([~-]#)$/,'<b>\1</b> \2') + given.gsub!(/(?:^!_\s+|^[7-9]~\s+)(.*)?\s*$/,'<b>\1</b>') end def wordlist_bold(line) line=line.dup @@ -140,7 +141,7 @@ module Syntax w.gsub!(@vz.markup_make_bold,'<b>\1</b>') end else - if w =~ /(?:^!_|^[789]~)\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + if w =~ /(?:^!_|^[7-9]~)\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! end end line_array << w @@ -149,7 +150,7 @@ module Syntax else line end else - if line !~/^(?:[0-9]~|%+\s)/ and line =~ /(?:^!_|^[789]~)\s+/; embolden(line) + if line !~/^(?:[0-9]~|%+\s)/ and line =~ /(?:^!_|^[7-9]~)\s+/; embolden(line) end end line @@ -172,8 +173,10 @@ module Syntax # ~{endnote}~ <!e endnote !> # !_ #bold/emphasise paragraph # _" #blockquote paragraph - # _1 <!i1!> #indent paragraph 1 step - # _2 <!i2!> #indent paragraph 2 steps + # _1 <:i1> #indent paragraph 1 step + # _2 <:i2> #indent paragraph 2 steps + # _3 <:i3> #indent paragraph 3 steps + # _4 <:i4> #indent paragraph 4 steps # _* #bullet (list) # _1* #bullet (list) indented # _1* #bullet (list) indented @@ -255,17 +258,15 @@ module Syntax line.gsub!(/(^|\s+)-([^{]\S+?)-( |$)/,'\1<del>\2</del>\3') #underscore single word, watch line.gsub!(/(^|\s+|['"]| |\(|\>|\d+)\^(\S+?)\^/,'\1<sup>\2</sup>') #superscript single word, watch digit added line.gsub!(/<[:e]\s+(.+?)!?>/,'~{ \1 }~') # not tested - line.gsub!(/^\s*_([12])(\*+)\s*/,'<:i\1> _* ') #bullets, shortcut - line.gsub!(/^\s*_([12])\s+/,'<:i\1> ') #indent + line.gsub!(/^\s*_([1-9])(\*+)\s*/,'<:i\1> _* ') #bullets, shortcut + line.gsub!(/^\s*_([1-9])\s+/,'<:i\1> ') #indent line.gsub!(/(?:<br>|<br \/>)\s*_[12]\s+/,'<br> ') #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') - #line.gsub!(/^\s*_([12])\s+/,"<:i\\1> ") - #line.gsu!b!(/^\s*_([12])\s+/,"<!i\\1!> ") #indent line line.gsub!(/<:?br>/,'<br />') #adjustment 2004w41, from # line.gsub!(/<br>/,'<br />') ##added - #line.gsub!(/(?:^!_\s+|^[78]~\s+|<:b>)(.*)?([~-]#)$/i,"<b>\\1</b> \\2") #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - #line.gsub!(/(?:^!_\s+|^[78]~\s+|<:b>)(.*)?\s*$/i,"<b>\\1</b>") #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - #line.gsub!(/(?:(?:^| )!_ |^[78]~ |<:b>)(.*)\n/mi,"<b>\\1</b> ") #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - #line.gsub!(/^_" (.*)\n/i,"<blockquote>\\1</blockquote> ") #blockquotes #introduce KEEP + #line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?([~-]#)$/i,'<b>\1</b> \2') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + #line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?\s*$/i,'<b>\1</b>') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + #line.gsub!(/(?:(?:^| )!_ |^[7-9]~ |<:b>)(.*)\n/mi,'<b>\1</b> ') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + #line.gsub!(/^_" (.*)\n/i,'<blockquote>\1</blockquote> ') #blockquotes #introduce KEEP line.gsub!(/<:hi>/,'<span style="background-color: rgb(255,240,196)">') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) line.gsub!(/<:\/hi>/,'</span>') line.gsub!(/(<:verse>.+)/m,"\\1\n") @@ -319,8 +320,8 @@ module Syntax line.gsub!(/(^|\s+|['"]|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/,'\1<i>\2</i>\3') #italics single word, watch line.gsub!(/(^|\s+|['"]|\(|\>)_(\S+?)_/,'\1<u>\2</u>') #underscore single word, watch line.gsub!(/(^|\s+|['"]|\(|\>|\d+)\^(\S+?)\^/,'\1<sup>\2</sup>') #superscript single word, watch digit added - line.gsub!(/^\s*_([12])(\*+)\s*/,"<:i\\1> _* ") # bullets, shortcut - line.gsub!(/^\s*_([12])\s+/,'<:i\1> ') + line.gsub!(/^\s*_([1-9])(\*+)\s*/,'<:i\1> _* ') # bullets, shortcut + line.gsub!(/^\s*_([1-9])\s+/,'<:i\1> ') line.gsub!(/<:?br>/,'<br />') end @data diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 3e1c72cc..459cb806 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -85,7 +85,6 @@ module SiSU_DB_import def marshal_load require "#{SiSU_lib}/dal" @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - #@dal_array.each { |x| puts x.inspect; sleep 1 } tell=SiSU_Screen::Ansi.new(@opt.cmd,"#{@db.db_psql}::#{@opt.fns}") tell.puts_blue unless @opt.cmd =~/q/ tell=SiSU_Screen::Ansi.new(@opt.cmd,'Marshal Load',@fnm) @@ -111,7 +110,7 @@ module SiSU_DB_import end end def special_character_escape(string) - string.gsub!(/'/,"''") + string.gsub!(/'/,"''") #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'") string.gsub!(/<:br>/,"<br />\n") string.gsub!(/<:(?:code|alt|group|verse)(?:-end)?>/,'') string.gsub!(/<:name#\S+?>/,'') diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index c81b91d2..3713acae 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -206,6 +206,27 @@ module SiSU_Viz def url_promo_home '' end + def url_decoration + def tex_open + '{\UseTextSymbol{OML}{<}}' + end + def tex_close + '{\UseTextSymbol{OML}{>}}' + end + def xml_open + '<' + end + def xml_close + '>' + end + def txt_open + '<' + end + def txt_close + '>' + end + self + end #% color def color_shadow '"4"' diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 1d9491dd..9af0f758 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -199,11 +199,11 @@ module SiSU_HTML @format,@text,@ocn=$1,$2,$3 end else - if @para[/^(?:_1\*|<:i[12]>\s*_\*)\s+(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m] - @format,@text,@ocn='_1*',$1,$2,$3 + if @para[/^(?:<:i([1-9])>\s*_\*)\s+(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m] + @format,@text,@ocn="_#{$1}\*",$2,$3,$4 elsif @para[/^(_\*)\s+(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m] @format,@text,@ocn=$1,$2,$3 - elsif @para[/<:(i[12])>\s*(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m] + elsif @para[/<:(i[1-9])>\s*(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m] @format,@text,@ocn=$1,$2,$3 elsif @para[/<:(code|alt|verse|group)>(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m] @format,@text,@ocn=$1,$2,$3 diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 73c97358..0899447e 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -917,7 +917,6 @@ WOK @@dp=nil attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped def initialize(md='',*txt) - #txt[0].gsub!(/\.(html|pdf|php)/,'') if txt[0] =~/\.\.\/\S+/ @md,@one,@two,@three=md,txt[0],txt[1],txt[2] rgx=/^[1-6-]~/ @one_stripped=@one.gsub(rgx,'') if @one =~rgx @@ -927,7 +926,7 @@ WOK @link,@linkname=txt[0],txt[1] @format,parablock=txt[0],txt[1] @parablock=parablock - ##speed hit does not justify action: + ##performance hit does not justify action: #@parablock=if parablock=~/\S+/ and parablock !~/<!Th?¡ /m # wrap=SiSU_text_utils::Wrap.new(parablock,70,4) # wrap.line_wrap @@ -979,20 +978,8 @@ WOK @tag,@class='li','bullet' para_form end - def bullet_indent1 - @tag,@class='li','i1' - para_form - end - def bullet_indent2 - @tag,@class='li','i2' - para_form - end - def indent1 - @tag,@class='p','i1' - para_form - end - def indent2 - @tag,@class='p','i2' + def format(tag,atrib) + @tag,@class=tag,atrib para_form end def dl @@ -1013,12 +1000,12 @@ WOK end def gsub_body case @one - when /^(?:<:i[12]>\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ + when /^(?:<:i[1-9]>\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ @one.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') - @one.gsub!(/^(<:i[12]>)\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') - when /^(?:<:i[12]>\s*)?\(?(\d|[a-z])+\)/ + @one.gsub!(/^(<:i[1-9]>)\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') + when /^(?:<:i[1-9]>\s*)?\(?(\d|[a-z])+\)/ @one.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') - @one.gsub!(/^(<:i[12]>)\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') + @one.gsub!(/^(<:i[1-9]>)\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') when /^\s*\d{1,3}\.\s/ @one.gsub!(/^\s*(\d+\.)/,'<b>\1</b>') when /^\s*[A-Z]\.\s/ @@ -1034,6 +1021,17 @@ WOK #{@vz.table_close}} end + def bold_header + @one.gsub!(/[1-9]~(\S+)/,'<a name="\1"></a>') + @one.gsub!(/[1-9]~/,'') + @one.gsub!(/<~0;[um]\d+;[um]\d+><#@dp:#@dp>\s*$/i,'') #watch & do differently + %{<p class="bold"> + #@one + </p> +#{@vz.margin_num_css} + +#{@vz.table_close}} + end def toc_head_copy_at %{<p class="center">#@one</p>\n} end diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index bc03fc7d..1774fb3f 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -86,136 +86,68 @@ module SiSU_HTML_scroll @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) end @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).lev_segname_para_ocn - unless @rcdc - m=/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - if para =~m - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/[12]|_1?\*|<!i[12]!>\s*_\*|null/ - case @sto.format - when /^1~\S*/; para=@sto.scroll_lev_para_ocn.heading_body1 - when /^2~\S*/; para=@sto.scroll_lev_para_ocn.heading_body2 - when /^3~\S*/; para=@sto.scroll_lev_para_ocn.heading_body3 - when /^4~\S+/; para=@sto.scroll_lev_para_ocn.heading_body4 # work on see Split_text_object4 - when /^5~\S*/; para=@sto.scroll_lev_para_ocn.heading_body5 - when /^6~\S*/; para=@sto.scroll_lev_para_ocn.heading_body6 - when /^_\*$/; para=@sto.scroll_lev_para_ocn.bullet - when /^_1\*$/ + m=/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + if para =~m + format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|_[1-9]?\*|<:i[1-9]>\s*_\*|null/ + case @sto.format + when /^1~\S*/; para=@sto.scroll_lev_para_ocn.heading_body1 + when /^2~\S*/; para=@sto.scroll_lev_para_ocn.heading_body2 + when /^3~\S*/; para=@sto.scroll_lev_para_ocn.heading_body3 + when /^4~\S+/; para=@sto.scroll_lev_para_ocn.heading_body4 # work on see Split_text_object4 + when /^5~\S*/; para=@sto.scroll_lev_para_ocn.heading_body5 + when /^6~\S*/; para=@sto.scroll_lev_para_ocn.heading_body6 + when /^_\*$/; para=@sto.scroll_lev_para_ocn.bullet + when /^_([1-9])\*$/ #indent with bullet + format_txt_obj.gsub_body + para=@sto.scroll_lev_para_ocn.format('li',"i#{$1}") + when /^i([1-9])$/ #indent + format_txt_obj.gsub_body + para=@sto.scroll_lev_para_ocn.format('p',"i#{$1}") + when /^center$/; para=@sto.scroll_lev_para_ocn.center + when /^(?:b|bold)$/; para=@sto.scroll_lev_para_ocn.bold + when /^(?:verse|group|alt)$/; para=@sto.scroll_lev_para_ocn.para + when /^code$/; para=@sto.scroll_lev_para_ocn.code + when /null/ # see whether u can improve + if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.bullet_indent1 - when /^_2\*$/ - format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.bullet_indent2 - when /^i1$/ - format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.indent1 - when /^i2$/ - format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.indent2 - when /^center$/; para=@sto.scroll_lev_para_ocn.center - when /^(?:b|bold)$/; para=@sto.scroll_lev_para_ocn.bold - when /^(?:verse|group|alt)$/; para=@sto.scroll_lev_para_ocn.para - when /^code$/; para=@sto.scroll_lev_para_ocn.code - when /null/ # see whether u can improve - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ - format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.para - if para =~/<!Th?.+/ # tables come as single block - table=SiSU_HTML_shared::Table.new(para) - para=table.table_split - end - end - end - elsif para =~/Endnotes?/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="notes">Note</a>') - para=format_txt_obj.bold_para - elsif para =~/Owner Details/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="owner.details">Owner Details</a>') - @scr[:owner_details]=format_txt_obj.bold_para - para='' - elsif para =~/(.*)<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>(.*)/ #watch - one,two=$1,$2 - format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) - para=format_seg.no_paranum - end - #para=para.gsub(/ [2-6]~\S+ /,'') #and @md.cmd =~/[VM]/ #arbitrary, watch problematic as too general - para='' if (para =~/<a name="n\d+">/ and para =~/^(?:\^~\d+\s|<!e[:_]\d+!>)/) # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though - if para =~/<:center>/ #rules changed now a <p class="center" problems may arise 2005w11 ! - one,two=/(.*)<:center>(.*)/.match(para).captures - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) - end - else # this is crazy rethink and redo later with some form of inject - m=/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - if para =~m - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/[12]|null/ - meta=case @sto.format - when /^1~/; @sto.scroll_lev_para_ocn.heading_body1 - when /^2~/; @sto.scroll_lev_para_ocn.heading_body2 - when /^3~/; @sto.scroll_lev_para_ocn.heading_body3 - when /^4~\S+/; @sto.scroll_lev_para_ocn.heading_body4 # work on see Split_text_object - when /^5~/; @sto.scroll_lev_para_ocn.heading_body5 - when /^6~/; @sto.scroll_lev_para_ocn.heading_body6 - when /^i1$/ - format_txt_obj.gsub_body - @sto.scroll_lev_para_ocn.indent1 - when /^i2$/ - format_txt_obj.gsub_body - @sto.scroll_lev_para_ocn.indent2 - when /^center$/; @sto.scroll_lev_para_ocn.center - when /^(b|bold)$/; @sto.scroll_lev_para_ocn.bold - when /null/ # see whether u can improve - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ - format_txt_obj.gsub_body - @sto.scroll_lev_para_ocn.para - if para =~/<!Th?.+/ # tables come as single block - table=Table.new(para) - para=table.table_split - end + para=@sto.scroll_lev_para_ocn.para + if para =~/<!Th?.+/ # tables come as single block + table=SiSU_HTML_shared::Table.new(para) + para=table.table_split end end - elsif para =~/(Endnotes?)/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="notes">Note</a>') - meta=format_txt_obj.bold_para - elsif para =~/MetaData/ and para =~/<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="metadata">MetaData</a>') - meta=format_txt_obj.bold_para - elsif para =~/Owner Details/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="owner.details">Owner Details</a>') - @scr[:owner_details]=format_txt_obj.bold_para - meta='' - elsif para =~/(¡|<!Th?)/ - table=Table.new(para) - para=table.table - elsif para =~/(.*)<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>(.*)/ #ok - bug in equiv for seg 2004w46 - one,two=$1,$2 - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) #watch #fix - meta=format_scroll.no_paranum - end - meta='' if para =~/<a name="n\d+">/ and para =~/^(\^~\d+ |<!e[:_]\d+!>)/ # -endnote - if para =~/<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - case para - when /<:i1>/ - gsub(/<:i1>/,'') - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,para) - meta=format_scroll.indent_one_no_paranum - when /<:i2>/ - gsub(/<:i2>/,'') - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,para) - meta=format_scroll.indent_one_no_paranum - end - end - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ - end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para).captures - format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) end + elsif para =~/^[1-9]~\S*/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,para) + para=format_txt_obj.bold_header + elsif para =~/Endnotes?/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="notes">Note</a>') + para=format_txt_obj.bold_para + elsif para =~/Owner Details/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="owner.details">Owner Details</a>') + @scr[:owner_details]=format_txt_obj.bold_para + para='' + elsif para =~/(.*)<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>(.*)/ #watch + one,two=$1,$2 + format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) + para=format_seg.no_paranum + end + #para=para.gsub(/ [2-6]~\S+ /,'') #and @md.cmd =~/[VM]/ #arbitrary, watch problematic as too general + para='' if (para =~/<a name="n\d+">/ and para =~/^(?:\^~\d+\s|<!e[:_]\d+!>)/) # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though + if para =~/<:center>/ #rules changed now a <p class="center" problems may arise 2005w11 ! + one,two=/(.*)<:center>(.*)/.match(para).captures + format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) end para.gsub!(/<!.+!>/,' ') para.gsub!(/^<:\S?>/,'') para.gsub!(/<:\S?>/,' ') para.strip! - unless meta; @scr[:body] << para unless para =~/\A\s*\Z/ - else @scr[:metadata] << meta + unless @rcdc; @scr[:body] << para unless para =~/\A\s*\Z/ + else @scr[:metadata] << para end + #unless meta; @scr[:body] << para unless para =~/\A\s*\Z/ + #else @scr[:metadata] << meta + #end end end @scr diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 96b9a970..8f8f7b53 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -279,21 +279,18 @@ module SiSU_HTML_seg end if para[/<~(\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+><#@dp:#@dp)>$/] @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).lev_segname_para_ocn - format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[12]|_1?\*|<:i[12]>\s*_\*|null/ + format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|_[1-9]?\*|<:i[1-9]>\s*_\*|null/ para=case @sto.format # work area 2003w29 ||@|def lev_segname_para_ocn| when /^4~\S+/; @sto.seg_lev_para_ocn.header4 # work on see Split_text_object when /^5~(?:~\S+)?/; @sto.seg_lev_para_ocn.header5 when /^6~(?:~\S+)?/; @sto.seg_lev_para_ocn.header6 when /^_\*$/; @sto.seg_lev_para_ocn.bullet - when /^_1\*$/ + when /^_([1-9])\*$/ #indent levels 1-9 with bullet format_txt_obj.gsub_body - @sto.seg_lev_para_ocn.bullet_indent1 - when /^i1$/ + para=@sto.seg_lev_para_ocn.format('li',"i#{$1}") + when /^i([1-9])$/ #indent levels 1-9 format_txt_obj.gsub_body - @sto.seg_lev_para_ocn.indent1 - when /^i2$/ - format_txt_obj.gsub_body - @sto.seg_lev_para_ocn.indent2 + para=@sto.seg_lev_para_ocn.format('p',"i#{$1}") when /^(?:verse|group|alt)$/ @sto.seg_lev_para_ocn.para when /^code$/ @@ -439,7 +436,7 @@ module SiSU_HTML_seg try=e_n.split(/<br \/>/) try.each do |e| format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,e) - note_match=if e =~/<:i[12]>/ + note_match=if e =~/<:i[1-9]>/ format_seg.endnote_body_seg_tail_indent else format_seg.endnote_body_seg_tail end diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 2d295a6c..749f5180 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -187,6 +187,7 @@ module SiSU_Tune @env=SiSU_Env::Info_env.new(@md.fns) @sys=SiSU_Env::System_call.new @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @env=SiSU_Env::Info_env.new(@md.fns) #@utf8=SiSU_character_encode::UTF8 #.new end def songsheet @@ -231,6 +232,45 @@ module SiSU_Tune @tuned_file << para end end + def urls(data) + @words=[] + data.each do |word| + @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ + if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/ + m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/.match(word).captures + else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures + d='' + end + case m + when /\.png|\.jpg|\.gif|c=|\d+x\d+/ + w,h=/(\d+)x(\d+)/.match(m).captures if m =~/\d+x\d+/ + w=%{width="#{w}"} if w + h=%{height="#{h}"} if h + c=m[/"(.+?)"/m,1] + caption=%{<br /><p class="caption">#{c}</p>} if c + png=m.scan(/\S+/)[0] + image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external + else @env.url.images_local + end + ins=if u and u.strip !~/^image$/ + %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}} + else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}} + end + word.gsub!(/\{.+?\}((?:https?|ftp)\S+|image)/,ins) + else + link=m[/(.+)/m] + png=m.scan(/\S+/)[0].strip + link=link.strip + ins=%{<a href="#{u}">#{link}</a>#{d}} + word.gsub!(/\{.+?\}(?:https?|ftp)\S+/,ins) + end + word + else word + end + word + end + @words + end def url_markup data=@data @tuned_file=[] @@ -256,7 +296,7 @@ module SiSU_Tune end if para =~/\{.+?\}((?:http|ftp)\S+|image)/ @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) - word_mode=SiSU_Tune::Tune_urls.new(@word_mode,@md).urls + word_mode=urls(@word_mode) words=word_mode.join(' ') para.gsub!(/.+/,words) end @@ -274,20 +314,20 @@ module SiSU_Tune para.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) - para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<a href="mailto:\1">\1</a>\\2') + para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<<a href="mailto:\1">\1</a>>\2') end if (para !~/(\"\w+:\/\/\S+?\"|>\s*\w+:\/\/\w+?\S*<)/) #url markup http etc. if para=~/\w+:\/\/\S+?\.\S+?[.,] / - para.gsub!(/(\w+:\/\/\S+?\.\S+?)([.,] )/,'<a href="\1" target="_top">\1</a>\2') #full stops ! have been a bother + para.gsub!(/(\w+:\/\/\S+?\.\S+?)([.,] )/,'<<a href="\1" target="_top">\1</a>>\2') #full stops ! have been a bother else - para.gsub!(/(\w+:\/\/\S+?\.\S+)/, '<a href="\1" target="_top">\1</a>') + para.gsub!(/(\w+:\/\/\S+?\.\S+)/, '<<a href="\1" target="_top">\1</a>>') end end if (para =~/[ ^](?:https?|ftp):\/\/\S+/) #url markup http leftovers watch carefully may accept too much 2004w46 if para=~/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/ - para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/,'\1<a href="\2" target="_top">\2</a>\3') #full stops ! have been a bother + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/,'\1<<a href="\2" target="_top">\2</a>>\3') #full stops ! have been a bother else - para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+)/,'\1<a href="\2" target="_top">\2</a>') + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+)/,'\1<<a href="\2" target="_top">\2</a>>') end end if (para =~/..\/\S+/ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/) @@ -326,51 +366,5 @@ module SiSU_Tune @tuned_file end end - class Tune_urls - def initialize(data,md) - @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin - @env=SiSU_Env::Info_env.new(@md.fns) - end - def urls - @words=[] - @data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ - if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/ - m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures - d='' - end - case m - when /\.png|\.jpg|\.gif|c=|\d+x\d+/ - w,h=/(\d+)x(\d+)/.match(m).captures if m =~/\d+x\d+/ - w=%{width="#{w}"} if w - h=%{height="#{h}"} if h - c=m[/"(.+?)"/m,1] - caption=%{<br /><p class="caption">#{c}</p>} if c - png=m.scan(/\S+/)[0] - image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external - else @env.url.images_local - end - ins=if u and u.strip !~/^image$/ - %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}} - else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}} - end - word.gsub!(/\{.+?\}((?:https?|ftp)\S+|image)/,ins) - else - link=m[/(.+)/m] - png=m.scan(/\S+/)[0].strip - link=link.strip - ins=%{<a href="#{u}">#{link}</a>#{d}} - word.gsub!(/\{.+?\}(?:https?|ftp)\S+/,ins) - end - word - else word - end - word - end - @words - end - end end __END__ diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index caf86a39..feac2d03 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -140,6 +140,7 @@ module SiSU_ODF end end class Scroll <Source + require "#{SiSU_lib}/defaults" require "#{SiSU_lib}/shared_txt" @@img_count=0 @@odf={ :body=>[],:open=>[],:close=>[],:head=>[],:metadata=>[],:tail=>[],:endnotes=>[] } @@ -153,13 +154,14 @@ module SiSU_ODF @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ @serial=/\s*<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>\s*/ @tab="\t" + @url_brace=SiSU_Viz::Skin.new.url_decoration @br=if @md.cmd =~/M/; "\n" else '' end end def songsheet pre - @data=markup + @data=markup(@data) post publish end @@ -169,8 +171,8 @@ module SiSU_ODF @n=[] notes.each do |n| #high cost to deal with <br> appropriately within odf, consider n=n.dup.to_s - if n =~/<br(?: \/)?>/ - fix=n.split(/<br(?: \/)?>/) #watch #added + if n =~/<:?br(?: \/)?>/ + fix=n.split(/<:?br(?: \/)?>/) #watch #added fix.each do |x| if x =~/\S+/; @n << x end @@ -282,16 +284,16 @@ module SiSU_ODF end def normal(para) #P1 - P3 para.gsub!(@serial,'') - para.gsub!(/(^|\s)(https?:\/\/[^'">< ]+)/,'\1<text:a xlink:type="simple" xlink:href="\2">\2</text:a>') - para.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/,'<text:a xlink:type="simple" xlink:href="mailto:\1">\1</text:a>') - par=case para - when /^<:i1>\s/m; para.gsub!(/^<:i1>\s/m,'') - %{<text:p text:style-name="P2">#{para}</text:p>} - when /^<:i2>\s/m; para.gsub!(/^<:i2>\s/m,'') - %{<text:p text:style-name="P3">#{para}</text:p>} - else %{<text:p text:style-name="P1">#{para}</text:p>} #%{<text:p text:style-name="Standard">#{para}</text:p>} + para.gsub!(/(^|\s)(https?:\/\/[^'">< ]+)/,%{\\1#{@url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\2">\\2</text:a>#{@url_brace.xml_close}}) + para.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/,%{#{@url_brace.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@url_brace.xml_close}}) + para=case para + when /^<:i([1-9])>\s/m + m=$1 + para.gsub!(/^<:i#{m}>\s/m,'') + %{<text:p text:style-name="P1#{m}">#{para}</text:p>} + else %{<text:p text:style-name="P1">#{para}</text:p>} end - para=par #+ %{<text:p text:style-name="Standard"/>} + para end def fontface(para) #para=para.gsub(/<b>(.+?)<\/b>/,%{<text:span text:style-name="T1">\\1</text:span>}) @@ -300,7 +302,7 @@ module SiSU_ODF def footnote(para) @astx||=10000 para.gsub!(/<#@dp>([}\]]~)/,'\1') - para.gsub!(/<br \/><:i1>/,'<br />') + #para.gsub!(/<br \/><:i[1-9]>/,'<br />') if para =~/~\{\d+\s+/ para=para.gsub(/~\{(\d+)\s+(.+?)\}~/,'<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>') end @@ -324,9 +326,7 @@ module SiSU_ODF end def group_clean(para) para.gsub!(/&nbsp;| /,' ') - para.gsub!(/</,'<') - para.gsub!(/>/,'>') - #para.gsub!(/<br(?:\s+\/)?>/,'<br />') + para.gsub!(/</,'<'); para.gsub!(/>/,'>') para.gsub!(/<br(?:\s+\/)?>/,'<br />') #para.gsub!(/\s\s/,'  ') para @@ -334,9 +334,9 @@ module SiSU_ODF def poem(para) #P4 #same as group para.gsub!(@serial,'') para.gsub!(/<:verse(?:-end)?>\s*/m,'') - para=group_clean(para) parray=[] - para.split(/<br(?: \/)?>/).each do |parablock| + para.split(/<:?br(?: \/)?>/).each do |parablock| + parablock=group_clean(parablock) parray << %{<text:p text:style-name="P4">#{parablock}</text:p>} if parablock =~/\S+/ end para=parray.join + '<text:p text:style-name="Standard"/>' @@ -344,9 +344,9 @@ module SiSU_ODF def group(para) #P4 #same as verse para.gsub!(@serial,'') para.gsub!(/<:group(?:-end)?>\s*/m,'') - para=group_clean(para) parray=[] - para.split(/<br(?: \/)?>/).each do |parablock| + para.split(/<:?br(?: \/)?>/).each do |parablock| + parablock=group_clean(parablock) parray << %{<text:p text:style-name="P4">#{parablock}</text:p>} if parablock =~/\S+/ end para=parray.join + '<text:p text:style-name="Standard"/>' @@ -354,10 +354,10 @@ module SiSU_ODF def code(para) #P5 para.gsub!(@serial,'') para.gsub!(/<:code(?:-end)?>\s*/m,'') - para=group_clean(para) para.gsub!(/\s\s/,'  ') parray=[] - para.split(/<:br>/).each do |parablock| + para.split(/<:?br(?: \/)?>/).each do |parablock| + parablock=group_clean(parablock) parray << %{<text:p text:style-name="P5">#{parablock}</text:p>} if parablock =~/\S+/ end para=parray.join + '<text:p text:style-name="Standard"/>' @@ -414,8 +414,7 @@ module SiSU_ODF #end wordlist end - def markup # Used for major markup instructions - data=@data + def markup(data) # Used for major markup instructions safe_characters=/[^a-zA-Z0-9}{\/?,."';:)(><\-_&!@%~#\]\[*=$| \n+`¡]/ dir=SiSU_Env::Info_env.new(@md.fns) @data_mod,@endnotes,@level,@cont,@copen,@odf_contents_close=Array.new(6){[]} @@ -443,9 +442,11 @@ module SiSU_ODF para=para_array.join(' ') para=para.strip end - para.gsub!(/^(<:i[12]>\s+)?_\*\s+/,'\\1<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.25cm" svg:height="0.25cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_red.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ') # bullet_red.png + para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\\1<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.25cm" svg:height="0.25cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_red.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ') # bullet_red.png #para.gsub!(/^_\*\s+/,'<text:span text:style-name="T6">·</text:span> ') #bullet - para.gsub!(/^(<:i[12]>)\s+_\*\s+/,'\1 <text:span text:style-name="T6">·</text:span> ') #bullet + para.gsub!(/^(<:i[1-9]>)\s+_\*\s+/,'\1 <text:span text:style-name="T6">·</text:span> ') #bullet + #para.gsub!(/^(<:i[1-9]>\s+)?_\*\s+/,'\\1<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.25cm" svg:height="0.25cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_red.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ') # bullet_red.png + #para.gsub!(/^(<:i[1-9]>)\s+_\*\s+/,'\1 <text:span text:style-name="T6">·</text:span> ') #bullet para.gsub!(/<br>/,'<br />') para.gsub!(/<:p[bn]>/,'<text:p text:style-name="P8"> </text:p>') para.gsub!(/©/,'©') #too arbitrary @@ -542,18 +543,6 @@ module SiSU_ODF para=format_text.seg_no_paranum end para='' if para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote - case para #remove - when /<:i1>/ - if para =~/.*<:#>.*$/ - format_text=OD_format::Format_text_object.new(para,'') - para=format_text.scr_indent_one_no_paranum - end - when /<:i2>/ - if para =~/.*<:#>.*$/ - format_text=OD_format::Format_text_object.new(para,'') - para=format_text.scr_indent_one_no_paranum - end - end if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/) # i don't get the condition for no paranum end @@ -613,14 +602,26 @@ module SiSU_ODF %{<office:automatic-styles>#@br} + %{#{table}#@br} + %{<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:text-align="justify" style:justify-single-word="false"/></style:style>#@br} + - %{<style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="1cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + - %{<style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="2cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:text-align="justify" style:justify-single-word="false"/></style:style>#@br} + # P1 + %{<style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:text-align="justify" style:justify-single-word="false"/></style:style>#@br} + # P1 %{<style:style style:name="P4" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%" fo:text-align="justify" style:justify-single-word="false"/></style:style>#@br} + %{<style:style style:name="P5" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm" fo:line-height="100%" fo:text-align="start" style:justify-single-word="false"/></style:style>#@br} + %{<style:style style:name="P6" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-before="page"/></style:style>#@br} + %{<style:style style:name="P7" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:paragraph-properties fo:text-align="justify" style:justify-single-word="false"/></style:style>#@br} + %{<style:style style:name="P8" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-before="page"/></style:style>#@br} + %{<style:style style:name="P9" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-after="page"/></style:style>#@br} + + %{<style:style style:name="P10" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:text-align="justify" style:justify-single-word="false"/></style:style>#@br} + # P1 + + %{<style:style style:name="P11" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="1cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P12" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="2cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P13" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="3cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P14" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="4cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P15" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="5cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P16" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="6cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P17" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="7cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P18" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="8cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="P19" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:margin-top="0.199cm" fo:margin-bottom="0.199cm" fo:line-height="150%" fo:margin-left="8cm" fo:margin-right="0cm" fo:text-align="justify" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/></style:style>#@br} + + %{<style:style style:name="T1" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/></style:style>#@br} + %{<style:style style:name="T2" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/></style:style>#@br} + %{<style:style style:name="T3" style:family="text"><style:text-properties style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color"/></style:style>#@br} + diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index c39cba14..8728741a 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -143,6 +143,7 @@ module SiSU_Plaintext end end class Scroll <Source + require "#{SiSU_lib}/defaults" require "#{SiSU_lib}/shared_txt" include SiSU_text_utils @@endnotes_para=[] @@ -150,6 +151,7 @@ module SiSU_Plaintext @@dp=nil def initialize(data,md) @data,@md=data,md + @url_brace=SiSU_Viz::Skin.new.url_decoration @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #m # 2004w18 pb pn removal added @@ -171,7 +173,7 @@ module SiSU_Plaintext end end def songsheet - markup + @data=markup(@data) publish #@data.each { |x| puts x.inspect if x =~/\[table/ } end @@ -264,9 +266,10 @@ WOK para.gsub!(/~[{\[]([\d*+]+)\s+(?:.+?)[}\]]~/,'[^\1]') # endnote marker marked up wrapped=if para[@regx] paragraph=para[@regx,2] - if paragraph.include? '<:i1>' - paragraph.gsub!(/<:i1>/,'') - util=SiSU_text_utils::Wrap.new(paragraph,70,2) + if paragraph =~/<:i([1-9])>/ + m=$1.to_i + paragraph.gsub!(/<:i#{m}>/,'') + util=SiSU_text_utils::Wrap.new(paragraph,70,m*2) else util=SiSU_text_utils::Wrap.new(paragraph,70,0) end util.line_wrap @@ -291,8 +294,7 @@ WOK end @@endnotes_para=[] end - def markup # Used for major markup instructions - data=@data + def markup(data) # Used for major markup instructions dir=SiSU_Env::Info_env.new(@md.fns) @data_mod,@endnotes,@level,@cont,@copen,@plaintext_contents_close=Array.new(6){[]} (0..6).each { |x| @cont[x]=@level[x]=false } @@ -303,17 +305,22 @@ WOK data.each do |para| para.gsub!(/<!Th?¡.+/m,"#@br#{table_message}") para.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check - para.gsub!(/_\*\s+/,'* ') # bullet markup, marked down + para.gsub!(/_\*\s+/,'* ') # bullet markup, marked down + #para.gsub!(/<br(?: \/)?>/,"\n") # introduces a bug para.gsub!(/©/,'©') # bullet markup, marked down - para.gsub!(/&/,'&') # bullet markup, marked down + para.gsub!(/&/,'&') # bullet markup, marked down para.gsub!(/<sup>(.+?)<\/sup>/,'^\1^') para.gsub!(/<sub>(.+?)<\/sub>/,'[\1]') para.gsub!(/<i>(.+?)<\/i>/,'/\1/') para.gsub!(/<b>(.+?)<\/b>/,'*\1*') para.gsub!(/<u>(.+?)<\/u>/,'_\1_') - para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,'') + if para =~/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/ + para.gsub!(/<br(?: \/)?>/,"\n") # watch + para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,'') + end para.gsub!(/<:p[bn]>/,'') # remove page breaks para.gsub!(/^\s*<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'') # remove empty lines - check + para.gsub!(/(^|\s)(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/,"\\1#{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") para.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1') para.gsub!(/<:name#\S+?>/,'') # remove name links para.gsub!(/ /,' ') # decide on @@ -394,13 +401,8 @@ WOK end para='' if (para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote case para - when /<:i1>/ - if para =~/.*<:#>.*$/ - format_text=Format_text_object.new(para,'') - para=format_text.scr_indent_one_no_paranum - end - when /<:i2>/ - if para =~/.*<:#>.*$/ + when /<:i[1-9]>/ + if para =~/.*<:#>.*$/m format_text=Format_text_object.new(para,'') para=format_text.scr_indent_one_no_paranum end @@ -421,7 +423,6 @@ WOK def publish divider="=" content=[] - data=@data content << @@plaintext[:open] content << @@plaintext[:head] content << @@plaintext[:body] @@ -446,11 +447,12 @@ WOK filename_plaintext=SiSU_Env::SiSU_file.new(@md,@md.fn[:plain]).mkfile @sisu=[] @content.each do |para| # this is a hack - if para =~/^\S/ - if para !~/^([*=-]|\.){5}/; filename_plaintext.puts para #unix plaintext - else filename_plaintext.puts para #unix plaintext + if para.class == Array and para.length > 0 + para.each do |line| + line.gsub!(/\s+$/m,'') + filename_plaintext.puts line #unix plaintext end - else filename_plaintext.puts para # if para =~/^\s/ + else filename_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ end end end diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 93e77db7..3c0e9ce1 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -50,6 +50,7 @@ module SiSU_Format_Shared require "#{SiSU_lib}/defaults" include SiSU_Viz class CSS_Format + require "#{SiSU_lib}/defaults" def initialize(content=nil,id=nil,ocnd='',ocns='',lv='',hname=nil) content.gsub!(/<:i[12]>/,'') @content=content @@ -58,14 +59,78 @@ module SiSU_Format_Shared @lv=@notenumber=lv.to_s @hname=hname.to_s @tab="\t" + @url_brace=SiSU_Viz::Skin.new.url_decoration # lots introduced to do html tables in db @@tablehead,@@tablefoot=[],[] @vz=SiSU_Env::Get_init.instance.skin end + def urls(data) + @words=[] + data.each do |word| + @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ + if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/ + m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/.match(word).captures + else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures + d='' + end + case m + when /\.png|\.jpg|\.gif|c=|\d+x\d+/ + w,h=/(\d+)x(\d+)/.match(m).captures if m =~/\d+x\d+/ + w=%{width="#{w}"} if w + h=%{height="#{h}"} if h + c=m[/"(.+?)"/m,1] + caption=%{<br /><p class="caption">#{c}</p>} if c + png=m.scan(/\S+/)[0] + #image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external + #else @env.url.images_local + #end + ins=if u and u.strip !~/^image$/ + %{<a href="#{u}">[#{png}]</a>#{caption}} + else %{[#{png}] #{caption}} + end + word.gsub!(/\{.+?\}((?:https?|ftp)\S+|image)/,ins) + else + link=m[/(.+)/m] + png=m.scan(/\S+/)[0].strip + link=link.strip + ins=%{<a href="#{u}">#{link}</a>#{d}} + word.gsub!(/\{.+?\}(?:https?|ftp)\S+/,ins) + end + word + else word + end + word + end + @words + end + def markup(para) + if para =~/\{.+?\}((?:http|ftp)\S+|image)/ + @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) + word_mode=urls(para) + words=word_mode.join(' ') + para.gsub!(/.+/,words) + end + if (para !~/(\"\w+:\/\/\S+?\"|>\s*\w+:\/\/\w+?\S*<)/) #url markup http etc. + if para=~/\w+:\/\/\S+?\.\S+?[.,] / + para.gsub!(/(\w+:\/\/\S+?\.\S+?)([.,] )/,%{#{@url_brace.xml_open}<a href="\\1" target="_top">\\1</a>#{@url_brace.xml_close}\\2}) #full stops ! have been a bother + else + para.gsub!(/(\w+:\/\/\S+?\.\S+)/,%{#{@url_brace.xml_open}<a href="\\1" target="_top">\\1</a>#{@url_brace.xml_close}}) + end + end + if (para =~/[ ^](?:https?|ftp):\/\/\S+/) #url markup http leftovers watch carefully may accept too much 2004w46 + if para=~/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/ + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #full stops ! have been a bother + else + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+)/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}}) + end + end + para + end def paragraph %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive" header="#@hname">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} << "\n" end def endnote + @content=markup(@content) <<GSUB #{@tab*1}<p class="endnote" name="note_#@notenumber" from="#@ocn"> #{@tab*2}<a name="_#@notenumber" href="#-#@notenumber">#@notenumber.</a> <note>#@content</note> @@ -88,12 +153,15 @@ GSUB %{#{@tab*1}<p class="norm" id="none" type="comment">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} end def norm + @content=markup(@content) %{#{@tab*1}<p class="norm" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} end def indent1 + @content=markup(@content) %{#{@tab*1}<p class="indent1" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} end def indent2 + @content=markup(@content) %{#{@tab*1}<p class="indent2" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} end def para_table diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 6cb6f991..69b47d01 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -77,6 +77,12 @@ module SiSU_text_parts elsif /^([1-6]~)\s+(\S.+?)<~(0);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) @@alt_id_count+=1 @format,@text,@ocn=$1,$2,"x#{@@alt_id_count}" + elsif /^(?:<:i([1-9])>\s*_\*)\s+(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @format,@text,@ocn="_#{$1}\*",$2,$3,$4 + elsif /^(_\*)\s+(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @format,@text,@ocn=$1,$2,$3 + elsif /<:(i[1-9])>\s*(.+?)<~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @format,@text,@ocn=$1,$2,$3 end else if /(.+?)<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) @@ -135,10 +141,12 @@ module SiSU_text_parts end module SiSU_XML_munge class Trans + require "#{SiSU_lib}/defaults" def initialize(md) @sys=SiSU_Env::System_call.new @dir=SiSU_Env::Info_env.new(md.fns) @dp=SiSU_Env::Info_env.new.digest.pattern + @url_brace=SiSU_Viz::Skin.new.url_decoration end def char_enc #character encode def utf8(para='') @@ -336,12 +344,13 @@ module SiSU_XML_munge para.gsub!(/<:pb>\s*/,'') para.gsub!(/<+[-~]#>+/,'') para.gsub!(/<0;\w\d+;[um]\d+><#@dp:#@dp>/,'') - para.gsub!(/^(<:i[12]>\s*)_\*\s+/,'\1 <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_red.png" width="12" height="12" alt="*" /> ') - para.gsub!(/^_\*\s+/,'<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_red.png" width="12" height="12" alt="*" /> ') + #embeds a red-bullet image --> + #para.gsub!(/^(<:i[1-9]>\s*_\*)\s+/,'\1 <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_red.png" width="12" height="12" alt="*" /> ') + #para.gsub!(/^_\*\s+/,'<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_red.png" width="12" height="12" alt="*" /> ') para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\2" width="\\3" height="\\4" />[\\2] \\5}) para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\2"/>\\2}) para.gsub!(/(^|\s)\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/,'\1<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\3">\2</link>\4') - para.gsub!(/(^|\s)(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/,'\1<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\2</link>\3') + para.gsub!(/(^|\s)(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/,%{\\1#{@url_brace.xml_open}<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\\2">\\2</link>#{@url_brace.xml_close}\\3}) para.gsub!(/ /,' ') #clean para end @@ -363,9 +372,8 @@ module SiSU_XML_munge para end def markup_group(para='') - para.gsub!(/</,'<') - para.gsub!(/>/,'>') - para.gsub!(/<br(?:\s+\/)?>/,'<br />') + para.gsub!(/</,'<'); para.gsub!(/>/,'>') + para.gsub!(/<:?br(?:\s+\/)?>/,'<br />') para end end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 7440289d..aec45b58 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -472,8 +472,7 @@ WOK when /^4#{@@tilde}/; mono.level4 when /^5#{@@tilde}/; mono.level5 when /^6#{@@tilde}/; mono.level6 - when /^<:i1>/; mono.indent1 - when /^<:i2>/; mono.indent2 + when /^<:i([1-9])>/; mono.indent($1) when /<:=/; mono.symbol_graphic #watch when /^\s*<:image\s+/; mono.image when /\}image/; mono.png diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index ea418dd2..b981ca15 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -250,6 +250,7 @@ WOK end class Format_text_object require 'iconv' + require "#{SiSU_lib}/defaults" attr_accessor :string,:string1,:string,:orientation,:url,:dir,:tex @@sys=SiSU_Env::System_call.new @@tex_backslash="\\\\" @@ -268,6 +269,7 @@ WOK @start_table='' @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern @tx=SiSU_Env::Get_init.instance.tex + @url_brace=SiSU_Viz::Skin.new.url_decoration end def longtable_landscape @end_table='\end{longtable}' @@ -493,7 +495,7 @@ WOK @string.gsub!(/[^\}>]((?:https?|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{ \1 } \end{scriptsize}\2') else # regular urls !! http:// href if @string=~/(?:https?|ftp):\/\/\S+?[,.]? / - @string.gsub!(/(?:^|[^\}>])((?:https?|ftp):\/\/\S+?)([,.])? /,' \begin{scriptsize}\href{\1}{ \1}\end{scriptsize}\2 ') + @string.gsub!(/(?:^|[^\}>])((?:https?|ftp):\/\/\S+?)([,.])? /," #{@url_brace.tex_open}\\begin{scriptsize}\\href{\\1}{ \\1}\\end{scriptsize}#{@url_brace.tex_close}\\2 ") #tamper else @string.gsub!(/(?:^|[^\}>])((?:https?|ftp):\/\/\S+)/,' \begin{scriptsize}\href{ \1 }{\1} \end{scriptsize}') #should not be necessary, not checked end end @@ -526,7 +528,7 @@ WOK @string.gsub!(/\s+'/,' `') # open ' @string.gsub!(/^([1-6-]#{@@tilde}\S*|<.+?>)?\s*'/,'\1`') # open ' end - @string.gsub!(/^(<:i[12]>)?\s*\\_\*\s*/,'\\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ + @string.gsub!(/^(<:i[1-9]>)?\s*\\_\*\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ @string.gsub!(/(<font.*?>|<\/font>)/,'') @string.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') @string.gsub!(/(<sup>|<\/sup>)/,'') @@ -692,17 +694,11 @@ WOK @string.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') #end BUGWATCH end - def indent1 - @string.gsub!(/<:i1>(.*)/m, - '\begin{ParagraphIndent}{0.01\columnwidth} \1 -\end{ParagraphIndent} -') - end - def indent2 - @string.gsub!(/<:i2>(.*)/m, - '\begin{ParagraphIndent}{0.02\columnwidth} \1 -\end{ParagraphIndent} -') + def indent(lev) + @string.gsub!(/<:i#{lev}>(.*)/m, + "\\begin{ParagraphIndent}{0.0#{lev}\\columnwidth} \\1 +\\end{ParagraphIndent} +") end def symbol_graphic dir=SiSU_Env::Info_env.new(@md.fns) diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 44293919..8d9e2764 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -120,7 +120,7 @@ module SiSU_XHTML end def songsheet pre - markup + @data=markup(@data) post publish end @@ -269,8 +269,7 @@ WOK @@xml[:body] << "#{@tab*0}</object>" << "\n" #if para[@regx] @endnotes=[] end - def markup - data=@data + def markup(data) @endnotes=[] @rcdc=false @level,@cont,@copen,@xml_contents_close=[],[],[],[] @@ -331,12 +330,13 @@ WOK table=SiSU_Tables::Table_xml.new(para,ocn) para=table.table_split table_structure(para,ocn) - elsif para =~ /<:i1>/ - xml_structure(para,nil,nil,nil,'indent1') - elsif para =~ /<:i2>/ - xml_structure(para,nil,nil,nil,'indent2') - else - xml_structure(para,nil,nil,nil) + elsif para =~ /^\s*(?:<:i([1-9])> )?_\*/ + m=$1 + para.gsub!(/^(\s*(?:<:i[1-9]> )?)_\*/,'\1') + xml_structure(para,nil,nil,nil,"indent_bullet#{m}") + elsif para =~ /<:i([1-9])>/ + xml_structure(para,nil,nil,nil,"indent#{$1}") + else xml_structure(para,nil,nil,nil) end #@@xml[:body] << "#{@tab*6}<object>" << "\n" if para[@regx] #@@xml[:body] << "#{@tab*7}<ocn>#{para[@regx,3]}</ocn>" << "\n" if para[@regx,3] @@ -358,12 +358,7 @@ WOK end para='' if (para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote para=case para - when /<:i1>/ - if para =~/.*<:#>.*$/ - format_text=Format_text_object.new(para,'') - format_text.scr_inden_ocn_e_no_paranum - end - when /<:i2>/ + when /<:i[1-9]>/ if para =~/.*<:#>.*$/ format_text=Format_text_object.new(para,'') format_text.scr_inden_ocn_e_no_paranum @@ -419,7 +414,6 @@ WOK end def publish content=[] - data=@data content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 20c5f80e..7edbb8ea 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -120,7 +120,7 @@ module SiSU_XML_SAX end def songsheet pre - markup + @data=markup(@data) post publish end @@ -293,8 +293,7 @@ WOK @@xml[:body] << "#{@tab*0}</object>" << "\n" #if para[@regx] @endnotes=[] end - def markup - data=@data + def markup(data) xml_sc(@md) @endnotes,@level,@cont,@copen,@xml_contents_close=[],[],[],[],[] @rcdc=false @@ -355,10 +354,12 @@ WOK table=SiSU_Tables::Table_xml.new(para,ocn) para=table.table_split table_structure(para) - elsif para =~ /<:i1>/ - xml_structure(para,nil,nil,nil,'indent1') - elsif para =~ /<:i2>/ - xml_structure(para,nil,nil,nil,'indent2') + elsif para =~ /^\s*(?:<:i([1-9])> )?_\*/ #uncomment + m=$1 + para.gsub!(/^(\s*(?:<:i[1-9]> )?)_\*/,'\1') + xml_structure(para,nil,nil,nil,"indent_bullet#{m}") + elsif para =~ /<:i([1-9])>/ + xml_structure(para,nil,nil,nil,"indent#{$1}") else xml_structure(para,nil,nil,nil) end #@@xml[:body] << "#{@tab*6}<object>" << "\n" if para[@regx] @@ -381,11 +382,7 @@ WOK end para='' if para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote if para =~/.*<:#>.*$/ - para=case para - when /<:i1>/ - format_text=Format_text_object.new(para,'') - format_text.scr_inden_ocn_e_no_paranum - when /<:i2>/ + para=if para =~ /<:i[1-9]>/ format_text=Format_text_object.new(para,'') format_text.scr_inden_ocn_e_no_paranum end @@ -438,7 +435,6 @@ WOK end def publish content=[] - data=@data content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index 9c13dcc1..4225a276 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -118,7 +118,7 @@ module SiSU_XML_DOM end def songsheet pre - markup + @data=markup(@data) post publish end @@ -225,13 +225,13 @@ WOK @cont[2]=false if @cont[2] @cont[3]=false if @cont[3] ####### attempt to close contents - if @copen[3] # 6{ + if @copen[3] # 6~ [3,2,1].each { |v| @@xml[:body] << "#{@tab*n}</contents#{v}>\n" } @copen[1]=@copen[2]=@copen[3]=false - elsif @copen[2] # 5{ + elsif @copen[2] # 5~ [2,1].each { |v| @@xml[:body] << "#{@tab*n}</contents#{v}>\n" } @copen[1]=@copen[2]=@copen[3]=false - elsif @copen[1] # 4{ + elsif @copen[1] # 4~ [1].each { |v| @@xml[:body] << "#{@tab*n}</contents#{v}>\n" } @copen[1]=@copen[2]=@copen[3]=false end @@ -318,8 +318,7 @@ WOK @@xml[:body] << "#{@tab*0}</object>" << "\n" #if para[@regx] @endnotes=[] end - def markup - data=@data + def markup(data) xml_sc(@md) @rcdc=false @level,@cont,@copen,@xml_contents_close=[],[],[],[] @@ -388,9 +387,12 @@ WOK @@xml[:body] << table_structure(para,ocn) else #xml_structure(para, nil, nil, nil) type=case para - when /^\s*<:i1>/; 'indent1' - when /^\s*<:i2>/; 'indent2' - else 'norm' + when /^\s*(?:<:i([1-9])> )?_\*/ + m=$1 + para.gsub!(/^(\s*(?:<:i[1-9]> )?)_\*/,'\1') + "indent_bullet#{m}" + when /^\s*<:i([1-9])>/; "indent#{$1}" + else 'norm' end xml_markup(para) @@xml[:body] << %{#{@tab*6}<object id="#{para[@regx,3]}">} << "\n" if para[@regx] and para[@regx,3] @@ -417,10 +419,7 @@ WOK para='' if para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote if para =~/.*<:#>.*$/ para=case para - when /<:i1>/ - format_text=Format_text_object.new(para,'') - format_text.scr_inden_ocn_e_no_paranum - when /<:i2>/ + when /<:i[1-9]>/ format_text=Format_text_object.new(para,'') format_text.scr_inden_ocn_e_no_paranum end @@ -481,7 +480,6 @@ WOK end def publish content=[] - data=@data content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] |