aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/odf.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2007-06-14 10:16:51 +0100
committerRalph Amissah <ralph.amissah@gmail.com>2007-06-14 10:16:51 +0100
commit4c11eebf5ea1ce4abaeb8dc555ec1bf2cb27947e (patch)
treef85706d4725d429e61c12320a13c71a5033a300e /lib/sisu/v0/odf.rb
parent0.53.0, pre-build, see changelog, library naming changed for scm, placed unde... (diff)
sisu-0.54.0 (minor additions to syntax, indent range extended)sisu_0.54.0
* 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
Diffstat (limited to 'lib/sisu/v0/odf.rb')
-rw-r--r--lib/sisu/v0/odf.rb81
1 files changed, 41 insertions, 40 deletions
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} +