aboutsummaryrefslogtreecommitdiffhomepage
path: root/data/sisu/conf/convert/sisu_convert
diff options
context:
space:
mode:
Diffstat (limited to 'data/sisu/conf/convert/sisu_convert')
-rw-r--r--data/sisu/conf/convert/sisu_convert160
1 files changed, 80 insertions, 80 deletions
diff --git a/data/sisu/conf/convert/sisu_convert b/data/sisu/conf/convert/sisu_convert
index 148384ad..7be075fc 100644
--- a/data/sisu/conf/convert/sisu_convert
+++ b/data/sisu/conf/convert/sisu_convert
@@ -5,19 +5,19 @@
#
# Ralph Amissah mailto:ralph@amissah.com
#
-# * Name: SiSU information Structuring Universe
+# * Name: SiSU information Structuring Universe
# * Author: Ralph@Amissah.com
# * Description: document conversion tool, to sisu from other formats
# * arch-tag: document conversion tool to sisu markup
# * $Date: 2004/10/16 15:51:06 $
# * $Id: sisu_convert,v 1.37 2004/10/16 15:51:06 ralph Exp $
# * License: GPL 3 or later
-# * Notes: word conversion uses wvWare and wvSiSU.xml (a modified/stripped wvHtml.xml)
+# * Notes: word conversion uses wvWare and wvSiSU.xml (a modified/stripped wvHtml.xml)
# * http://wvware.sourceforge.net/
# * http://sourceforge.net/projects/wvware
-# * <url:sisu.lnk>|sisu.lnk|@|^|
+# * <url:sisu.lnk>|sisu.lnk|@|^|
# * <url:sisu>
-# * <url:zxy_param.rb>|zxy_param.rb|@|^|
+# * <url:zxy_param.rb>|zxy_param.rb|@|^|
module CONVERT
class MyOutput
def initialize(data, filename, instruct)
@@ -25,53 +25,53 @@ module CONVERT
@filename=filename
@instruct=instruct
end
- def headerBasic
+ def headerBasic
<<WOK
-@title:
+@title:
-@subtitle:
+@subtitle:
-@creator:
+@creator:
-@type:
+@type:
-@subject:
+@subject:
-@date:
+@date:
-@date.available:
+@date.available:
@publisher: SiSU
-@rights:
+@rights:
@level:
WOK
- end
- def headerDefault
+ end
+ def headerDefault
<<WOK
-@title:
+@title:
-@subtitle:
+@subtitle:
-@creator:
+@creator:
-@type:
+@type:
-@subject:
+@subject:
-@date:
+@date:
-@date.available:
+@date.available:
@publisher: SiSU
-@rights:
+@rights:
WOK
end
- def hardOutput
+ def hardOutput
pre = Array.new
case @instruct
when /default/
@@ -79,16 +79,16 @@ WOK
else
pre << headerBasic
end
- @filename_wv=File.new(%{,,#{@filename}.sst},'w+')
+ @filename_wv=File.new(%{,,#{@filename}.sst},'w+')
@filename_wv << pre
- @data.each do |x|
+ @data.each do |x|
y = x.split("\n")
y.each do |z| # cleaner output this way
z.strip!
@filename_wv.puts "#{z}\n\n" unless z =~/^$/
end
end
- end
+ end
end
class WareWord97
def initialize(data, filename, instruct)
@@ -96,28 +96,28 @@ WOK
@filename=filename
@instruct=instruct
end
- def songsheet
+ def songsheet
data=@data
- 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
+ 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
tuned_file=Array.new
endnote_no=1
data.each do |para|
- para.strip!
+ 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>/,'')
- tuned_file << para unless para == nil
- end
+ tuned_file << para unless para == nil
+ end
tuned_file
end
def markup_rules
@@ -125,7 +125,7 @@ WOK
tuned_file=Array.new
endnote_no=1
data.each do |para|
- para.strip!
+ 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
@@ -136,8 +136,8 @@ WOK
para.gsub!(/<u>(.+?)<\/u>/,'_{\1}_')
para.gsub!(/<b>(.+?)<\/b>/,'*{\1}*')
para.gsub!(/<i>(.+?)<\/i>/,'/{\1}/')
- tuned_file << para unless para == nil
- end
+ tuned_file << para unless para == nil
+ end
tuned_file
end
end
@@ -147,9 +147,9 @@ WOK
@filename=filename
@instruct=instruct
end
- def songsheet
+ def songsheet
data=@data
- print "Convert to SiSU file from #{@filename}.html << gvim ,,#{@filename}.sst >\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.join.split(/\n\n+/), @filename, @instruct).space_paragraphs
@@ -157,15 +157,15 @@ WOK
#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
- data=MyOutput.new(data.collect, @filename, @instruct).hardOutput
- end
+ data=MyOutput.new(data.collect, @filename, @instruct).hardOutput
+ end
def space_paragraphs
#data=@data.join.split(/\n/)
data=@data
#p data.length
tuned_file=Array.new
data.each do |para|
- para.strip!
+ para.strip!
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')
@@ -178,7 +178,7 @@ WOK
para.gsub!(/(<\/h[1-6]>)/i,'\1zZz')
para.gsub!(/ \s+/i,' ')
para.gsub!(/(?:\s*zZz\s*)+/i,'zZz') #
- tuned_file << para unless para == nil
+ tuned_file << para unless para == nil
end
tuned_file
end
@@ -187,7 +187,7 @@ 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].gsub!(/zZz/,'zZz_1 ') if x =~/.+?#{m}/mi
res << x[/#{m}(.+)/mi,1]
else
res << x #[/(.+)/mi,1]
@@ -214,7 +214,7 @@ WOK
# 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")
- tuned_file << para << "\n\n" unless para == nil
+ tuned_file << para << "\n\n" unless para == nil
end
tuned_file
end
@@ -308,33 +308,33 @@ WOK
para.gsub!(/^\s*(&nbsp;){4,5}/i,'_1 ')
para.gsub!(/&#9;/,' ') #check
## glyphs & tildes
- para.gsub!(/&iexcl;/, '¡') #'Inverted exclamation
+ para.gsub!(/&iexcl;/, '¡') #'Inverted exclamation
para.gsub!(/&cent;/, '¢') #'Cent sign ¢
para.gsub!(/&pound;/, '£') #'Pound sign £
- para.gsub!(/&curren;/, '¤') #'General currency sign
+ para.gsub!(/&curren;/, '¤') #'General currency sign
para.gsub!(/&yen;/, '¥') #'Yen sign ¥
- para.gsub!(/&brvbar;/, '¦') #'Broken vertical bar
+ para.gsub!(/&brvbar;/, '¦') #'Broken vertical bar
para.gsub!(/&sect;/, '§') #'Section sign §
- para.gsub!(/&uml;/, '¨') #'Umlaut
+ para.gsub!(/&uml;/, '¨') #'Umlaut
para.gsub!(/&copy;/, '©') #'Copyright ©
para.gsub!(/&ordf;/, 'ª') #'Feminine ordinal ª
para.gsub!(/&laquo;/, '«') #'Left angle quote «
- para.gsub!(/&not;/, '¬') #'Not sign
- para.gsub!(/&shy;/, '­') #'Soft hyphen
+ para.gsub!(/&not;/, '¬') #'Not sign
+ para.gsub!(/&shy;/, '­') #'Soft hyphen
para.gsub!(/&reg;/, '®') #'Registered trademark ®
- para.gsub!(/&macr;/, '¯') #'Macron accent
+ para.gsub!(/&macr;/, '¯') #'Macron accent
para.gsub!(/&deg;/, '°') #'Degree sign °
para.gsub!(/&plusmin;/,'±') #'Plus or minus ±
para.gsub!(/&sup2;/, '²') #'Superscript 2 ²
para.gsub!(/&sup3;/, '³') #'Superscript 3 ³
- para.gsub!(/&acute;/, '') #'Acute accent
+ para.gsub!(/&acute;/, '') #'Acute accent
para.gsub!(/&micro;/, 'µ') #'Micro sign (Greek mu) µ
para.gsub!(/&para;/, '¶') #'Paragraph sign ¶
- para.gsub!(/&middot;/, '·') #'Middle dot
- para.gsub!(/&cedil;/, '¸') #'Cedilla
+ para.gsub!(/&middot;/, '·') #'Middle dot
+ para.gsub!(/&cedil;/, '¸') #'Cedilla
para.gsub!(/&sup1;/, '¹') #'Superscript 1 ¹
para.gsub!(/&ordm;/, 'º') #'Masculine ordinal º
- para.gsub!(/&raquo;/, '»') #'Right angle quote
+ para.gsub!(/&raquo;/, '»') #'Right angle quote
para.gsub!(/&frac14;/, '¼') #'Fraction one quarter ¼
para.gsub!(/&frac12;/, '½') #'Fraction on half ½
para.gsub!(/&frac34;/, '¾') #'Fraction three quarters ¾
@@ -355,7 +355,7 @@ WOK
para.gsub!(/&Iacute;/, 'Í') #'Capital I, acute accent Í
para.gsub!(/&Icirc;/, 'Î') #'Capital I, circumflex accent Î
para.gsub!(/&Iuml;/, 'Ï') #'Capital I, umlaut Ï
- para.gsub!(/&ETH;/, 'Ð') #'Capital eth, Icelandic
+ para.gsub!(/&ETH;/, 'Ð') #'Capital eth, Icelandic
para.gsub!(/&Ntilde;/, 'Ñ') #'Capital N, tilde Ñ
para.gsub!(/&Ograve;/, 'Ò') #'Capital O, grave accent Ò
para.gsub!(/&Oacute;/, 'Ó') #'Capital O, acute accent Ó
@@ -408,8 +408,8 @@ WOK
para.gsub!(/\t+/,' ')
#para.gsub!(/ +/,' ')
#para.gsub!(/^(?:<(?:\/)?[bi]>)+$/i, '')
- tuned_file << para unless para == nil
- end
+ tuned_file << para unless para == nil
+ end
tuned_file
end
end
@@ -419,15 +419,15 @@ WOK
@filename=filename
@instruct=instruct
end
- def songsheet
+ def songsheet
data=@data
- print "Convert to SiSU file from #{@filename}.html << gvim ,,#{@filename}.sst >\n" #: <<#{@@html_title}>>
- data=Default.new(data.collect, @filename, @instruct).space_paragraphs
+ 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
- data=Default.new(data.collect, @filename, @instruct).markup_default
- data=MyOutput.new(data.collect, @filename, @instruct).hardOutput
- end
+ data=Default.new(data.collect, @filename, @instruct).markup_default
+ data=MyOutput.new(data.collect, @filename, @instruct).hardOutput
+ end
def markup_default
data=@data
tuned_file=Array.new
@@ -435,8 +435,8 @@ WOK
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 << para unless para == nil
+ end
tuned_file
end
end
@@ -463,7 +463,7 @@ def do_word(argv, instruct)
@argv.each do |filename|
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
+ CONVERT::WareWord97.new(file_array, filename, instruct).songsheet # metaverse created here
end
end
def do_html(argv, instruct)
@@ -476,7 +476,7 @@ def do_html(argv, instruct)
end
@argv.each do |filename|
file_array=IO.readlines("#{filename}.html","\n\r")
- CONVERT::Html.new(file_array,filename,instruct).songsheet # metaverse created here
+ CONVERT::Html.new(file_array,filename,instruct).songsheet # metaverse created here
end
end
def do_default(argv, instruct)
@@ -489,20 +489,20 @@ def do_default(argv, instruct)
end
@argv.each do |filename|
file_array=IO.readlines("#{filename}.html", "\n\r")
- CONVERT::Default.new(file_array, filename, instruct).songsheet # metaverse created here
+ CONVERT::Default.new(file_array, filename, instruct).songsheet # metaverse created here
end
end
def cases(argv, instruct)
- case instruct
- when/^--(word(97)?|doc)$/i #creates minimal sisu_small.gz package to send
+ case instruct
+ when/^--(word(97)?|doc)$/i #creates minimal sisu_small.gz package to send
do_word(argv, instruct)
- when/^--(html)$/i #creates sisu.gz package to send
+ when/^--(html)$/i #creates sisu.gz package to send
do_html(argv, instruct)
- when/^--(default)$/i #creates sisu.gz package to send
+ when/^--(default)$/i #creates sisu.gz package to send
do_default(argv, instruct)
- else
+ else
help
- end
+ end
end
$KCODE='u'
branch='v0'
@@ -515,5 +515,5 @@ argv=$*
instruct = "#{argv[0].to_s}"
argv.shift
instruct.chomp!
-instruct = "help" if instruct.nil? or instruct == "";
+instruct = "help" if instruct.nil? or instruct == "";
cases(argv, instruct)