From 8fe365726f3bb7866a7a9285cb5045c50c39fd67 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 31 Jan 2013 18:36:08 -0500 Subject: v4: epub, constants, debug alternative for various readers ... work on --- data/doc/sisu/CHANGELOG_v4 | 2 + lib/sisu/v4/constants.rb | 14 ++++ lib/sisu/v4/dal_idx.rb | 11 +--- lib/sisu/v4/epub.rb | 32 +++++----- lib/sisu/v4/epub_concordance.rb | 10 +-- lib/sisu/v4/epub_format.rb | 137 ++++++++++++++++++++-------------------- lib/sisu/v4/epub_segments.rb | 6 +- lib/sisu/v4/epub_tune.rb | 10 +-- 8 files changed, 115 insertions(+), 107 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index 759c1bdc..55acb451 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -30,6 +30,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.4.orig.tar.xz * v4: dal, on ocn excluded paragraphs (~# -#), hang/indent bullet, fix [bug reported indirectly by Cory Doctorow (discovered in work with markup)] +* v4: epub, constants, debug alternative for various readers ... work on + %% 4.0.3.orig.tar.xz (2013-01-27:03/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_4.0.3 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_4.0.3-1 diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index 08279630..65b17796 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -198,10 +198,24 @@ Px={ } Px[:lng_lst_rgx]=Px[:lng_lst].join('|') Ep={ + alt: :on, d_oebps: 'OEBPS', + d_image: 'OEBPS/image', + d_css: 'OEBPS/css', f_ncx: 'toc.ncx', f_opf: 'content.opf', } +$ep=if Ep[:alt]==:on + { + o: 'opf:', + hsp: ' ', + } +else + { + o: '', + hsp: ' ', + } +end Db={ name_prefix: "SiSU#{SiSU_version_dir}a_", name_prefix_db: "sisu_#{SiSU_version_dir}a_", diff --git a/lib/sisu/v4/dal_idx.rb b/lib/sisu/v4/dal_idx.rb index 63eb487e..a1d66402 100644 --- a/lib/sisu/v4/dal_idx.rb +++ b/lib/sisu/v4/dal_idx.rb @@ -161,12 +161,7 @@ module SiSU_DAL_BookIndex the_idx end def clean_xml(str) - str=str.gsub(/&/,'&'). - gsub(/\(/,'('). - gsub(/\)/,')'). - gsub(/\*/,'*'). - gsub(/\+/,'+'). - gsub(/,/,',') + str=str.gsub(/&/,'&') str end def index(the_idx) @@ -193,8 +188,8 @@ module SiSU_DAL_BookIndex idx[:html] << '' idx[:xhtml] << '' else - idx[:html] << %{#{x}, } - idx[:xhtml] << %{#{x}, } + idx[:html] << %{#{x},#{$ep[:hsp]}} + idx[:xhtml] << %{#{x},#{$ep[:hsp]}} end end idx[:html] << '

' diff --git a/lib/sisu/v4/epub.rb b/lib/sisu/v4/epub.rb index 195f719e..a3b9211e 100644 --- a/lib/sisu/v4/epub.rb +++ b/lib/sisu/v4/epub.rb @@ -549,7 +549,7 @@ module SiSU_EPUB segtoc << format_txt_obj.center_bold if defined? @md.creator.author \ and @md.creator.author - creator_endnote=@md.creator.author.gsub(/(\*+)/,%{ \\1}) + creator_endnote=@md.creator.author.gsub(/(\*+)/,%{#{$ep[:hsp]}\\1}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } format_txt_obj=SiSU_EPUB_Format::FormatTextObject.new(@md,txt_obj) @@ -708,21 +708,21 @@ module SiSU_EPUB - - Cover - - - - - -
-
- - - -
-
- + + Cover + + + + + +
+
+ + + +
+
+ WOK filename_xhtml.puts cover_image,"\n" diff --git a/lib/sisu/v4/epub_concordance.rb b/lib/sisu/v4/epub_concordance.rb index 93774d30..60242567 100644 --- a/lib/sisu/v4/epub_concordance.rb +++ b/lib/sisu/v4/epub_concordance.rb @@ -102,9 +102,9 @@ module SiSU_EPUB_Concordance @vz=SiSU_Viz::Defaults.new txt_path=%{#{@md.dir_out}} @fnb=@md.fnb - @lex_button=%{SiSU home -->} + @lex_button=%{SiSU home} @doc_details =< 

#{@md.title.full}

#{@md.creator.author}

+
#{$ep[:hsp]}

#{@md.title.full}

#{@md.creator.author}

WOK end def create @@ -122,7 +122,7 @@ WOK [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.]

- (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ] + (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [#{$ep[:hsp]}http://[web host]/#{@fnb}/concordance.html#your_word#{$ep[:hsp]}]

WOK end @@ -284,12 +284,12 @@ WOK end end end - scr='Full Text scroll: doc#  ' + scr=%{Full Text#{$ep[:hsp]}scroll:#{$ep[:hsp]}doc##{$ep[:hsp]} } seg='' @file_concordance << SiSU_EPUB_Concordance::Source::DocTitle.new(@particulars).create alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @file_concordance << '

' - alph.each {|x| @file_concordance << %{#{x}, }} + alph.each {|x| @file_concordance << %{#{x},#{$ep[:hsp]}}} @file_concordance << '

' letter=alph.shift @file_concordance << %{\n

A

} diff --git a/lib/sisu/v4/epub_format.rb b/lib/sisu/v4/epub_format.rb index dd3273d0..d8baae63 100644 --- a/lib/sisu/v4/epub_format.rb +++ b/lib/sisu/v4/epub_format.rb @@ -69,7 +69,7 @@ module SiSU_EPUB_Format ocn_class='ocn' if @ocn.to_i==0 @ocn.gsub(/^(\d+|)$/, - %{}) + %{}) else @ocn.gsub(/^(\d+|)$/, %{}) @@ -77,7 +77,7 @@ module SiSU_EPUB_Format else ocn_class='ocn_off' @ocn.gsub(/^(\d+|)$/, - %{}) + %{}) end end def name @@ -1220,6 +1220,7 @@ module SiSU_EPUB_Format module SanitizeXML def self.xml(x) if x.is_a?(String) + x=x.gsub(/ /,' ') if Ep[:alt]==:on x.gsub(/&/,'&'). gsub(//,'>'). #gsub(//,'>'). @@ -1246,8 +1247,6 @@ module SiSU_EPUB_Format def doc_type_xhtml <<-WOK - WOK end @@ -1305,25 +1304,25 @@ application/epub+zip segfilename=dir_epub_cont + '/' + name output_epub_cont_seg=File.new(segfilename,'w') output_epub_cont_seg << %{#{doc_type} - - - #{dob.obj} - - #{@md.html_title} - - -#{@css.xhtml_epub} - -#{@vz.color_body} -
-
- -

- #{dob.obj} -

-
-
- -} + + + #{dob.obj} - + #{@md.html_title} + + + #{@css.xhtml_epub} + + #{@vz.color_body} +
+
+ +

+ #{dob.obj} +

+
+
+ + } output_epub_cont_seg.close end def toc_ncx #list of navigation points (like chapters), table of contents, listing each navigation point (chapters and such) under the navigation map @@ -1341,9 +1340,7 @@ output_epub_cont_seg.close end def open <<-WOK - - + WOK end @@ -1404,12 +1401,12 @@ output_epub_cont_seg.close ? '' : "-#{no}" <<-WOK - - - Table of Contents - - - + + + Table of Contents + + + WOK end def navpoint(dob,no,fn_base,hashtag=nil) @@ -1419,16 +1416,16 @@ output_epub_cont_seg.close ? '' : "-#{no}" <<-WOK - - - #{dob.obj} - - + + + #{dob.obj} + + WOK end def navpoint_close <<-WOK - + WOK end def navmap_close @@ -1454,7 +1451,7 @@ output_epub_cont_seg.close def package_open <<-WOK - + WOK end def package_close @@ -1466,7 +1463,7 @@ output_epub_cont_seg.close cover_image=if defined? @md.make.cover_image \ and @md.make.cover_image.is_a?(Hash) \ and @md.make.cover_image[:cover] =~/\S+/ - %{\n } + %{\n <#{$ep[:o]}meta name="cover" content="cover_image" />} else '' end author=if defined? @md.creator.author \ @@ -1577,7 +1574,7 @@ output_epub_cont_seg.close end f=SiSU_Env::FileOp.new(@md) <<-WOK - #{@md.title.full} @@ -1585,7 +1582,7 @@ output_epub_cont_seg.close #{f.output_path.epub.url}/#{f.base_filename.epub} urn:uuid:#{@md.dgst[1]} - + WOK end def manifest_open @@ -1608,7 +1605,7 @@ output_epub_cont_seg.close and @md.make.cover_image.is_a?(Hash) \ and md.make.cover_image[:cover] =~/\S+/ <<-WOK - + WOK else '' end @@ -1646,7 +1643,7 @@ output_epub_cont_seg.close end def spine_cover_image <<-WOK - + WOK end def spine_sisu_toc @@ -1674,7 +1671,7 @@ output_epub_cont_seg.close end def guide_cover_image <<-WOK - + WOK end def guide_sisu_toc @@ -1727,20 +1724,20 @@ output_epub_cont_seg.close end def head %{#{doc_type} - - -#{@css.xhtml_epub} - -#{@vz.color_body}} + + + #{@css.xhtml_epub} + + #{@vz.color_body}} end def concordance if @md.concord_make %{#{@vz.margin_css} -

- - Concordance - -

+

+ + Concordance + +

#{@vz.table_close}} else %{#{@vz.margin_css} @@ -1807,15 +1804,15 @@ output_epub_cont_seg.close end def head %{#{doc_type} - - - #{@seg_name_xhtml[@seg_name_xhtml_tracker]} - - #{@md.html_title} - - -#{@css.xhtml_epub} - -#{@vz.color_body}} + + + #{@seg_name_xhtml[@seg_name_xhtml_tracker]} - + #{@md.html_title} + + + #{@css.xhtml_epub} + + #{@vz.color_body}} end def endnote_mark %{ @@ -1833,7 +1830,7 @@ output_epub_cont_seg.close Owner Details -     + #{$ep[:hsp]*3} @@ -1914,7 +1911,7 @@ output_epub_cont_seg.close def no_paranum %{
- +

#{@txt}

@@ -2059,7 +2056,7 @@ output_epub_cont_seg.close #{@txt}

#{@vz.margin_num_css} -     + #{$ep[:hsp]*3} #{@vz.table_close}} end def bold_heading #unused @@ -2069,7 +2066,7 @@ output_epub_cont_seg.close #{@txt}

#{@vz.margin_num_css} -     + #{$ep[:hsp]*3} #{@vz.table_close}} end def toc_head_copy_at @@ -2123,8 +2120,8 @@ output_epub_cont_seg.close note=$1 note=note.gsub(/[\n\s]+/m,' ') txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). - gsub(/ \d+<\/sup> /m,''). - gsub(/#{Mx[:nbsp]}\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove + gsub(/#{$ep[:hsp]}\d+<\/sup>#{$ep[:hsp]}/m,''). + gsub(/#{$ep[:hsp]}\d+<\/sup>#{$ep[:hsp]}/m,'') #remove end %{<#{tag} class="#{attrib}"> #{txt} #{note} diff --git a/lib/sisu/v4/epub_segments.rb b/lib/sisu/v4/epub_segments.rb index e2727232..007e4672 100644 --- a/lib/sisu/v4/epub_segments.rb +++ b/lib/sisu/v4/epub_segments.rb @@ -305,7 +305,7 @@ WOK txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') - @@heading1=@@heading1.gsub(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading1=@@heading1.gsub(/#{$ep[:hsp]}#{$ep[:hsp]}[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') end if @@is2==1 heading2=@@heading2 @@ -316,7 +316,7 @@ WOK txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') - @@heading2=@@heading2.gsub(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading2=@@heading2.gsub(/#{$ep[:hsp]}#{$ep[:hsp]}[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') end if @@is3==1 heading3=@@heading3 @@ -327,7 +327,7 @@ WOK txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') - @@heading3=@@heading3.gsub(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading3=@@heading3.gsub(/#{$ep[:hsp]}#{$ep[:hsp]}[\d*+]+<\/sup>#{$ep[:hsp]}<\/a>/,'') end if @@is4==1 heading4=@@heading4 diff --git a/lib/sisu/v4/epub_tune.rb b/lib/sisu/v4/epub_tune.rb index b64fd675..f34db8ff 100644 --- a/lib/sisu/v4/epub_tune.rb +++ b/lib/sisu/v4/epub_tune.rb @@ -103,7 +103,7 @@ module SiSU_EPUB_Tune str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). gsub(/
/u,'
'). - gsub(/#{Mx[:nbsp]}/u,' ') + gsub(/#{Mx[:nbsp]}/u,$ep[:hsp]) end end class Tune @@ -151,8 +151,8 @@ module SiSU_EPUB_Tune gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). 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,'●  '). - gsub(/#{Mx[:nbsp]}/,' '). + gsub(/#{Mx[:gl_bullet]}/m,"●#{$ep[:hsp]*2}"). + gsub(/#{Mx[:nbsp]}/,$ep[:hsp]). gsub(/<(p|br)>/,'<\1 />') dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean @tuned_file << dob @@ -253,9 +253,9 @@ module SiSU_EPUB_Tune %{\n
\\3
\n}) end dob.obj=dob.obj.gsub(/!pick/,%{stellar}). - gsub(/!new/,%{ new}). + gsub(/!new/,%{#{$ep[:hsp]}new}). gsub(/<:h(.{1,7}?)>/,'\1'). - gsub(/<:to(\d{1,7}?)>/,'to { \1 } '). + gsub(/<:to(\d{1,7}?)>/,%{to#{$ep[:hsp]}\{#{$ep[:hsp]}\\1#{$ep[:hsp]}\} }). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). #http ftp matches escaped, no decoration gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration -- cgit v1.2.3