aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-02-20 19:18:56 -0500
committerRalph Amissah <ralph@amissah.com>2013-02-20 22:19:09 -0500
commit9b67ec9247d8322ede2bb47405862fd0ce6de375 (patch)
tree15b1c37ace164124f8b829d8e3c33abb8595c69a
parentb_epub.png, epub icon (for manifest) updated to use official image (diff)
v4 (v3): epub, tinkering with headers & cleaning of angle brackets '<' & '>'
-rw-r--r--data/doc/sisu/CHANGELOG_v32
-rw-r--r--data/doc/sisu/CHANGELOG_v44
-rw-r--r--lib/sisu/v3/epub_tune.rb8
-rw-r--r--lib/sisu/v4/epub_format.rb22
-rw-r--r--lib/sisu/v4/epub_tune.rb9
5 files changed, 29 insertions, 16 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3
index d121b9e0..0b82f9d6 100644
--- a/data/doc/sisu/CHANGELOG_v3
+++ b/data/doc/sisu/CHANGELOG_v3
@@ -37,6 +37,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.11.orig.tar.xz
sisu_3.3.11.orig.tar.xz
sisu_3.3.11-1.dsc
+* v3: epub, add markup of angle brackets '<' & '>' to early markup of amp. '&'
+
* v3: vim, colorschemes, general housekeeping
* b_epub.png, epub icon (for manifest) updated to use official image
diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4
index cd39d51c..308d66c6 100644
--- a/data/doc/sisu/CHANGELOG_v4
+++ b/data/doc/sisu/CHANGELOG_v4
@@ -28,6 +28,10 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.8.orig.tar.xz
sisu_4.0.8.orig.tar.xz
sisu_4.0.8-1.dsc
+* v4: epub
+ * tinkering with some headers
+ * add markup of angle brackets '<' & '>' to early markup of ampersand '&'
+
* v4: vim, ftplugin & colorschemes housekeeping, scheme "def*" added
* general housekeeping
* :colorscheme def256* defined from 256 colors (primarily 16 of them) terminal
diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb
index a6b23a0d..664f143e 100644
--- a/lib/sisu/v3/epub_tune.rb
+++ b/lib/sisu/v3/epub_tune.rb
@@ -123,7 +123,7 @@ module SiSU_EPUB_Tune
begin
@cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX
SiSU_Screen::Ansi.new(@md.opt.cmd,'Tune').txt_grey if @md.opt.cmd =~/[MVv]/
- data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_html
+ data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_angle_brackets
data=SiSU_EPUB_Tune::Tune.new(data,@md).endnotes_html
data=SiSU_EPUB_Tune::Tune.new(data,@md).url_markup
data=SiSU_EPUB_Tune::Tune.new(data,@md).markup
@@ -274,10 +274,12 @@ module SiSU_EPUB_Tune
@tuned_file << dob
end
end
- def amp_html
+ def amp_angle_brackets
data,data_new=@data,[]
data.each do |dob|
- dob.obj=dob.obj.gsub(/&/u,'&amp;')
+ dob.obj=dob.obj.
+ gsub(/&/u,'&amp;').
+ gsub(/</u,'&lt;').gsub(/>/u,'&gt;')
data_new << dob
end
data_new
diff --git a/lib/sisu/v4/epub_format.rb b/lib/sisu/v4/epub_format.rb
index a56ea394..98f4d7e4 100644
--- a/lib/sisu/v4/epub_format.rb
+++ b/lib/sisu/v4/epub_format.rb
@@ -71,23 +71,21 @@ module SiSU_EPUB_Format
if make.build.ocn?
ocn_class='ocn'
if @ocn.to_i==0
- @ocn.gsub(/^(\d+|)$/,
- %{<label class="#{ocn_class}">#{$ep[:hsp]}</label>})
+ @ocn.gsub(/^(\d+|)$/,'')
else
@ocn.gsub(/^(\d+|)$/,
%{<label class="#{ocn_class}"><a href="#o\\1" class="lnk#{ocn_class}">\\1</a></label>})
end
else
ocn_class='ocn_off'
- @ocn.gsub(/^(\d+|)$/,
- %{<label class="#{ocn_class}">#{$ep[:hsp]}</label>})
+ @ocn.gsub(/^(\d+|)$/,'')
end
end
def name
%{<a name="#{@ocn}"></a>}
end
def id #w3c? "tidy" complains about numbers as identifiers ! annoying
- %{id="o#{@ocn}"}
+ (@ocn.empty?) ? '' : %{id="o#{@ocn}"}
end
def goto
%{<a href="##{@ocn}">}
@@ -1225,7 +1223,8 @@ module SiSU_EPUB_Format
if x.is_a?(String)
x=x.gsub(/&nbsp;/,' ') if Ep[:alt]==:on
x.gsub(/&/,'&amp;').
- gsub(/</,'&lt;').gsub(/>/,'&gt;').
+ gsub(/</,"&lt;").gsub(/>/,"&gt;").
+ gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_o_xml]).
#gsub(/</,'&#60;').gsub(/>/,'&#62;').
gsub(/\\\\/,'<br />').
gsub(/&lt;br(?: \/)?&gt;/,'<br />')
@@ -1243,9 +1242,8 @@ module SiSU_EPUB_Format
@css=SiSU_Env::CSS_Stylesheet.new(md)
@seg_name_xhtml=(SiSU_EPUB::Source::Seg.new.seg_name_xhtml || [])
@seg_name_xhtml_tracker=(SiSU_EPUB::Source::Seg.new.seg_name_xhtml_tracker || [])
- @index='index'
- @metalink='#metadata'
@tocband_scroll,@tocband_segtoc=nil,nil
+ @index,@metalink='index','#metadata'
end
def doc_type_xhtml
<<-WOK
@@ -1572,17 +1570,21 @@ output_epub_cont_seg.close
rights=if defined? @md.rights.all \
and @md.rights.all =~/\S+/
rights=SanitizeXML.xml(@md.rights.all)
+ rights=rights.gsub(/<br\s*\/?>/,' ')
%{\n <dc:rights>#{rights}</dc:rights>}
else ''
end
f=SiSU_Env::FileOp.new(@md)
<<-WOK
- <#{$ep[:o]}metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
+ <#{$ep[:o]}metadata
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:opf="http://www.idpf.org/2007/opf"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
unique-identifier="urn:uuid:#{@md.dgst[1]}" version="2.0">
<dc:title>#{@md.title.full}</dc:title>
#{cover_image}#{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights}
- <dc:identifier opf:scheme="URI">#{f.output_path.epub.url}/#{f.base_filename.epub}</dc:identifier>
+ <dc:identifier opf:scheme="URI">#{f.output_path.epub.url.gsub(/http:\/\//,'')}/#{f.base_filename.epub}</dc:identifier>
<dc:identifier id="bookid">urn:uuid:#{@md.dgst[1]}</dc:identifier>
<!-- <dc:identifier id="EPB-UUID">urn:uuid:#{@md.dgst[1]}</dc:identifier> -->
</#{$ep[:o]}metadata>
diff --git a/lib/sisu/v4/epub_tune.rb b/lib/sisu/v4/epub_tune.rb
index bce4aed7..fbb42bc4 100644
--- a/lib/sisu/v4/epub_tune.rb
+++ b/lib/sisu/v4/epub_tune.rb
@@ -123,7 +123,7 @@ module SiSU_EPUB_Tune
begin
@cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX
SiSU_Screen::Ansi.new(@md.opt.cmd,'Tune').txt_grey if @md.opt.cmd =~/[MVv]/
- data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_html
+ data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_angle_brackets
data=SiSU_EPUB_Tune::Tune.new(data,@md).endnotes_html
data=SiSU_EPUB_Tune::Tune.new(data,@md).url_markup
data=SiSU_EPUB_Tune::Tune.new(data,@md).markup
@@ -156,6 +156,7 @@ module SiSU_EPUB_Tune
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'').
gsub(/#{Mx[:gl_bullet]}/m,"●#{$ep[:hsp]*2}").
+ gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_o_xml]).
gsub(/#{Mx[:nbsp]}/,$ep[:hsp]).
gsub(/<(p|br)>/,'<\1 />')
dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean
@@ -274,10 +275,12 @@ module SiSU_EPUB_Tune
@tuned_file << dob
end
end
- def amp_html
+ def amp_angle_brackets
data,data_new=@data,[]
data.each do |dob|
- dob.obj=dob.obj.gsub(/&/u,'&amp;')
+ dob.obj=dob.obj.
+ gsub(/&/u,'&amp;').
+ gsub(/</u,'&lt;').gsub(/>/u,'&gt;')
data_new << dob
end
data_new