aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu')
-rw-r--r--lib/sisu/v0/css.rb141
-rw-r--r--lib/sisu/v0/dal_syntax.rb37
-rw-r--r--lib/sisu/v0/db_import.rb3
-rw-r--r--lib/sisu/v0/defaults.rb21
-rw-r--r--lib/sisu/v0/html.rb6
-rw-r--r--lib/sisu/v0/html_format.rb38
-rw-r--r--lib/sisu/v0/html_scroll.rb172
-rw-r--r--lib/sisu/v0/html_segments.rb15
-rw-r--r--lib/sisu/v0/html_tune.rb98
-rw-r--r--lib/sisu/v0/odf.rb81
-rw-r--r--lib/sisu/v0/plaintext.rb44
-rw-r--r--lib/sisu/v0/shared_html_lite.rb68
-rw-r--r--lib/sisu/v0/shared_xml.rb20
-rw-r--r--lib/sisu/v0/texpdf.rb3
-rw-r--r--lib/sisu/v0/texpdf_format.rb22
-rw-r--r--lib/sisu/v0/xhtml.rb26
-rw-r--r--lib/sisu/v0/xml.rb22
-rw-r--r--lib/sisu/v0/xml_dom.rb26
18 files changed, 494 insertions, 349 deletions
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+|['"]|&nbsp;|\(|\>|\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
+ '&lt;'
+ end
+ def xml_close
+ '&gt;'
+ 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
&nbsp;&nbsp;&nbsp;
#{@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}
+ &nbsp;&nbsp;&nbsp;
+#{@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&nbsp;{&nbsp;\1&nbsp;}</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)/,'&lt;<a href="mailto:\1">\1</a>&gt;\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+?)([.,] )/,'&lt;<a href="\1" target="_top">\1</a>&gt;\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+)/, '&lt;<a href="\1" target="_top">\1</a>&gt;')
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&lt;<a href="\2" target="_top">\2</a>&gt;\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&lt;<a href="\2" target="_top">\2</a>&gt;')
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!(/&amp;nbsp;|&nbsp;/,'&#160;')
- para.gsub!(/</,'&lt;')
- para.gsub!(/>/,'&gt;')
- #para.gsub!(/<br(?:\s+\/)?>/,'<br />')
+ para.gsub!(/</,'&lt;'); para.gsub!(/>/,'&gt;')
para.gsub!(/&lt;br(?:\s+\/)?&gt;/,'<br />')
#para.gsub!(/\s\s/,'&#160;&#160;')
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/,'&#160;&#160;')
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!(/&#169;/,'©') #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!(/&#169;/,'©') # bullet markup, marked down
- para.gsub!(/&amp;/,'&') # bullet markup, marked down
+ para.gsub!(/&amp;/,'&') # 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!(/&nbsp;/,' ') # 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!(/&nbsp;/,' ') #clean
para
end
@@ -363,9 +372,8 @@ module SiSU_XML_munge
para
end
def markup_group(para='')
- para.gsub!(/</,'&lt;')
- para.gsub!(/>/,'&gt;')
- para.gsub!(/&lt;br(?:\s+\/)?&gt;/,'<br />')
+ para.gsub!(/</,'&lt;'); para.gsub!(/>/,'&gt;')
+ para.gsub!(/&lt;:?br(?:\s+\/)?&gt;/,'<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]