From 9b67ec9247d8322ede2bb47405862fd0ce6de375 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 20 Feb 2013 19:18:56 -0500 Subject: v4 (v3): epub, tinkering with headers & cleaning of angle brackets '<' & '>' --- data/doc/sisu/CHANGELOG_v3 | 2 ++ data/doc/sisu/CHANGELOG_v4 | 4 ++++ lib/sisu/v3/epub_tune.rb | 8 +++++--- lib/sisu/v4/epub_format.rb | 22 ++++++++++++---------- lib/sisu/v4/epub_tune.rb | 9 ++++++--- 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,'&') + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(//u,'>') 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+|)$/, - %{}) + @ocn.gsub(/^(\d+|)$/,'') else @ocn.gsub(/^(\d+|)$/, %{}) end else ocn_class='ocn_off' - @ocn.gsub(/^(\d+|)$/, - %{}) + @ocn.gsub(/^(\d+|)$/,'') end end def name %{} end def id #w3c? "tidy" complains about numbers as identifiers ! annoying - %{id="o#{@ocn}"} + (@ocn.empty?) ? '' : %{id="o#{@ocn}"} end def goto %{} @@ -1225,7 +1223,8 @@ module SiSU_EPUB_Format if x.is_a?(String) x=x.gsub(/ /,' ') if Ep[:alt]==:on x.gsub(/&/,'&'). - gsub(//,'>'). + gsub(//,">"). + gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_o_xml]). #gsub(//,'>'). gsub(/\\\\/,'
'). gsub(/<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(//,' ') %{\n #{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"> #{@md.title.full} #{cover_image}#{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights} - #{f.output_path.epub.url}/#{f.base_filename.epub} + #{f.output_path.epub.url.gsub(/http:\/\//,'')}/#{f.base_filename.epub} urn:uuid:#{@md.dgst[1]} 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]}/,'\1'). # 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,'&') + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(//u,'>') data_new << dob end data_new -- cgit v1.2.3