diff options
| author | Ralph Amissah <ralph@amissah.com> | 2008-09-16 00:36:14 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2008-09-16 00:36:14 -0400 | 
| commit | bc9228c42269bfb4d451ca2d2d92a6a12afb094f (patch) | |
| tree | 42b666a81ef350d0ff6153a49d159b3a1c348959 /lib | |
| parent | Updated sisu-0.68.0 (diff) | |
| parent | fixes: alphabet list (concordance, dal_idx), and file types (dal_expand_inser... (diff) | |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib')
59 files changed, 4575 insertions, 3558 deletions
| diff --git a/lib/sisu/v0/character_encoding.rb b/lib/sisu/v0/character_encoding.rb index 60c2f335..aa856cdd 100644 --- a/lib/sisu/v0/character_encoding.rb +++ b/lib/sisu/v0/character_encoding.rb @@ -374,7 +374,9 @@ module SiSU_character_encode    ['ü',  252, '374', '\303\274',     'ü', 'ü',    'ü',    '\"{u}',           '',                'Small u, umlaut         ü' ],    ['ý',  253, '375', '\303\275',     'ý', 'ý',  'ý',    '',                '',                'Small y, acute accent   ý' ],    ['þ',  254, '376', '\303\276',     'þ', 'þ',   'þ',    '',                '',                'Small thorn, Icelandic  þ' ], -  ['ÿ',  255, '377', '\303\277',     'ÿ', 'ÿ',    'ÿ',    '',                '',                'Smally y, umlaut        ÿ' ] +  ['ÿ',  255, '377', '\303\277',     'ÿ', 'ÿ',    'ÿ',    '',                '',                'Smally y, umlaut        ÿ' ], +  ['∝',     ,    '',         '',    '∝', '∝',    '∝',    '',                '',                'proportional to  U+221D (8733) ∝' ], +  ['∞',     ,    '',         '',    '∞', '∞',   '∞',    '',                '',                'infinity  U+221E (8734) ∞' ],  ]      end    end diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index f62b20ac..babc6655 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -66,8 +66,9 @@ module SiSU_Concordance    include SiSU_Env    require "#{SiSU_lib}/defaults"    include SiSU_Viz -  require "#{SiSU_lib}/html_format_css" +  require "#{SiSU_lib}/html_format"    include SiSU_HTML_Format +  require "#{SiSU_lib}/html_minitoc"    class Source      def initialize(opt)        @opt=opt @@ -105,22 +106,23 @@ module SiSU_Concordance        #revisit, both requires (html & shared_xml) needed for stand alone operation (sisu -w [filename])        require "#{SiSU_lib}/shared_xml"        require "#{SiSU_lib}/html" -      def initialize(lnk,env,md) -        @env,@md=env,md +      def initialize(particulars) +        @particulars,@md=particulars,particulars.md +        @data=SiSU_HTML::Source::Html_environment.new(particulars).tuned_file_instructions          @vz=SiSU_Env::Get_init.instance.skin -        file_array=@env.read_source_file(@md.fns)          txt_path=%{#{@md.dir_out}}          SiSU_Env::Info_skin.new(@md).select          @md_title=@md.title          @fnb=@md.fnb          @lex_button=%{<a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" height="44" width="144" valign="center" src="../_sisu/image/sisu.png" alt="SiSU home -->"></a>} -        @lnk=lnk          @doc_details =<<WOK  <table summary="links to text related to this rudimentary index" width="96%" border="0" bgcolor="white" cellpadding="0" align="center"><tr><td width="2%" align="right"> </td><td width="94%" valign="top" align="justify"><h1 class="small"><a href="#{@md.fn[:toc]}" #{@vz.js_toc}><b>#{@md.dc_title}</b></a></h1><p class="bold">#{@md.dc_creator}</p></td></tr></table>  WOK        end        def create -        head_banner=SiSU_HTML_Format_type::Head_toc.new(@md) +        head_banner=SiSU_HTML_Format::Head_toc.new(@md) +        minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet +        toc='<div class="toc">' + minitoc.to_s + '</div>'          <<WOK  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  <html> @@ -140,6 +142,8 @@ WOK  <body>    #{@vz.js_top}    #{head_banner.concordance_navigation_band('pdf')} +  #{toc} +<div class="content">   #@doc_details  <p>Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.<br />[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]</p>  <p>(The word listing/index is Case sensitive: Capitalized words appear before lower case)</p> @@ -148,7 +152,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.]    </p>    <p> -    (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 # [ http://[web host]/#{@fnb}/concordance.html#your_word ]    </p>  WOK        end @@ -171,12 +175,13 @@ WOK      class Words        require "#{SiSU_lib}/defaults"        include SiSU_Viz -      require "#{SiSU_lib}/html_format_css" +      require "#{SiSU_lib}/html_format"        include SiSU_HTML_Format        require "#{SiSU_lib}/sysenv"        include SiSU_Screen        @@dp=nil        def initialize(particulars) +        @particulars=particulars          begin            @vz=SiSU_Env::Get_init.instance.skin            @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array @@ -194,18 +199,19 @@ WOK            @rxp_t3=Regexp.new('^T3')            @rxp_excluded1=/(?:https?|file|ftp):\/\/\S+/            @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#@dp|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! -          @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|#{Mx[:id_o]}\S+?#{Mx[:id_c]}|\w+|[a-zA-Z]+}mi +          @rgx_splitlist=%r{[—.,;:-]|#{Mx[:id_o]}\S+?#{Mx[:id_c]}}mi +          @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|\w+|[a-zA-Z]+}mi          rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error          end        end        def songsheet          begin            mkdir_p(@path) unless FileTest.directory?(@path) -          @file_index_all=File.open("#@path/#{@md.fn[:concordance]}",'w') +          @file_concordance=File.open("#@path/#{@md.fn[:concordance]}",'w')            map_para          rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error          ensure -          @file_index_all.close +          @file_concordance.close          end        end      protected @@ -218,13 +224,13 @@ WOK          @sfx='.html' #used for hardlinks, previous setting @sfx='', web server takes care of suffix          @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}#\\2") unless wordlocation.nil?          case @wordlocation -          when @rxp_t1 -            %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show,  } -          when @rxp_t2 -            %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show,  } -          when @rxp_t3 -            %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show,  } -          else %{<a href="#@word_location_seg">#@show</a>,  } +        when @rxp_t1 +          %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show,  } +        when @rxp_t2 +          %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show,  } +        when @rxp_t3 +          %{[<a href="#{@md.fnl[:pre]}doc#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}##@show">H</a>]#@show,  } +        else %{<a href="#@word_location_seg">#@show</a>,  }          end        end        def map_para @@ -238,8 +244,10 @@ WOK              end              if toy =~/\d+/ \              and toy !~/^0$/ +              line=line.split(@rgx_splitlist).join(' ') #%take in word or other match                for word in line.scan(@rgx_scanlist) #%take in word or other match                  #word.gsub!(@rxp_clean,'') +                word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'')                  word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'')                  word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'')                  word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') @@ -274,7 +282,8 @@ WOK                    word.gsub!(/^\(?[a-zA-Z]\)$/,'')                    word.gsub!(/^\d+(st|nd|rd|th)$/,'')                    word.gsub!(/^(\d+\.?)+$/, '') -                  word.gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') +                  word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') +                  word.gsub!(/:name#\S+/,'')                    word.gsub!(/^\S$/,'')                    word=nil if word =~/^\S$/                    word=nil if word =~/^\s*$/ #watch @@ -306,20 +315,36 @@ WOK          end          scr='<font size="1" color="#777777" face=times new roman><img border="0" height="15" width="15" src="../_sisu/image/b_doc.png" alt="Full Text"> scroll: </font><font size="1" color="#222222" face=times new roman>doc# </font> '          seg='' -        @file_index_all << SiSU_Concordance::Source::Doc_title.new('toc',@env,@md).create +        @file_concordance << SiSU_Concordance::Source::Doc_title.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 << '<p>' +        alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>, }} +        @file_concordance << '</p>' +        letter=alph.shift +        @file_concordance << %{\n<hr />\n<p class="book_index_lev1"><a name="A">A</a></p>}          for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} +          f=/^(\S)/.match(word)[1] +          if letter < f.upcase +            while letter < f.upcase +              if alph.length > 0 +                letter=alph.shift +                @file_concordance << %{\n<hr />\n<p class="book_index_lev1"><a name="#{letter}">#{letter}</a></p>} +              else break +              end +            end +          end            keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html            if keyword !~ @rxp_excluded0              if @word_map[word][0] =~ /\d+/                wm=[] -              @file_index_all << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} +              @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}}              end -            @file_index_all << '</p>' +            @file_concordance << '</p>'            end            # special cases endnotes and header levels 1 - 3          end          credits=@vz.credits_sisu -        @file_index_all << "#{credits}</body>\n</html>" # footer +        @file_concordance << %{</div><div class="content">#{credits}<div></body>\n</html>} # footer          tell=SiSU_Screen::Ansi.new(@md.cmd,@md.fns,"#{@env.path.output_tell}/#{@md.fn[:concordance]}")          tell.flow if @md.cmd =~/[MV]/        end diff --git a/lib/sisu/v0/constants.rb b/lib/sisu/v0/constants.rb index 68093673..414732e1 100644 --- a/lib/sisu/v0/constants.rb +++ b/lib/sisu/v0/constants.rb @@ -90,6 +90,8 @@ Mx[:gl_bullet]=       "#{Mx[:gl_o]}●#{Mx[:gl_c]}"  #non substantive text sort: <-#> <~#>    Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph)    Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) +Mx[:idx_o]='▢ ';                                         Mx[:idx_c]='▢ ' # +Mx[:nbsp]=            '░' #'▭ '  Mx[:br_line]=         "#{Mx[:mk_o]}br#{Mx[:mk_c]}"  Mx[:br_paragraph]=    "#{Mx[:mk_o]}br#{Mx[:mk_c]}"  Mx[:br_nl]=           "#{Mx[:mk_o]}nl#{Mx[:mk_c]}" @@ -97,7 +99,8 @@ Mx[:br_page]=         "#{Mx[:mk_o]}pb#{Mx[:mk_c]}"  Mx[:br_page_new]=     "#{Mx[:mk_o]}pn#{Mx[:mk_c]}"  Mx[:br_endnotes]=     "#{Mx[:mk_o]}ENDNOTES#{Mx[:mk_c]}"  Mx[:br_eof]=          "#{Mx[:mk_o]}EOF#{Mx[:mk_c]}" -Mx[:lnk_o]='「'; Mx[:lnk_c]='」' +Mx[:lnk_o]='◁'; Mx[:lnk_c]='▷' + #‹ ›  Mx[:sm_set_o]='《'; Mx[:sm_set_c]='》'  Mx[:sm_subset_o]='《 '; Mx[:sm_subset_c]='》'  #Mx[:sm_set_o]='∈ '; Mx[:sm_set_c]='∋ ' @@ -166,4 +169,6 @@ check:   ‹ › ∗   '〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕'  '〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' +◁▷  +◀this is text or an image▶ http:// diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index cdd05528..ec71c4f3 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -106,7 +106,8 @@ WOK  /* SiSU css default stylesheet */    body {      color: black; -    background: #{@vz.color_white}; +    background: "#ffffff"; +    background-color: "#ffffff";    }  /*      table { @@ -121,25 +122,28 @@ WOK      }  */    a:link { -    color: #{@vz.color_blue_ink}; +    color: #003399;      text-decoration: none;    }    a:visited { -    color: #{@vz.color_blue_ink}; +    color: #003399;      text-decoration: none;    } +  a:hover { +    color: #000000; +    background-color: #f9f9aa; +  }  /*    a:hover { -    color: #{@vz.color_black};      border-bottom: 2px solid #777777; -    background-color: #{@vz.color_yellow_light}; +    background-color: #fff3b6;    }  */    a:hover img { -    background-color: #{@vz.color_white}; +    background-color: "#ffffff";    }    a:active { -    color: #{@vz.color_blue_ink}; +    color: #003399;      text-decoration: underline;    }    div { @@ -150,6 +154,7 @@ WOK      margin-left: 5%;      margin-right: 1%;    } +    #top_band {      position: absolute;      top: 0; @@ -197,55 +202,65 @@ WOK      margin-left: 75%;      width: 20%;    } -  p { + +  .norm, .bold { +    line-height: 150%; +    margin-left: 1em; +    margin-right: 2em; +    margin-top: 10px; +    margin-bottom: 0px; +    text-indent: 0mm; +  } +  p, h0, h1, h2, h3, h4, h5, h6 {      display: block; -    font-family: #{fonts}; +    font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman;      font-size: 100%;      font-weight: normal;      line-height: 150%; -    text-align: left; -    margin-left: 10mm; +    text-align: justify; +    margin-left: 1em; +    margin-right: 2em;      text-indent: 0mm;      margin-top: 3px;      margin-bottom: 3px; -    margin-right: 5mm; -  } -  p.norm { -    text-align: justify;    } +  p.norm { } +  p.i1 {margin-left: 2em;} +  p.i2 {margin-left: 3em;} +  p.i3 {margin-left: 4em;} +  p.i4 {margin-left: 5em;} +  p.i5 {margin-left: 6em;} +  p.i6 {margin-left: 7em;} +  p.i7 {margin-left: 8em;} +  p.i8 {margin-left: 9em;} +  p.i9 {margin-left: 10em;} +    p.code { -    font-family: monospace; +    font-family: inconsolata, andale mono, courier new, courier, monospace; +    font-size: 90%;      text-align: left;    } +    p.caption {      text-align: left;      font-size: 80%;      display: inline;    } +    p.endnote { -    font-family: #{fonts};      font-size: 96%; -    font-weight: normal;      line-height: 120%;      text-align: left; -    margin-left: 10mm; -    text-indent: 0mm; -    margin-top: 3px; -    margin-bottom: 3px;      margin-right: 15mm;    }    p.endnote_indent { -    font-family: #{fonts};      font-size: 96%; -    font-weight: normal;      line-height: 120%;      text-align: left; -    margin-left: 15mm; -    text-indent: 0mm; -    margin-top: 3px; -    margin-bottom: 3px; +    margin-left: 2em;      margin-right: 15mm;    } +    p.center {      text-align: center;    } @@ -261,23 +276,7 @@ WOK      font-style: normal;      background: #fff3b6;    } -  p.ocn, p.paranum { -    font-size: 10px; -    margin-top: 0px; -    margin-bottom: 5px; -    color: #777777; -    margin-right: 5px; -    text-align: right; -  } -  p.ocn_off, p.no_paranum { -    display: none; -    font-size: 10px; -    margin-top: 0px; -    margin-bottom: 5px; -    color: #777777; -    margin-right: 5px; -    text-align: right; -  } +    p.small {      font-size: 80%;      margin-top: 0px; @@ -285,7 +284,8 @@ WOK      margin-right: 6px;      text-align: left;    } -  p.tiny { + +  .tiny, .tiny_left, .tiny_right, .tiny_center {      font-size: 10px;      margin-top: 0px;      margin-bottom: 0px; @@ -293,33 +293,23 @@ WOK      margin-right: 6px;      text-align: left;    } +  p.tiny { }    p.tiny_left { -    font-size: 10px; -    margin-top: 0px; -    margin-bottom: 0px; -    color: #777777;      margin-left: 0px;      margin-right: 0px;      text-align: left;    }    p.tiny_right { -    font-size: 10px; -    margin-top: 0px; -    margin-bottom: 0px; -    color: #777777; -    margin-right: 5mm; +    margin-right: 1em;      text-align: right;    }    p.tiny_center { -    font-size: 10px; -    margin-top: 0px; -    margin-bottom: 0px; -    color: #777777;      margin-left: 0px;      margin-right: 0px;      text-align: center;    } -  p.pane { + +  p.pane, p.pane_title, p.pane_blurb, p.pane_link, p.pane_indent {      font-size: 80%;      margin-top: 0px;      margin-bottom: 0px; @@ -327,39 +317,26 @@ WOK      margin-right: 4px;      text-align: left;    } +  p.pane { }    p.pane_title {      font-weight: bold; -    font-size: 80%; -    margin-top: 0px;      margin-bottom: 0px; -    margin-left: 2mm; -    margin-right: 4px; -    text-align: left;    }    p.pane_blurb {      font-size: 10px; -    margin-top: 0px;      margin-bottom: 0px; -    margin-left: 2mm; -    margin-right: 4px; -    text-align: left;    }    p.pane_link {      font-size: 10px; -    margin-top: 0px;      margin-bottom: 0px;      margin-left: 4mm; -    margin-right: 4px; -    text-align: left;    }    p.pane_indent {      font-size: 10px; -    margin-top: 0px;      margin-bottom: 0px;      margin-left: 4mm; -    margin-right: 4px; -    text-align: left;    } +    p.concordance_word {      line-height: 150%;      font-weight: bold; @@ -371,20 +348,30 @@ WOK      font-size: 80%;      color: #777777;      display: inline; -    margin-left: 0mm; -    text-indent: 0mm; +    margin-left: 0em;    }    p.concordance_object {      font-size: 80%; -    font-weight: normal;      line-height: 120%;      text-align: left; -    margin-left: 15mm; -    text-indent: 0mm; +    margin-left: 3em; +    margin-top: 1px; +    margin-bottom: 3px; +  } +  p.book_index_lev1 { +    line-height: 100%; +    margin-top: 4px; +    margin-bottom: 1px; +  } +  p.book_index_lev2 { +    line-height: 100%; +    text-align: left; +    margin-left: 3em;      margin-top: 1px;      margin-bottom: 3px;    } -  p.quickref{ + +  p.quickref {      font-size: 10px;      font-style: italic;      margin-top: 0px; @@ -393,7 +380,7 @@ WOK      margin-right: 5px;      text-align: left;    } -  p.bigref{ +  p.bigref {      font-size: 11px;      font-weight: bold;      margin-top: 0px; @@ -402,19 +389,24 @@ WOK      margin-right: 5px;      text-align: center;    } -  p.i1 {margin-left: 15mm;} -  p.i2 {margin-left: 20mm;} -  p.i3 {margin-left: 25mm;} -  p.i4 {margin-left: 30mm;} -  p.i5 {margin-left: 35mm;} -  p.i6 {margin-left: 40mm;} -  p.i7 {margin-left: 45mm;} -  p.i8 {margin-left: 50mm;} -  p.i9 {margin-left: 55mm;} + +  label.ocn { +    width: 2%; +    float: right; +    top: 0; +    font-size: 10px; +    margin-top: 0px; +    margin-bottom: 5px; +    color: #777777; +    margin-right: 5px; +    text-align: right; +    background-color: #ffffff; +  }    table { }    tr { }    th, td { } +    p.left, th.left, td.left {      text-align: left;    } @@ -426,75 +418,6 @@ WOK      text-align: right;    } -  h0, h1, h2, h3, h4, h5, h6 { -    display: block; -    font-family: #{fonts}; -    font-weight: bold; -    line-height: 120%; -    margin-left: 10mm; -    margin-right: 10mm; -    text-align: left; -    margin-top: 20px; -    margin-bottom: 10px; -  } -  h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { -    text-align: center; -  } -  ul { -    list-style: none; -  } -  ul.horizontal { -    list-style: none; -  } -  ul.vertical { -    list-style: none; -  } -  li { -    background: url(../image/bullet_09.png) no-repeat 0px 6px; -    /* list-style-type: disc; */ -    padding-left: 20px; -    display: block; -    font-family: #{fonts}; -    /* font-size: 100%; */ -    font-weight: normal; -    line-height: 150%; -    text-align: left; -    margin-left: 10mm; -    text-indent: 0mm; -    margin-top: 3px; -    margin-bottom: 3px; -    margin-right: 0mm; -  } -  li.bullet { -    margin-left: 10mm; -  } -  li.i1 { -    margin-left: 15mm; -  } -  li.i2 { -    margin-left: 20mm; -  } -  li.i3 { -    margin-left: 25mm; -  } -  li.i4 { -    margin-left: 30mm; -  } -  li.i5 { -    margin-left: 35mm; -  } -  li.i6 { -    margin-left: 40mm; -  } -  li.i7 { -    margin-left: 45mm; -  } -  li.i8 { -    margin-left: 50mm; -  } -  li.i9 { -    margin-left: 55mm; -  }    #horizontal_links {      background: #eeeeee;      margin-left: 5%; @@ -515,8 +438,6 @@ WOK      background: none;    }    #horizontal a { -    /* font-weight: normal; */ -    /* float: left; */      line-height: 12px;      margin: 0 0 0 0;      text-decoration: none; @@ -525,20 +446,20 @@ WOK    #horizontal a.active, #horizontal a:hover {      border-bottom: 2px solid #777777;      padding-bottom: 2px; -    /* font-weight: bold; */      color: #000077;    }    #horizontal a:hover {      color: #000077;    } +    #document_versions {      position: absolute;      top: 10mm;      right: 2%;      width: 12%; -    /* background: #ffffff; */      float: right;    } +    #vertical_links {      position: absolute;      top: 10mm; @@ -548,28 +469,15 @@ WOK      float: right;    }    #vertical { -    /* background: none; */      padding: 0 12px 0px 0px; -    /* border-top: 2px solid #000077; */ -    /* border-bottom: 2px solid #000077; */ -    /* margin-left: 33%; */      margin-left: 2%;      margin-right: 2%;    } -/* -  #vertical { -    padding: 0 12px 0px 0px; -    border-top: 2px solid #000077; -    border-bottom: 2px solid #000077; -    margin-left: 33%; -    margin-right: 33%; -  } */    #vertical li {      display: block;      list-style-type: none;    }    #vertical a { -    /* font-weight: normal; */      line-height: 12px;      text-decoration: none;      color: #000077; @@ -577,15 +485,43 @@ WOK    #vertical a.active, #vertical a:hover {      border-bottom: 2px solid #777777;      padding-bottom: 2px; -    /* font-weight: bold; */      color: #000077;    } -  li.doc { + +  ul, li { +    list-style-type: none; +    list-style: none; +    padding-left: 20px; +    display: block; +    font-family: verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman; +    font-weight: normal; +    line-height: 150%; +    text-align: left; +    text-indent: 0mm; +    margin-left: 1em; +    margin-right: 2em; +    margin-top: 3px; +    margin-bottom: 3px; +  } + +  li {      background: url(../image/bullet_09.png) no-repeat 0px 6px; -    /* background: url(../image/bullet_doc.png) no-repeat 0 0; */ -    /* background: url(../../_sisu/image/bullet_09.png) no-repeat 0px 6px; */ -    padding-left: 16px; -    margin-left: 10px; +  } + +  ul { +  } +  li.bullet { margin-left: 1em; } +  li.i1 { margin-left: 2em; } +  li.i2 { margin-left: 3em; } +  li.i3 { margin-left: 4em; } +  li.i4 { margin-left: 5em; } +  li.i5 { margin-left: 6em; } +  li.i6 { margin-left: 7em; } +  li.i7 { margin-left: 8em; } +  li.i8 { margin-left: 9em; } +  li.i9 { margin-left: 10em; } + +  li.doc, li.ref, li.refcenter {      margin-top: 0px;      margin-bottom: 0px;      margin-right: 0px; @@ -593,74 +529,65 @@ WOK      font-style: normal;      text-align: left;    } +  li.doc { +    background: url(../image/bullet_09.png) no-repeat 0px 6px; +    padding-left: 16px; +    margin-left: 10px; +    margin-right: 0px; +  }    li.ref {      background: none;      padding-left: 0;      margin-left: 0; -    margin-top: 0px; -    margin-bottom: 0px;      color: #777777; -    font-size: 8px; -    font-style: normal; -    text-align: left;    }    li.refcenter {      background: url(../image/bullet_09.png) no-repeat 0px 6px; -    /* background: url(../image/bullet_doc.png) no-repeat 0 0; */ -    background: none;      padding-left: 20px;      margin-left: 10%;      font-size: 9px; -    margin-top: 0px; -    margin-bottom: 0px;      color: #777777;      text-align: center;    }    li.refbold { -    background: url(../image/bullet_09.png) no-repeat 0px 6px; -    /* background: url(../image/bullet_doc.png) no-repeat 0 0; */ -    /* padding-left: 0px; */ +    list-style-type: none;      padding-left: 16px;      margin-left: 0; -    margin-top: 0px; -    margin-bottom: 0px;      margin-right: 10mm; -    font-size: 8px;      font-weight: bold; -    text-align: left; -  } -  h1 { -    font-size: 120%; -    margin-top: 20px; -  } -  h2 { -    font-size: 115%; -    margin-top: 20px;    } -  h3 { -    font-size: 110%; -    margin-top: 20px; -  } -  h4 { -    font-size: 105%; -  } -  h5 { -    font-size: 100%; -  } -  h6 { -    font-size: 100%; -  } -  h0 { -    font-size: 80%; -  } -  h1.norm, h2.norm, h3.norm { -    font-size: 110%; -    margin-left: 10mm; -    margin-right: 15mm; + +  h0, h1, h2, h3, h4, h5, h6 { +    font-weight: bold; +    line-height: 120%;      text-align: left;      margin-top: 20px;      margin-bottom: 10px;    } +  h4.norm, h5.norm, h6.norm { +    margin-top: 10px; +    margin-bottom: 0px; +  } +  h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { +    text-align: center; +  } +  h1 { font-size: 120%; } +  h2 { font-size: 115%; } +  h3 { font-size: 110%; } +  h4 { font-size: 105%; } +  h5 { font-size: 100%; } +  h6 { font-size: 100%; } +  h0 { font-size: 80%; } + +  h1.i {margin-left: 2em;} +  h2.i {margin-left: 3em;} +  h3.i {margin-left: 4em;} +  h4.i {margin-left: 5em;} +  h5.i {margin-left: 6em;} +  h6.i {margin-left: 7em;} +  h7.i {margin-left: 8em;} +  h8.i {margin-left: 9em;} +  h9.i {margin-left: 10em;}    h1.top_band {      display: inline;      text-align: left; @@ -682,6 +609,7 @@ WOK      margin-right: 0px;      text-align: left;    } +    p.top_band {      display: inline;      text-align: left; @@ -709,178 +637,240 @@ WOK      text-indent: 0mm;      margin-right: 1mm;    } -  h4.norm, h5.norm, h6.norm { -    font-size: 100%; -    margin-left: 10mm; -    margin-right: 15mm; -    text-align: left; -    margin-top: 10px; -    margin-bottom: 0px; -  } -  h1.i {margin-left: 10mm;} -  h2.i {margin-left: 15mm;} -  h3.i {margin-left: 20mm;} -  h4.i {margin-left: 25mm;} -  h5.i {margin-left: 30mm;} -  h6.i {margin-left: 35mm;} -  h7.i {margin-left: 40mm;} -  h8.i {margin-left: 45mm;} -  h9.i {margin-left: 50mm;} -  h1.banner { + +  .banner, .subbanner {      font-weight: bold;      text-align: center; -    font-size: 120%;      margin-left: 10mm;      margin-right: 15mm;      margin-top: 20px;      margin-bottom: 10px;    } + +  h1.banner { +    font-size: 120%; +  }    h1.subbanner { -    font-weight: bold; -    text-align: center;      font-size: 115%; -    margin-left: 10mm; -    margin-right: 15mm; -    margin-top: 20px; -    margin-bottom: 10px;    }    h2.banner { -    font-weight: bold; -    text-align: center;      font-size: 110%; -    margin-left: 10mm; -    margin-right: 15mm; -    margin-top: 20px; -    margin-bottom: 10px;    }    h3.banner { -    font-weight: bold; -    text-align: center;      color: #990000;      font-size: 105%; -    margin-left: 10mm; -    margin-right: 15mm; -    margin-top: 20px; -    margin-bottom: 10px;    }    h4.banner { -    font-weight: bold; -    text-align: center;      color: #ff0000;      font-size: 100%; -    margin-left: 10mm; -    margin-right: 15mm; -    margin-top: 20px; -    margin-bottom: 10px;    }    h5.banner { -    font-weight: bold;    }    h6.banner { -    font-weight: bold;    } -  h1.toc { -    margin-left: 10mm; -    font-size: 115%; + +  .toc { +    font-weight: normal;      margin-top: 6px;      margin-bottom: 6px; +  } +  h1.toc { +    margin-left: 1em; +    font-size: 115%;      line-height: 150%;    }    h2.toc { -    margin-left: 15mm; +    margin-left: 2em;      font-size: 110%; -    margin-top: 6px; -    margin-bottom: 6px;      line-height: 140%;    }    h3.toc { -    margin-left: 20mm; +    margin-left: 3em;      font-size: 105%; -    margin-top: 6px; -    margin-bottom: 6px;      line-height: 120%;    }    h4.toc { -    margin-left: 25mm; -    font-weight: normal; +    margin-left: 4em;      font-size: 100%; -    margin-top: 6px; -    margin-bottom: 6px;      line-height: 120%;    }    h5.toc { -    margin-left: 30mm; -    font-weight: normal; +    margin-left: 5em;      font-size: 95%; -    margin-top: 6px; -    margin-bottom: 6px;      line-height: 110%;    }    h6.toc { -    margin-left: 35mm; -    font-weight: normal; +    margin-left: 6em;      font-size: 90%; -    margin-top: 6px; -    margin-bottom: 6px;      line-height: 110%;    } -/* microtoc (for later) --> */ + +  .microtoc { +    margin-top: 2px; +    margin-bottom: 2px; +  } +    h1.microtoc {      margin-left: 0mm;      font-size: 115%; -    margin-top: 2px; -    margin-bottom: 2px;    }    h2.microtoc {      margin-left: 5mm;      font-size: 110%; -    margin-top: 2px; -    margin-bottom: 2px;    }    h3.microtoc {      margin-left: 10mm;      font-size: 105%; -    margin-top: 2px; -    margin-bottom: 2px;    }    h4.microtoc {      margin-left: 15mm;      font-weight: normal;      font-size: 100%; -    margin-top: 2px; -    margin-bottom: 2px;    }    h5.microtoc {      margin-left: 20mm;      font-weight: normal;      font-size: 95%; -    margin-top: 2px; -    margin-bottom: 2px;    }    h6.microtoc {      margin-left: 25mm;      font-weight: normal;      font-size: 90%; -    margin-top: 2px; -    margin-bottom: 2px;    } -/* subtoc --> */ -  h5.subtoc { -    margin-left: 20mm; + +  .subtoc {      margin-right: 34%;      font-weight: normal; +  } +  h5.subtoc { +    margin-left: 2em;      font-size: 80%;      margin-top: 2px;      margin-bottom: 2px;    }    h6.subtoc { -    margin-left: 25mm; -    margin-right: 34%; -    font-weight: normal; +    margin-left: 3em;      font-size: 75%;      margin-top: 0px;      margin-bottom: 0px;    } + +  div.substance { +    width: 100%; +    background-color: #ffffff; +  } +  div.ocn { +    width: 5%; +    float: right; +    top: 0; +    background-color: #ffffff; +  } +  div.endnote { +    width: 95%; +    background-color: #fffffff; +  } +  div.toc { +    position: absolute; +    float: left; +    margin: 0; +    padding: 0; +    padding-top: 0.5em; +    border: 0; +    width: 13em; +    background-color: #eeeeee; +    margin-right:1em; +  } +  div.summary { +    margin: 0; +    padding: 0; +    border-left: 13em solid #eeeeee; +    padding-left: 1em; +    background-color: #eeeeee; +  } +  div.content, div.main_column { +    margin: 0; +    padding: 0; +    border-left: 13em solid #ffffff; +    padding-left: 1em; +  } +  div.content:after { +    content:' '; +    clear:both; +    display:block; +    height:0; +    overflow:hidden +  } +  div.footer { +    clear:left; +    padding: 0.5em; +    font-size: 80%; +    margin: 0; +  } +  div.toc ul { +    list-style: none; +    padding: 0; +    margin: 0; +  } +  div.toc li ul a, li ul span.currentlink +  { +    font-weight: normal; +    font-size: 90%; +    padding-left: 2em; +    background-color: #eeeeee; +  } +  div.toc a, span.currentlink{ +    display:block; +    text-decoration: none; +    padding-left: 0.5em; +    color: #0000aa; +  } +  hr { +    width: 90%; +  } + +  span.currentlink { +    text-decoration: none; +    background-color: #aaaaf9; +  } + +  div.toc a:visited { +    color: #0000aa; +  } +  div.toc a:hover { +    color: #000000; +    background-color: #f9f9aa; +  } + +  .minitoc { +    font-weight: normal; +    margin-top: 2px; +    margin-bottom: 2px; +  } +  h1.minitoc, h2.minitoc, h3.minitoc { +    margin-left: 0em; +    font-weight: bold; +    text-align: left; +    font-size: 90%; +    margin-top: 4px; +    margin-bottom: 4px; +  } +  h4.minitoc { +    margin-left: 0em; +    font-size: 90%; +  } +  h5.minitoc { +    margin-left: 1em; +    font-size: 85%; +  } +  h6.minitoc { +    margin-left: 2em; +    font-size: 85%; +  } +  h0.minitoc { +    margin-left: 0em; +    font-size: 90%; +  } +    h1.c, h2.c, h3.c, h4.c, h5.c, h6.c, p.c {      text-align: center    } @@ -902,35 +892,6 @@ WOK      margin-bottom: 20px;      margin-right: 15mm;    } -/* -  table.hidden { -    color: #ffffff; -    text-decoration: none; -  } -  td.hidden { -    color: #ffffff; -    background-color: #000000; -  } -  td.hidden a.active, div.hidden a:hover { -    color: #ffffff; -    background-color: #000000; -  } -  td.hidden a:hover { -    text-decoration: none; -  } -  div.hidden a { -    line-height: 12px; -    margin: 0 0 0 0; -    text-decoration: none; -    color: #000077; -  } -  div.hidden a.active, div.hidden a:hover { -    text-decoration: none; -  } -  div.hidden a:hover { -    text-decoration: none; -  } -*/  WOK      end      def homepage                                  #stylesheet for index, home page @@ -974,257 +935,6 @@ WOK    #banner h1 { margin:0px; padding:10px}  WOK      end -    def html_bk                                   #stylesheet for html... check use -<<WOK -    document { -      display: block; -      margin-left: 0mm; -      margin-right: 0mm; -    } -    head { -      display: block; -      margin-bottom: 20px; -      background-color: #dddddd; -    } -    dc,keywords,copyright { -      display: block; -      font-family: #{fonts}; -      color: blue; -      background-color: #dddddd; -      font-weight: normal; -      text-align: justify; -      font-size: xx-small%; -      line-height: 120%; -      margin-left: 5%; -      margin-right: 5mm; -      margin-top: 0px; -      margin-bottom: 0px; -    } -    keywords,copyright { -      display: block; -      font-family: #{fonts}; -      color: red; -      background-color: #dddddd; -      font-weight: normal; -      text-align: justify; -      font-size: xx-small%; -      line-height: 120%; -      margin-left: 5%; -      margin-right: 5mm; -      margin-top: 0px; -      margin-bottom: 0px; -    } -    table { -      margin-left: 5%; -      display: block; -    } -    tr { -      display: block; -    } -    th, td { -      display: inline; -    } -    th.left { -      text-align: left; -    } -    td.right { -      text-align: right; -    } -    body { -      color: black; -      background: #ffffff; -    } -    a:link { -      color: #003399; -      text-decoration: none; -    } -    a:visited { -      color: #003399; -      text-decoration: none; -      /* background-color: #e3ecef; */ -    } -    a:hover { -      color: #000000; -      text-decoration: underline; -      background-color: #fff3b6; -    } -    a:hover IMG { -      background-color: #ffffff; -    } -    a:active { -      color: #003399; -      text-decoration: underline; -    } -    p { -      display: block; -      font-family: #{fonts}; -      font-weight: normal; -      text-align: justify; -      font-size: 100%; -      line-height: 150%; -      margin-left: 5%; -      margin-right: 5%; -      margin-top: 2px; -      margin-bottom: 0px; -    } -    p.norm { -    } -    p.h1 { -      font-family: #{fonts}; -      font-size: 120%; -      font-weight: bold; -      text-align: left; -      line-height: 120%; -      margin-top: 20px; -      margin-bottom: 10px; -    } -    p.h2 { -      font-weight: bold; -      font-size: 110%; -      text-align: left; -      margin-top: 20px; -      margin-bottom: 10px; -    } -    p.h3 { -      font-size: 110%; -      font-weight: bold; -      text-align: left; -    } -    p.h4 { -      font-size: 110%; -      font-weight: bold; -      text-align: left; -    } -    p.h5 { -      font-size: 110%; -      font-weight: bold; -      text-align: left; -    } -    p.h6 { -      font-size: 110%; -      font-weight: bold; -      text-align: left; -    } -    p.toc1 { -      font-weight: bold; -      font-size: small; -      text-align: left; -      line-height: 100%; -      margin-left: 5%; -      margin-right: 5%; -      margin-top: 10px; -      margin-bottom: 5px; -    } -    p.toc2 { -      font-weight: bold; -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 5%; -      margin-right: 10%; -      margin-top: 10px; -      margin-bottom: 5px; -    } -    p.toc3 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 5%; -      margin-right: 10%; -      margin-top: 10px; -      margin-bottom: 5px; -    } -    p.toc4 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 10%; -      margin-right: 10%; -      margin-top: 5px; -      margin-bottom: 5px; -    } -    p.toc5 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 15%; -      margin-right: 10%; -      margin-top: 5px; -      margin-bottom: 5px; -    } -    p.toc6 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 20%; -      margin-right: 10%; -      margin-top: 5px; -      margin-bottom: 5px; -    } -/* microtoc for use later -->  */ -/* - -*/ -/* subtoc --> */ -    p.subtoc4 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 10%; -      margin-right: 10%; -      margin-top: 5px; -      margin-bottom: 5px; -    } -    p.subtoc5 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 15%; -      margin-right: 10%; -      margin-top: 5px; -      margin-bottom: 5px; -    } -    p.subtoc6 { -      font-size: x-small; -      text-align: left; -      line-height: 100%; -      margin-left: 20%; -      margin-right: 10%; -      margin-top: 5px; -      margin-bottom: 5px; -    } -    p.ocn { -      display: block; -      text-align: right; -      vertical-align: super; -      color: #999999; -      font-size: xx-small; -      margin-right: 0mm; -      margin-top: 0px; -      margin-bottom: 0px; -    } -    p.note { -      display: block; -      font-size: small; -      font-family: #{fonts}; -      font-weight: normal; -      line-height: 150%; -      text-align: justify; -      margin-left: 10%; -      margin-right: 5%; -      margin-top: 4px; -      margin-bottom: 0px; -    } -    en { -      font-size: xx-small; -      vertical-align: super; -    } -    i { font-style: italic; } -    b { font-style: bold; } -    u { text-decoration: underline; } -    br { display: block; } -WOK -    end      def xhtml                                     #stylesheet for xhtml  <<WOK  /* SiSU css xhtml & sax.xml default style */ @@ -2015,8 +1725,7 @@ WOK        margin-bottom: 0px;        margin-right: 5mm      } -    p.norm { -    } +    p.norm { }      p.endnote {        font-size: 100%;        margin-left: 20%; diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index cb6d70f8..18e2f8dd 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -60,13 +60,22 @@  =end  module SiSU_DAL -  require "#{SiSU_lib}/defaults" -  require "#{SiSU_lib}/sysenv" -  require "#{SiSU_lib}/param" -  require "#{SiSU_lib}/dal_syntax" -  require "#{SiSU_lib}/dal_doc_str" -  require "#{SiSU_lib}/i18n" -  require "#{SiSU_lib}/shared_sem" +  require "#{SiSU_lib}/defaults"                           # defaults.rb +  require "#{SiSU_lib}/sysenv"                             # sysenv.rb +  require "#{SiSU_lib}/param"                              # param.rb +  require "#{SiSU_lib}/dal_syntax"                         # dal_syntax.rb +  require "#{SiSU_lib}/dal_doc_str"                        # dal_doc_str.rb +  require "#{SiSU_lib}/dal_idx"                            # dal_idx.rb +  require "#{SiSU_lib}/dal_numbering"                      # dal_numbering.rb +  require "#{SiSU_lib}/dal_hash_digest"                    # dal_hash_digest.rb +  require "#{SiSU_lib}/dal_endnotes"                       # dal_endnotes.rb +  require "#{SiSU_lib}/dal_images"                         # dal_images.rb +  require "#{SiSU_lib}/dal_metadata"                       # dal_metadata.rb +  require "#{SiSU_lib}/dal_character_check"                # dal_character_check.rb +  require "#{SiSU_lib}/dal_substitutions_and_insertions"   # dal_substitutions_and_insertions.rb +  require "#{SiSU_lib}/dal_expand_insertions"              # dal_expand_insertions.rb +  require "#{SiSU_lib}/i18n"                               # i18n.rb +  require "#{SiSU_lib}/shared_sem"                         # shared_sem.rb    include SiSU_Env    include SiSU_Param    include SiSU_Viz @@ -74,20 +83,18 @@ module SiSU_DAL    class Instantiate < SiSU_Param::Parameters::Instructions      def initialize        @@flag_vocab=0 -      @@endnote={} -      @@endnote_array=@@word_mode=[] -      @@endnote_counter,@@endnote_counter_asterisk,@@endnote_counter_dag=1,1,1 #added        @@line_mode=''      end    end    class Source <Instantiate -    @@dal_array=[] +    @@dal_array,@@html_idx_array=[],[]      @@fns=nil      def initialize(opt)        @opt=opt        @@fns||@opt.fns        @my_make_fns=SiSU_Env::Create_file.new(@opt.cmd,@opt.fns)        @fnm=@my_make_fns.marshal_meta +      @fnm_idx_html=@my_make_fns.marshal_meta_idx_html        SiSU_Env::Create_system_link.new.images        @env=SiSU_Env::Info_env.new      end @@ -117,6 +124,21 @@ module SiSU_DAL          Instantiate.new        end      end +    def get_idx_html                                                             #reads dal idx.html, #unless does not exist then creates first +      begin +        dal=[] +        unless @@fns==@opt.fns +          @@fns=@opt.fns +          @@html_idx_array=[] +        end +        dal=if @@html_idx_array.empty?; read_fnm_idx_html +        else @@html_idx_array.dup #check +        end +      rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error +      ensure +        Instantiate.new +      end +    end    protected      def create_dal        dal_array=[] @@ -148,47 +170,62 @@ module SiSU_DAL        else SiSU_DAL::Source.new(@opt).create_dal        end      end +    def read_fnm_idx_html +      dal=[] +      dal=if FileTest.file?(@fnm_idx_html) +        if RUBY_VERSION < '1.9' +          File.open(@fnm_idx_html){ |f| dal=Marshal.load(f)} +        else File.open(@fnm_idx_html,'r:utf-8'){ |f| dal=Marshal.load(f)} +        end +      else nil +        #SiSU_DAL::Source.new(@opt).create_dal +      end +#p dal; dal +    end    end    class Output      def initialize(md,data)        @md,@data=md,data        @my_make=SiSU_Env::Create_file.new(@md.cmd,@md.fns) -      dir=SiSU_Env::Info_env.new(@md.fns) -      @hard="#{dir.path.dal}/#{@md.fns}.meta" +      @dir=SiSU_Env::Info_env.new(@md.fns)      end      def hard_output        if @md.cmd =~/M/          filename_meta=@my_make.file_meta          @data.each {|s| filename_meta.puts s.strip + "\n\n" unless s.strip.empty?} -      else File.unlink(@hard) if FileTest.file?(@hard) +      else +        hard="#{@dir.path.dal}/#{@md.fns}.meta" +        File.unlink(hard) if FileTest.file?(hard)        end      end      def marshal        marshal_meta=@my_make.marshal_meta        File.open(marshal_meta,'w'){|f| Marshal.dump(@data.to_a,f)}      end +    def idx_html_hard_output +      if @md.book_index and @md.cmd =~/M/ +        filename_meta=@my_make.file_meta_idx_html +        @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} +      else +        hard_idx_html="#{@dir.path.dal}/#{@md.fns}.idx.html" +        File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html) +      end +    end +    def idx_html_marshal +      marshal_meta=@my_make.marshal_meta_idx_html +      File.open(marshal_meta,'w'){|f| Marshal.dump(@data.to_a,f)} +    end    end    class Make -    @@endnote={} -    @@endnote_array=@@word_mode=[] -    @@endnote_counter,@@endnote_counter_asterisk,@@endnote_counter_dag=1,1,1 -    @@comment='%'      @@dp=nil      def initialize(md,data)        @md,@data=md,data -      @@word_mode=[]        @env=SiSU_Env::Info_env.new(@md.fns)        @skin=SiSU_Env::Info_skin.new(@md)        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern -      l=SiSU_Env::Standardise_language.new.file_to_language(@md.fns) -      @language=l[:l] -      @tr=SiSU_Translate::Source.new(@md,@language)      end      def reset        @@flag_vocab=0 -      @@endnote={} -      @@endnote_array=@@word_mode=[] -      @@endnote_counter,@@endnote_counter_asterisk,@@endnote_counter_dag=1,1,1        @@line_mode=''      end      def song @@ -197,9 +234,9 @@ module SiSU_DAL        @metafile="#{@env.path.dal}/#{@md.fns}.meta"        my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns)        data=data.join.split("\n\n") -      data=expand_insertions?(data) +      data=SiSU_insertions::Insertions.new(data).expand_insertions?        data=SiSU_document_structure::Code.new(@md,data).code -      data=substitutions_and_insertions?(data) +      data=SiSU_substitute_and_insert::SI.new(@md,data).substitutions_and_insertions?        data_new=[]        data.each do |x|          data_new << if x =~ /\n\n/m; x.split(/\n\n+/) @@ -208,949 +245,26 @@ module SiSU_DAL        end        data=data_new.flatten        data=SiSU_Syntax::Markup.new(@md,data).songsheet -      data=character_check(data) -      data=images(data) +      data,endnote_array=SiSU_character_check::Check.new(data).character_check_and_oldstyle_endnote_array +      data=SiSU_images::Images.new(@md,data).images        data=SiSU_document_structure::Tables.new(@md,data).tables -      data=numbering_song(data) #tr issue -      data=endnotes(data) -      data=object_digest(data) -      meta=metadata(data) +      data=SiSU_numbering::Numbering.new(@md,data).numbering_song +      data,book_index,html_idx=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_index +      data=SiSU_endnotes::Endnotes.new(@md,data,endnote_array).endnotes +      data=SiSU_hash::Object_digest.new(@md,data,@env).object_digest +      meta=SiSU_metadata::Metadata.new(@md,data).metadata +      #meta=metadata(data)        outputdata=data + meta        if @md.cmd =~/[mM]/          SiSU_DAL::Output.new(@md,outputdata).hard_output          SiSU_DAL::Output.new(@md,outputdata).marshal +        SiSU_DAL::Output.new(@md,html_idx).idx_html_hard_output +        SiSU_DAL::Output.new(@md,html_idx).idx_html_marshal        end        reset        outputdata      end    protected -    def character_check(data) -      require 'iconv' -      reset -      @tuned_file=[] -      endnote_no=1 -      data.each do |para| -        para.strip! -        para.gsub!(/^([12])~\?\s+/,'\1~ ')                                    #conditional header for incorporated document 2004w12 -        para.gsub!(/^[{~}]\s*$/,'') -        para.gsub!(/^#{@@comment}.*/,'')                                       #remove comment and divider #% -        para.gsub!(/<~#>|~#\s*/,"#{Mx[:fa_o]}~##{Mx[:fa_c]}") -        para.gsub!(/-#\s*/,"#{Mx[:fa_o]}-##{Mx[:fa_c]}#{Mx[:fa_o]}~##{Mx[:fa_c]}") -        #para.gsub!(/(#\{{3} arch-tag:|0\{{3}~cvs)\s+/, "0{{~rcs ") #KEEP ... ENABLE WIDER USE OF REVISION CONTROL -        para.gsub!(/(#{Mx[:en_a_o]} )\s+/,'\1'); para.gsub!(/(~\{ )\s+/,'\1') -        para.gsub!(/ \/\//,"#{Mx[:br_line]}")                                           #added 2004w29 -        para.gsub!(/<br>/,"#{Mx[:br_line]}")                                            #needed by xml, xhtml etc. -        #para.gsub!(/<p>/,'<p />')                                             #consider -        para.gsub!(/`/,"'") -        para.gsub!(/\t/,' ') -        para.gsub!(/\342\200\231/u,"'") #if para =~/’/  #Avoid #‘ ’ #“ ” -        para.gsub!(/�/u,' ') #watch, replace with char code -        para.gsub!(/[“”]/u,'""') -        para.gsub!(/[–—]/u,'-')   #— – chk -        para.gsub!(/·/u,'*') -        para.gsub!(/\\copy(?:right)?\b/,'©') -        para.gsub!(/\\trademark\b|\\tm\b/,'®') -        #non_utf8(para) -        para=para + "\n" -        unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ -          case para -          when /\^~/ # endnotes -                                                                                 #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ -            sub_para=para.dup -            @@endnote_array << sub_para.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/, %{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip -             endnote_no+=1 -            para=nil if para =~/\^~ .+/ #removes 'binary' endnote now in endnote array for later insertion -          end -        end -        @tuned_file << para unless para.nil? -      end -      @tuned_file=@tuned_file.flatten -    end -    def images(data) -      tuned_file=[] -      @rmgk=false -      if SiSU_Env::Info_settings.new.program?('rmagick'); @rmgk=SiSU_Env::Load.new('RMagick').prog -      else tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') -        tell.warn if @md.cmd =~/[vVM]/ -      end -      data.each do |para| -        para.strip! -        if para =~/\{\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?\}(?:(?:https?|file|ftp):\S+|image)/ -          if para !~/\{\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ -            m=/\{\s*(\S+\.(?:png|jpg|gif))/ -            if @rmgk -              imgs=para.scan(m).flatten -              images=imgs.each do |image| -                dir=SiSU_Env::Info_env.new(@md.fns) -                path_image=[dir.path.image_source_local_tex,dir.path.image_source_remote_tex,dir.path.image_source_tex] -                image_path=nil -                path_image.each do |image_path| -                  break if FileTest.exist?("#{image_path}/#{image}") -                end -                if FileTest.exist?("#{image_path}/#{image}") -                  img=Magick::ImageList.new("#{image_path}/#{image}") -                  img_col,img_row=img.columns,img.rows -                  if img_col > img_row                                               #landscape -                    if img_col> 640 #480 -                      img_col=640 #480 -                      img_row=((1.00*img_col/img.columns)*img.rows).round -                    end -                  else                                                               #portrait -                    if img_col> 640 #480 -                      img_col=640 #480 -                      img_row=((1.00*img_col/img.columns)*img.rows).round -                    end -                    if img_row > 640 -                      img_row=640 -                      img_col=((1.00*img_row/img.rows)*img.columns).round -                    end -                  end -                  para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") -                else para.gsub!(/\{\s*(\S+)\.(png|jpg|gif).+?\}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') -                end -              end -            else -              images=para.scan(m) do |image| -                tell=SiSU_Screen::Ansi.new(@md.cmd,'where image dimensions have not been provided RMagick is required',image) -                tell.warn #unless @opt.cmd =~/q/ -              end -            end -          end -        end -        para.gsub!(/\{\s+(\S+\.(?:png|jpg|gif))\s+/i,'{\1 ') if para =~/\{\s+\S+\.(?:png|jpg|gif).+?\}(?:(?:https?|file|ftp):\S+|image)/ -        tuned_file << para unless para.nil? -      end -      tuned_file -    end -    def output_filetypes_in_cmd(cmd_shortcut,source=nil) -      #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used -      cf_defaults=SiSU_Env::Info_processing_flag.new -      cmd_list=case cmd_shortcut.inspect -      when /0/; cf_defaults.cf_0 -      when /1/; cf_defaults.cf_1 -      when /2/; cf_defaults.cf_2 -      when /3/; cf_defaults.cf_3 -      when /4/; cf_defaults.cf_4 -      when /5/; cf_defaults.cf_5 -      end -      file_type_names={} -      file_type_names[:gen],file_type_names[:src]=[],[] -      file_type_names[:gen] <<= if cmd_list =~ /y/; 'sisu_manifest.html' -      end -      file_type_names[:gen] <<= if cmd_list =~ /h/; ['toc.html', 'doc.html'] -      end -      file_type_names[:gen] <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] -      end -      #file_type_names[:gen] <<= if cmd_list =~ /i/; 'manpage.1' -      #end -      file_type_names[:gen] <<= if cmd_list =~ /o/; 'opendocument.odt' -      end -      file_type_names[:gen] <<= if cmd_list =~ /b/; 'scroll.xhtml' -      end -      file_type_names[:gen] <<= if cmd_list =~ /x/; 'sax.xml' -      end -      file_type_names[:gen] <<= if cmd_list =~ /X/; 'dom.xml' -      end -      file_type_names[:gen] <<= if cmd_list =~ /a/; 'plain.txt' -      end -      file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt' -      end -      file_type_names[:gen] <<= if cmd_list =~ /w/; 'concordance.html' -      end -      file_type_names[:gen] <<= if cmd_list =~ /N/; 'digest.txt' -      end -      file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; source -      end -      file_type_names[:src] <<= if cmd_shortcut =~ /S/; "#{source}.zip" -      end -      file_type_names[:gen]=file_type_names[:gen].flatten -      file_type_names[:src]=file_type_names[:src].flatten -      file_type_names -    end -    def expand_insertions?(data) -      tuned_file,tuned_file_tmp=[],[] -      data.each do |para| -        if para !~/^%+\s/ \ -        and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ -          txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil -          @u=SiSU_Env::Info_env.new.url -          if defined? @u.remote -            if para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/m -              pre,txt,cmd,source,url_dir,note="#{$1.strip} ",$2,$3,$4,$5,$6 -            elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/ -              pre,txt,cmd,source,url_dir,note='',$1,$2,$3,$4,$5 -            end -            manifest="#{pre}{#{txt} }#{@u.remote}/#{url_dir}/toc.html#{note}\n\n" -          else -            puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" -            if para =~/\{(?:~\^\s+)?(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ -              txt,cmd,url_dir,note=$1,$2,$3,$4 -              manifest="{ #{txt} }../#{url_dir}/toc.html#{note}\n\n" -            end -          end -          tuned_file_tmp << manifest -          output_filetypes=output_filetypes_in_cmd(cmd,source) -          output_filetypes[:gen].each do |o_f| -            describe = case o_f -            when /sisu_manifest.html/; '~^ document manifest' -            when /toc.html/;           ' html, segmented text' -            when /doc.html/;           ' html, scroll, document in one' -            when /landscape.pdf/;      ' pdf, landscape' -            when /portrait.pdf/;       ' pdf, portrait' -            when /opendocument.odt/;   ' odf:odt, open document text' -            when /scroll.xhtml/;       ' xhtml scroll' -            when /sax.xml/;            ' xml, sax' -            when /dom.xml/;            ' xml, dom' -            when /plain.txt/;          ' plain text utf-8' -            #when /manpage.1/;          ' man, 1' -            when /wiki.txt/;           ' wiki text' -            when /concordance.html/;   ' concordance' -            when /digest.txt/;         ' dcc, document content certificate (digests)' -            else nil -            end -            if describe -              tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry -                if describe =~/^~\^ / -                  "     {#{describe} }#{@u.remote}/#{url_dir}/#{o_f} " -                else -                  "     { #{describe} }#{@u.remote}/#{url_dir}/#{o_f} " -                end -              else -                if describe =~/^~\^ / -                  "     {#{describe} }../#{url_dir}/#{o_f} " -                else "     { #{describe} }../#{url_dir}/#{o_f} " -                end -              end -            end -          end -          output_filetypes[:src].each do |o_f| -            describe=case o_f -            when /#{source}\.zip/;     ' markup source (zipped) pod' -            when /#{source}/;          ' markup source text' -            else nil -            end -            if describe -              tuned_file_tmp << if @u.remote -                x=if describe =~/zip/ -                  "     {#{describe} }#{@u.src_pod}/#{o_f} " -                else "     {#{describe} }#{@u.src_txt}/#{o_f} " -                end -              else -                x=if describe =~/zip/ -                  "     { #{describe} }../pod/#{o_f} " -                else "     { #{describe} }../zip/#{o_f} " -                end -              end -            end -          end -          tuned_file << 'group{' << tuned_file_tmp.join("\n") << '}group' -          #tuned_file << 'group{' << tuned_file_tmp.join("\n").strip << '}group' -          tuned_file_tmp=[] -        else tuned_file << para -        end -      end -      tuned_file -    end -    def substitutions_and_insertions?(data) -      data_expand=[] -      if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content preceeds it) -        data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'') -        data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'') -      end -      if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier -        data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1') -        data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1') -      end -      data.each do |para| -        if para =~/<:insert\d+!?>/ \ -        and para !~/^%\s+/ -          @skin.select -          ins=SiSU_Viz::Inserts.new -          case para -          when /^\s*<:insert1>\s*$/ -            para=[] -            ins.insert1.split(/\n\n/).each{|x| para << x } -          when /^\s*<:insert2>\s*$/ -            para=[] -            ins.insert2.split(/\n\n/).each{|x| para << x } -          when /^\s*<:insert3>\s*$/ -            para=[] -            ins.insert3.split(/\n\n/).each{|x| para << x << "\n"} -            para=ins.insert3 -          when /^\s*<:insert4>\s*$/ -            para=[] -            ins.insert4.split(/\n\n/).each{|x| para << x << "\n"} -            para=ins.insert4 -          when /^\s*<:insert5>\s*$/ -            para=[] -            ins.insert5.split(/\n\n/).each{|x| para << x << "\n"} -          when /^\s*<:insert6>\s*$/ -            para=[] -            ins.insert6.split(/\n\n/).each{|x| para << x << "\n"} -          when /^\s*<:insert7>\s*$/ -            para=[] -            ins.insert7.split(/\n\n/).each{|x| para << x << "\n"} -          end -          para.each{|x| data_expand << x } -        else data_expand << para -        end -        data_expand.flatten! -        data_expand.compact! -      end -      data_expand.each do |para| -        para=if @md.markup_version.to_f >= 0.38 -          SiSU_document_structure::Structure.new(@md,para).structure_markup_normalize -        else -          SiSU_document_structure::Structure.new(@md,para).structure_marks -        end -        #para.gsub!(/<url:(\S+?)>/,'\1') #consider, would permit use of text hyperlinks if desired, dal_syntax more appropriate? -        para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#')                                    #conditional header for incorporated document 2004w12 -        if para =~/^@\S+?:/ -          para.gsub!(/^@(\S+?):\s+/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}") -          para.gsub!(/^@(\S+?):([+-])\s+/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}") -        end -      end -    end -    def numbering_song(data) -      data=number_plaintext_para(data) -      data=name_endnote_seg(data) #tr issue -      data=auto_number_heading_ie_title(data) #tr issue -      data=ocn(data) #watch -      data=minor_numbering(data) -      data=name_para_seg_filename(data) -      data=set_heading_seg(data) unless @md.set_heading_seg -      data=set_heading_top(data) unless @md.set_heading_top -      data=set_header_title(data) unless @md.set_header_title -      data -    end -    def number_plaintext_para(data) -      @tuned_file=[] -      data.each do |para| -        if para !~/#{Mx[:gr_o]}(?:code|group|alt|poem|verse)#{Mx[:gr_c]}|#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ -          para.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks -        end -        para.gsub!(/^/,"\n") unless para =~/#{Mx[:tc_p]}/u -        para.gsub!(/^\s+|\s$/,"\n") -        @tuned_file << para -      end -      @tuned_file=@tuned_file.flatten -    end -    def name_endnote_seg(data) -      @tuned_file=[] -      data.each do |para| -        para.gsub!(/<:3>\s*<:ee>/, <<-WOK -#{@@endnote['special_align']} <p /><br />\r -#{@@endnote['seg_name_3']} <p /> -#{@@endnote['special_align_close']} -        WOK -        ) -        para.gsub!(/<:2>\s*<:ee>/, <<-WOK -#{@@endnote['special_align']} <p /><br />\r -#{@@endnote['seg_name_2']} <p /> -#{@@endnote['special_align_close']} -        WOK -        ) -        para.gsub!(/<:1>\s*<:ee>/, <<-WOK -#{@@endnote['special_align']} <p /><br />\r -#{@@endnote['seg_name_1']} <p /> -#{@@endnote['special_align_close']} -        WOK -        ) -        @tuned_file << para -      end -      # debug 2003w46 adding revision control info -      if @md.flag_auto_endnotes \ -      and @md.flag_separate_endnotes_make -        @tuned_file << "\n#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}Endnotes #{Mx[:gl_o]}-##{Mx[:gl_c]} #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" -      end -      @tuned_file << "\n#{Mx[:br_endnotes]}" #DECIDE ON -      @tuned_file=@tuned_file.flatten -    end -    def owner_details_seg -      data << "#{Mx[:lv_o]}4:owner.details#{Mx[:lv_c]}Owner Details" -    end -    def number_sub_heading(para,num,title_no) -      case para -      when /#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/;  para.gsub!(/#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/,"#{title_no} ") -      when /^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/; para.gsub!(/^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/,"#{title_no} ") -      when /^#{Mx[:lv_o]}#{num}:[a-z_\.]+#{Mx[:lv_c]}/ -        para.gsub!(/^#{Mx[:lv_o]}#{num}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i,%{#{Mx[:lv_o]}#{num}:\\1#{Mx[:lv_c]} #{title_no} \\2  #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) -      when /^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}\s*#{title_no}/ -        para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]}")                #where title contains title number -      else para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]} #{title_no} ") #main, where title number is to be provided -      end -      if @md.toc_lev_limit \ -      and @md.toc_lev_limit < num -        para.gsub!(/^#{Mx[:lv_o]}[5-9]:\S*?#{Mx[:lv_c]}/,'!_ ') #bold line, watch -      end -      para -    end -    def auto_number_heading_ie_title(data)                                             #also does some segment naming -      @tuned_file=[] -      if @md.markup =~/num_top/ \ -      or @md.num_top # watch, 2003w23 -        input="#{@md.markup}"[/num_top\=([1-6])/,1] if @md.markup -        input||=@md.num_top if @md.num_top !~/^$/ -      end -      num_top=input.to_i -      t_no1=t_no2=t_no3=t_no4=0 -      no1=num_top; no2=(num_top + 1); no3=(num_top + 2);  no4=(num_top + 3) -      t_not=0 -      data.each do |para| #@md.seg_names << [additions to segment names] -        if (@md.markup =~/num_top/ \ -        or (@md.num_top \ -        and @md.num_top !~/^$/)) \ -        and para !~/^#{Rx[:meta]}/ -          if (para =~/^(?:#{no1}|^#{no2}|^#{no3}#{no4})~#/ \ -          and para !~/^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}/) -            t_not+=1 #; t_no2=0; t_no3=0 -            para.gsub!(/^(#{Mx[:lv_o]}#{no1}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") -            para.gsub!(/^(#{Mx[:lv_o]}#{no2}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") -            para.gsub!(/^(#{Mx[:lv_o]}#{no3}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") -            para.gsub!(/^(#{Mx[:lv_o]}#{no4}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") -          end -          if para =~/#{Mx[:lv_o]}#{no1}:/ -            @subnumber=1 -            @subnumber=0 if para =~/#{Mx[:lv_o]}#{no1}:/ -          end -          if para =~/^#{Mx[:lv_o]}[1-6]:[\w-]*#{Mx[:lv_c]}/ \ -          and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s+[\d.]+)\s/ \ -          and para !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ -            if para =~/^#{Mx[:lv_o]}#{no1}:/ -              t_no1+=1; t_no2=0; t_no3=0 -              title_no="#{t_no1}" -              if not @md.seg_names.nil? \ -              and not @md.seg_names.include?(title_no) -                para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*(\S+)#/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]} \\1 #{title_no} ") #shift placement of auto-number to after first word, e.g. Article # not # Article, added on occasion of ABF (20040329) -                para.gsub!(/^#{no1}\{\s+(Article|Clause|Section)\s+#/i,%{#{no1}~#{title_no} \\1 #{title_no}. }) -                unless para =~/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review -                  para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]}#{title_no}. ") -                end -                @md.seg_names << title_no -              #else puts "warning segment name #{title_no} already exists" -              end -              unless para =~/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required -                para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i, -                  %{#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}#{title_no}. \\2 #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) -              end -              para.gsub!(/^#{Mx[:lv_o]}#{no1}:##{Mx[:lv_c]}/,"#{title_no}. ") #watch -              para.gsub!(/^#{no1}~#\s*/,"#{title_no}. ") -            end -            if para =~/^#{Mx[:lv_o]}#{no2}:\S*?#{Mx[:lv_c]}/ -              t_no2+=1; t_no3=0 -              title_no="#{t_no1}.#{t_no2}" -              para=number_sub_heading(para,no2,title_no) -            end -            if para =~/^#{Mx[:lv_o]}#{no3}:\S*?#{Mx[:lv_c]}/ -              t_no3+=1 -              title_no="#{t_no1}.#{t_no2}.#{t_no3}" -              para=number_sub_heading(para,no3,title_no) -            end -          elsif para =~/^#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}/ # endnotes, watch2005 -            para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}") #"#{no1}~\\1 ") -            para.gsub!(/^#{Mx[:lv_o]}#{no2}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no2}:\\1#{Mx[:lv_c]}") -            para.gsub!(/^#{Mx[:lv_o]}#{no3}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no3}:\\1#{Mx[:lv_c]}") -          end -        elsif @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 -          if para =~/^#{Mx[:lv_o]}[1-9]:#{Mx[:lv_c]}([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d -            name_num=$1 -            para.gsub!(/^#{Mx[:lv_o]}([1-9]:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{name_num}#{Mx[:lv_c]}") -          end -          if @md.toc_lev_limit -          end -        end -        @tuned_file << para -      end -      @tuned_file=@tuned_file.flatten -    end -    def ocn(data)                                                                      #and auto segment numbering increment -      @tuned_file=[] -      object_array=SiSU_document_structure::OCN.new(@md,data).ocn -      object_array.each do |o| -        @tuned_file <<= if o.ocn; "#{o.txt} #{Mx[:id_o]}~#{o.ocn};#{o.lv};#{o.type}#{Mx[:id_c]}" #main ocn descriptor -        else o.txt -        end -      end -      @tuned_file=@tuned_file.flatten -    end -    def minor_numbering(data)                                                          #and auto segment numbering increment -      @tuned_file=[] -      number_small,letter_small=0,0 -      letter=%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 ) -      data.each do |para| -        if para =~/\w|\S|<|\(/ -          if para !~/^%% |#{Rx[:meta]}|^0~|^#{Mx[:lv_o]}endnotes:|^4~endnotes|^<\/center>|<:ee>|<:e[:_]>|^\^~ |<:e[:_]\d+?>|^#{Mx[:fa_o]}:p[bn]#{Mx[:fa_c]}|^<:\#|<:- |<[:!]!4|#{Mx[:gr_o]}(?:alt|code|group|poem|table)#{Mx[:gr_c]}|^(?:alt|code|group|poem|table)\{|^\}(?:alt|code|group|poem|table)|^\}table$|<table|<\/table>|<td|<\/td>|<th|<\/th>|<tr>|<\/tr>|<hr width|<:4-endnotes>|\[endnotes\]|<:zz>|<:isbn-|<:journal-|<:conference-|#{Mx[:br_endnotes]}/i #ocn here #  added with Tune.code #¡ -            if para=~/^#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}/; number_small,letter_small=0,0                    #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) -            end -            if para =~/^#[ 1]/ -              letter_small=0 -              number_small=0 if para =~ /^#1/ -              number_small+=1 -              para.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004 -            end -            if para =~/^_# / -              para.gsub!(/^_# /,"#{Mx[:fa_o]}:i1#{Mx[:fa_c]} #{letter[letter_small]}. ") #change 2004 -              letter_small+=1 -            end -          end -        end -        @tuned_file << para -      end -      @tuned_file=@tuned_file.flatten -    end -    def name_para_seg_filename(data) -      # paragraph name/numbering rules -      # manual naming overrides, manual naming may be -      #   alpha-numeric characters mixed, -      #   numeric only (a number), if -      #     all segments have been named, -      #     the numbers used are over 1000 or -      #     it is  not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) -      #       [for now a warning is printed for such documents on use of maintenance or very-verbose flag] -      # auto-naming takes the form of giving numbers to segments -      # the rules for which are as follows -      #   if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.) -      #   otherwise the level 4 segment number from the embedded document structure info is used -      #   if there is none a sequential number is designated, preceded by an underscore -      @tuned_file=[] -      art_filename_auto=1 -      @counter=1 -      @unique_auto_name=[] -      if not @md.seg_autoname_safe and @md.cmd =~/[MV]/ -        puts 'manual segment names, numbers used as names, risk warning (segmented html)' -      end -      data.each do |para| -        para=SiSU_document_structure::Structure.new(@md,para).structure_markup -        if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}/ -          if para=~/^#{Mx[:lv_o]}[4]:#{Mx[:lv_c]}/ \ -          and not @md.set_heading_seg -            @md.set_heading_seg=true -          end -          if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}(?:\s*\S+)?\s+([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name -            pattern=$1 -            pattern.gsub!(/(?:[:,-]|\W)/,'.') -            pattern.gsub!(/\.$/,'') -            if not @md.seg_names.nil? \ -            and not @md.seg_names.include?(pattern) -              para.gsub!(/^#{Mx[:lv_o]}([456]):#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1:#{pattern}#{Mx[:lv_c]}") -              @md.seg_names << pattern -            else puts 'warn, there may be a conflicting numbering scheme' if @md.cmd =~/[VM]/ -            end -          end -          if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}.+?;4:(\d+);/m #extract segment name from embedded document structure info -            pattern=$1 -            pattern.gsub!(/(?:[:,-]|\W)/,'.') -            pattern.gsub!(/\.$/,'') -            if not @md.seg_names.nil? \ -            and not @md.seg_names.include?(pattern) -              para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{pattern}#{Mx[:lv_c]}") -              @md.seg_names << pattern -            else -              para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1~#{pattern}#{Mx[:lv_c]}") -              @md.seg_names << "~#{pattern}" -            end -          end -          if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}/ #if still not segment name, provide a numerical one -            if not @md.seg_names.nil? \ -            and not @md.seg_names.include?(art_filename_auto) -              para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,%{#{Mx[:lv_o]}\\1~#{art_filename_auto}#{Mx[:lv_c]}}) -              @md.seg_names << art_filename_auto -            else puts 'segment name (numbering) error' -            end -            art_filename_auto+=1 -          end -        end -        @tuned_file << if para =~/^#{Mx[:lv_o]}([1-6]):\S*?#{Mx[:lv_c]}/m \ -        and (@md.pagenew or @md.pagebreak) -          m=$1 #watch ref~ -          para_tmp=[] -          if @md.pagenew.inspect =~/#{m}/;           para_tmp << "#{Mx[:br_page_new]}\n" << para -          elsif @md.pagebreak.inspect =~/#{m}/;         para_tmp << "#{Mx[:br_page]}\n" << para -          end -          para_result=unless para_tmp.length > 0; para -          else                       para_tmp -          end -        else                         para -        end -      end -      if @md.seg_names.length > 0 -        @md.set_heading_seg=true -      end -      @tuned_file=@tuned_file.flatten -    end -    def set_heading_top(data)                                                         #% make sure no false positives -      unless @md.set_heading_top -        puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.cmd =~/[MV]/ -        @tuned_file=[] -        data.each do |para| -          unless @md.set_heading_top -            if para !~/^(?:#{Rx[:meta]}|@\S+:|0~\S+)\s/m \ -            and para !~/\A\s*\Z/m -              @md.set_heading_top=true -              head=if @md.title ; "#{Mx[:lv_o]}1:#{Mx[:lv_c]} #{@md.title}" -              else                "#{Mx[:lv_o]}1:#{Mx[:lv_c]} [no title provided]" -              end -              @tuned_file << head -            end -          end -          @tuned_file << para -        end -        @tuned_file=@tuned_file.flatten -      end -    end -    def set_heading_seg(data)                                                          #% make sure no false positives -      unless @md.set_heading_seg -        puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.cmd =~/[MV]/ -        @tuned_file=[] -        data.each do |para| -          unless @md.set_heading_seg -            if para !~/^(?:#{Rx[:meta]}|#{Mx[:lv_o]}[123]:\S*?#{Mx[:lv_c]})/m \ -            and para !~/\A\s*\Z/m \ -            and para !~/#{Mx[:br_page]}|#{Mx[:br_page_new]}/ -              @md.set_heading_seg=true -              head=if @md.title ; "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [#{@md.title}]" -              else                "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [segment]" -              end -              @tuned_file << head -            end -          end -          @tuned_file << para -        end -        @tuned_file=@tuned_file.flatten -      end -    end -    def set_header_title(data)                                                         #% make sure no false positives -      unless @md.set_header_title -        puts "\t no document title provided, (will have to manufacture one)" if @md.cmd =~/[MV]/ -        @tuned_file=[] -        data.each do |para| -          unless @md.set_header_title -            if para !~/^%{1,2}\s/m \ -            and para !~/\A\s*\Z/m -              @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" -              @md.title=@md.heading_seg_first -              @md.set_header_title=true -            end -          end -          @tuned_file << para -        end -        @tuned_file=@tuned_file.flatten -      end -    end -    def endnotes(data) -      @tuned_file=[] -      endnote_no,endnote_ref=1,1 -                                                                                 #% endnote work zone -      data.each do |para| -                                                                                 # manually numbered endnotes <!e(\d)!> <!e_(\d)!> --> -        if @md.mod.inspect =~/--no-asterisk|--no-annotate/ -          para.gsub!(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') -        end -        if @md.mod.inspect =~/--no-dagger|--no-annotate/ -          para.gsub!(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') -        end -        unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ -          case para -                                                                                 # auto-numbered endnotes <!e!> <!e_!> --> -          when /#{Mx[:en_a_o]}\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ -            para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1')                                     # required 2003w31 -            word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) -            word_mode=endnote_call_number(word_mode) -            para=word_mode.join(' ') -            endnote_ref+=1 -          when /~\^(?:\s|$)|<:e>/ -                                                                                 #%Note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop) -            word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) -            word_mode=endnote_call_number(word_mode) -            para=word_mode.join(' ') -            endnote_ref+=1 -          end -        end -        @tuned_file << para -      end -      @tuned_file=@tuned_file.flatten -    end -    def endnote_call_number(data) -      data.each do |word| -        unless data =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ -          case word -          when /#{Mx[:en_a_o]}/ -            unless word =~/#{Mx[:en_a_o]}[*+]+/ -              word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@@endnote_counter} ") -              @@endnote_counter+=1 -            end -          when /#{Mx[:en_b_o]}/ -            if word =~/#{Mx[:en_b_o]}[+]/ -              word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@@endnote_counter_dag} ") -              @@endnote_counter_dag+=1 -            else -              word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@@endnote_counter_asterisk} ") -              @@endnote_counter_asterisk+=1 -            end -          when /~\^|<:e>/ -            word.gsub!(/~\^|<:e>/,"#{@@endnote_array[@@endnote_counter-1]}") -            @@endnote_counter+=1 -          end -        end -      end -    end -    def metadata(data) -      meta,@dc,@rc,@cvs,dctitle,add=Array.new(6){[]} -      dir=SiSU_Env::Info_env.new(@md.fns) -      base_html="#{dir.url.root}/#{@md.fnb}" -      ocnm=ocnd=ocnv=0 -      ocnm+=1 -      header1="\n#{Mx[:lv_o_1]}meta#{Mx[:lv_c]}Document Information (metadata) #{Mx[:id_o]}~0;0:0;m#{ocnm}#{Mx[:id_c]}" -      ocnm+=1 -      header4="\n#{Mx[:lv_o_4]}metadata#{Mx[:lv_c]}Metadata #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" -      ocnm+=1; ocnd+=1 -      head_no_dc="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -      ocnm+=1; ocnd+=1 -      head_no_dc_tag="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -      data.each do |para| -        case para -        when /^#{Mx[:meta_o]}(title|creator|author|translator|translated_by|illustrator|illustrated_by|prepared_by|digitized_by|description|publisher|contributor|date\.created|date\.issued|date\.available|date\.valid|date\.modified|date|type|format|rights|identifier|source|language)#{Mx[:meta_c]}/i -          m=$1 -          ocnm+=1; ocnd+=1 -          @dc << case para -          when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/ -            "\n#{@tr.dc_title}: #{Mx[:fa_underscore_o]}#{@md.dc_title}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}(?:creator|author)#{Mx[:meta_c]}/ -            "\n#{@tr.creator}: #{Mx[:fa_underscore_o]}#{@md.dc_creator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /#{Mx[:meta_o]}(?:translator|translated_by)#{Mx[:meta_c]}/ -            "\n#{@tr.translator}: #{Mx[:fa_underscore_o]}#{@md.translator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}(?:illustrator|illustrated_by)#{Mx[:meta_c]}/ -            "\n#{@tr.illustrator}: #{Mx[:fa_underscore_o]}#{@md.illustrator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}prepared_by#{Mx[:meta_c]}/ -            "\n#{@tr.prepared_by}: #{Mx[:fa_underscore_o]}#{@md.prepared_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}digitized_by#{Mx[:meta_c]}/ -            "\n#{@tr.digitized_by}: #{Mx[:fa_underscore_o]}#{@md.digitized_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}description#{Mx[:meta_c]}/ -            "\n#{@tr.description}: #{Mx[:fa_underscore_o]}#{@md.dc_description}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}subject#{Mx[:meta_c]}/ -            "\n#{@tr.subject}: #{Mx[:fa_underscore_o]}#{@md.dc_subject}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}abstract#{Mx[:meta_c]}/ -            "\n#{@tr.abstract}: #{Mx[:fa_underscore_o]}#{@md.dc_abstract}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}publisher#{Mx[:meta_c]}/ -            "\n#{@tr.publisher}: #{Mx[:fa_underscore_o]}#{@md.dc_publisher}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}contributor#{Mx[:meta_c]}/ -            "\n#{@tr.contributor}: #{Mx[:fa_underscore_o]}#{@md.dc_contributor}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}date.created#{Mx[:meta_c]}/ -            "\n#{@tr.date_created}: #{Mx[:fa_underscore_o]}#{@md.dc_date_created}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}date.issued#{Mx[:meta_c]}/ -            "\n#{@tr.date_issued}: #{Mx[:fa_underscore_o]}#{@md.dc_date_issued}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}date.available#{Mx[:meta_c]}/ -            "\n#{@tr.date_available}: #{Mx[:fa_underscore_o]}#{@md.dc_date_available}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}date.modified#{Mx[:meta_c]}/ -            "\n#{@tr.date_modified}: #{Mx[:fa_underscore_o]}#{@md.dc_date_modified}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}date.valid#{Mx[:meta_c]}/ -            "\n#{@tr.date_valid}: #{Mx[:fa_underscore_o]}#{@md.dc_date_valid}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}date#{Mx[:meta_c]}/ -            "\n#{@tr.date}: #{Mx[:fa_underscore_o]}#{@md.dc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}type#{Mx[:meta_c]}/ -            "\n#{@tr.type}: #{Mx[:fa_underscore_o]}#{@md.dc_type}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}format#{Mx[:meta_c]}/ -            "\n#{@tr.format}: #{Mx[:fa_underscore_o]}#{@md.dc_format}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}rights#{Mx[:meta_c]}/ -            "\n#{@tr.rights}: #{Mx[:fa_underscore_o]}#{@md.dc_rights}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}identifier#{Mx[:meta_c]}/ -            "\n#{@tr.identifier}: #{Mx[:fa_underscore_o]}#{@md.dc_identifier}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}source#{Mx[:meta_c]}/ -            "\n#{@tr.source}: #{Mx[:fa_underscore_o]}#{@md.dc_source}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}language#{Mx[:meta_c]}/ -            "\n#{@tr.language}: #{Mx[:fa_underscore_o]}#{@md.dc_language}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}language.original#{Mx[:meta_c]}/ -            "\n#{@tr.language_original}: #{Mx[:fa_underscore_o]}#{@md.language_original}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}relation#{Mx[:meta_c]}/ -            "\n#{@tr.relation}: #{Mx[:fa_underscore_o]}#{@md.dc_relation}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}coverage#{Mx[:meta_c]}/ -            "\n#{@tr.coverage}: #{Mx[:fa_underscore_o]}#{@md.dc_coverage}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}keywords#{Mx[:meta_c]}/ -            "\n#{@tr.keywords}: #{Mx[:fa_underscore_o]}#{@md.keywords}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}comments#{Mx[:meta_c]}/ -            "\n#{@tr.comments}: #{Mx[:fa_underscore_o]}#{@md.comments}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}cls_loc#{Mx[:meta_c]}/ -            "\n#{@cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}cls_dewey#{Mx[:meta_c]}/ -            "\n#{@tr.cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}(?:cls_gutenberg|cls_pg)#{Mx[:meta_c]}/ -            "\n#{@tr.cls_gutenberg}: #{Mx[:fa_underscore_o]}#{@md.cls_gutenberg}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -            #"\n#{@tr.cls_gutenberg}: <u>#{@md.cls_pg}</u> #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}cls_isbn#{Mx[:meta_c]}/ -            "\n#{@tr.cls_isbn}: #{Mx[:fa_underscore_o]}#{@md.cls_isbn}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}prefix(?:_a)?#{Mx[:meta_c]}/ -            "\n#{@tr.prefix_a}: #{Mx[:fa_underscore_o]}#{@md.prefix_a}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          when /^#{Mx[:meta_o]}prefix_b#{Mx[:meta_c]}/ -            "\n#{@tr.prefix_b}: #{Mx[:fa_underscore_o]}#{@md.prefix_b}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" -          else para.gsub(/^#{Mx[:meta_o]}(#{m})\s+(.+)/m,"\n#{m.capitalize}: #{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}") -          end -        end -      end -      ocnm+=1; ocnv+=1 -      head_no_rc="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -      ocnm+=1; ocnv+=1 -      head_no_rc_tag="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -      data.each do |para| -        case para -        when /^0~(?:cvs|rcs)\+\s+/ #note the + sign to turn on use of cvs id -          ocnm+=1; ocnv+=1 -          @cvs << "#{@tr.sc_number}: #{Mx[:fa_underscore_o]}#{@md.sc_number}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -          ocnm+=1; ocnv+=1 -          @cvs << "#{@tr.sc_date}: #{Mx[:fa_underscore_o]}#{@md.sc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -          ocnm+=1; ocnv+=1 -          @cvs << "CVS/RCS time: #{Mx[:fa_underscore_o]}#{@md.sc_time}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -          ocnm+=1; ocnv+=1 -        when /^0~cvs[+\s]/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP -        when /^0~cvs\s+/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP -        end -      end -      if true #default version information -        ocnm+=1; ocnv+=1 -        if @md.sc_filename \ -        and @md.sc_filename.length > 3 -          @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.sc_filename}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -        else @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.fns}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -        end -        ocnm+=1; ocnv+=1 -        if @md.file_encoding \ -        and @md.file_encoding.length > 3  #translate -          @rc << "Filetype: #{Mx[:fa_underscore_o]}#{@md.file_encoding}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -        end -        ocnm+=1; ocnv+=1 -        if @md.dgst #change. enable by default -          @rc << "#{@tr.sourcefile_digest}, #{@md.dgst[0]} #{Mx[:fa_underscore_o]}#{@md.dgst[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -          ocnm+=1; ocnv+=1 -        end -        if @md.dgst_skin #change. enable by default -          @rc << "Skin_Digest: #{@md.dgst_skin[0]} #{Mx[:fa_underscore_o]}#{@md.dgst_skin[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -          ocnm+=1; ocnv+=1 -        end -        @rc << "#{Mx[:fa_bold_o]}Generated#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 -        @rc << "#{@tr.last_generated}: #{Mx[:fa_underscore_o]}#{Time.now}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -        ocnm+=1; ocnv+=1 -        if @md.sisu_version[:version] -          @rc << "#{@tr.sisu_version}: #{Mx[:fa_underscore_o]}#{@md.sisu_version[:project]}#{Mx[:fa_underscore_c]}  #{Mx[:fa_underscore_o]}#{@md.sisu_version[:version]}#{Mx[:fa_underscore_c]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]}) #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -          ocnm+=1; ocnv+=1 -        end -        @rc << "#{@tr.ruby_version}: #{Mx[:fa_underscore_o]} #{@md.ruby_version}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" -      end -      meta << Mx[:br_page_new] << header1 << header4 -      meta << "Document Manifest @\n #{base_html}/#{@md.fn[:manifest]} #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" -      meta << "#{Mx[:fa_bold_o]}Dublin Core#{Mx[:fa_bold_c]} (DC) #{head_no_dc}" if @dc.length > 0 -      meta << "#{Mx[:fa_italics_o]}DC tags included with this document are provided here.#{Mx[:fa_italics_c]} #{head_no_dc_tag}" if @dc.length > 0 -      @dc.each { |x| meta << x } -      meta << "#{Mx[:fa_bold_o]}Version Information#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 -      if @cvs.length > 0 -        meta << "#{Mx[:fa_italics_o]}Note the version information provided here, is specific to the host site.#{Mx[:fa_italics_c]} #{head_no_rc_tag}" -        @cvs.each { |x| meta << x } -      end -      @rc.each { |x| meta << x } -      ## ENDNOTE RELATED endnote related -      meta << "\n#{Mx[:br_eof]}" -      meta=object_digest(meta) -    end -    def stamped(para,hash_class) -      @tuned=[] -      para=strip_clean_extra_spaces(para) -      digest_all=hash_class.hexdigest(para) # print "#{hash_class.name}: "; puts digest_all #length==32 or 64 -      stripped=strip_clean_of_markup(para) -      digest_strip=hash_class.hexdigest(stripped) -      unless para =~/#{Mx[:fa_o]}code#{Mx[:fa_c]}/ -        case para -        when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m -          en_and_para,en_and_para_digest=[],[] -          para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch -          para_plus_en=para.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) -          para_tail=if para =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m -            /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.+?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] -          else '' -          end -          para_plus_en << para_tail -          en_and_para_digest << endnote_digest(para_plus_en) -          para_new=en_and_para_digest.join(' ') -          @tuned << para_new + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? -        else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? -        end -      else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? -      end -      @tuned.join -    end -    def object_digest(data) -    # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes -    # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) -    # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) -    # [digests should not include other digests] -    # vim==/<[0-9a-f]\{#{@@dl}\}\(:[0-9a-f]\{#{@@dl}\}\)\?>/ -      require 'digest/md5' -      require 'digest/sha2' -      @tuned_file=[] -      data.compact! -      data.each do |para| -        para.strip! -        if para=~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}/ \ -        and para !~/#{Rx[:meta]}/ #test should not be necessary remove -          if @env.digest.type =~/sha256/ -            for hash_class in [ Digest::SHA256 ] -              @tuned_file << stamped(para,hash_class) -            end -          else -            for hash_class in [ Digest::MD5 ] -              @tuned_file << stamped(para,hash_class) -            end -          end -        else @tuned_file << para unless para.nil? -        end -      end -      @tuned_file=@tuned_file.flatten -      #use md5 or to create hash of each dal object including ocn, & add into to each dal object -    end -    def endnote_digest(data) -      para_bit=[] -      data.each do |en_plus| -        para_bit <<= case en_plus -        when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ -          if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ -            para_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4] -            stripped_en=strip_clean_of_markup(en_txt) -            digest_en_strip=if @env.digest.type =~/sha256/ -              Digest::SHA256.hexdigest(stripped_en) -            else -              Digest::MD5.hexdigest(stripped_en) -            end -            para_txt + en_open + en_txt + Mx[:id_o] + digest_en_strip + Mx[:id_c] + en_close -          else puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up -          end -        else en_plus -        end -      end -      para_bit.join -    end -    def strip_clean_extra_spaces(s)                                              # dal output tuned -      s=s.dup -      s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') -      s=s.gsub(/ [ ]+/,' ') -      s=s.gsub(/^ [ ]+/,'') -      s=s.gsub(/ [ ]+$/,'') -      s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') -      s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') -    end -    def strip_clean_of_markup(s)                                                 # used for digest, define rules, make same as in db clean -      #consider: <\/?[ib]>|<(?:\/ )?br>|<del>(.+?)<\/del> -      s=s.dup -      s=s.gsub(/(?:<\/?[ib]>|#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}|#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|^#{Mx[:lv_o]}[1-6]:\S+?#{Mx[:lv_c]}|#{Mx[:en_a_o]}\d+\s.+?#{Mx[:en_a_c]})/m,'') # markup and endnotes removed -                                                                                 #% same as db clean --> -      s=s.gsub(/<del>(.+?)<\/del>/,'DELETED(\1)')                             # deletions -      s=s.gsub(/<sup>(\d+)<\/sup>/,'[\1]') -      s=s.gsub(/(?: \\;)+/,' ') -      #s=s.gsub(/<!T[h]?¡.+?!>/,"[TABLE]\n")                                   # tables -      #s=s.gsub(/<!¡¡\d+(.+?)!>/,'\1')                                         # tables -      #s=s.gsub(/¡¡\d+¡/,' ')                                                  # tables -      #s=s.gsub(/¡/,' ')                                                       # tables tidy later -      #s=s.gsub(/<.+?>/,'') -      s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ')             # else image names found in search -      s=s.gsub(/\s\s+/,' ') -      s=s.strip -    end    end  end  __END__ diff --git a/lib/sisu/v0/dal_character_check.rb b/lib/sisu/v0/dal_character_check.rb new file mode 100644 index 00000000..8cee0a13 --- /dev/null +++ b/lib/sisu/v0/dal_character_check.rb @@ -0,0 +1,112 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end + +module SiSU_character_check +  class Check +    def initialize(data) +      @data=data +      @comment='%' +      @endnote_array=[] +    end +    def character_check_and_oldstyle_endnote_array +      require 'iconv' +      data=@data +      #reset +      @tuned_file,@endnote_array=[],[] +      endnote_no=1 +      data.each do |para| +        para.strip! +        para.gsub!(/^([12])~\?\s+/,'\1~ ')                                    #conditional header for incorporated document 2004w12 +        para.gsub!(/^[{~}]\s*$/,'') +        para.gsub!(/^#{@comment}.*/,'')                                       #remove comment and divider #% +        para.gsub!(/<~#>|~#\s*/,"#{Mx[:fa_o]}~##{Mx[:fa_c]}") +        para.gsub!(/-#\s*/,"#{Mx[:fa_o]}-##{Mx[:fa_c]}#{Mx[:fa_o]}~##{Mx[:fa_c]}") +        #para.gsub!(/(#\{{3} arch-tag:|0\{{3}~cvs)\s+/, "0{{~rcs ") #KEEP ... ENABLE WIDER USE OF REVISION CONTROL +        para.gsub!(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '); para.gsub!(/(~\{\s*)\s+/,'\1 ') +        para.gsub!(/ \/\//,"#{Mx[:br_line]}")                                           #added 2004w29 +        para.gsub!(/<br>/,"#{Mx[:br_line]}")                                            #needed by xml, xhtml etc. +        para.gsub!(/\t/,' ') +        para.gsub!(/\342\200\231/u,"'") #if para =~/’/  #Avoid #‘ ’ #“ ” +        para.gsub!(/�/u,' ') #watch, replace with char code +        para.gsub!(/·/u,'*') +        para.gsub!(/\\copy(?:right)?\b/,'©') +        para.gsub!(/\\trademark\b|\\tm\b/,'®') +        #non_utf8(para) +        para=para + "\n" +        unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ +          case para +          when /\^~/ # endnotes +                                                                                 #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ +            sub_para=para.dup +            @endnote_array << sub_para.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip +             endnote_no+=1 +            para=nil if para =~/\^~ .+/ #removes 'binary' endnote now in endnote array for later insertion +          end +        end +        @tuned_file << para unless para.nil? +      end +      @tuned_file=@tuned_file.flatten +      [@tuned_file,@endnote_array] +    end +  end +end +__END__ diff --git a/lib/sisu/v0/dal_doc_str.rb b/lib/sisu/v0/dal_doc_str.rb index 37e9be3c..ac7e2b49 100644 --- a/lib/sisu/v0/dal_doc_str.rb +++ b/lib/sisu/v0/dal_doc_str.rb @@ -59,8 +59,8 @@  =end  module SiSU_document_structure -  require "#{SiSU_lib}/dal_doc_str_tables" -  require "#{SiSU_lib}/dal_doc_str_code" +  require "#{SiSU_lib}/dal_doc_str_tables"                 # dal_doc_str_tables.rb +  require "#{SiSU_lib}/dal_doc_str_code"                   # dal_doc_str_code.rb    class Structure      def initialize(md,para)        @md,@para=md,para @@ -216,15 +216,15 @@ module SiSU_document_structure                    end                  else                    ocno+=1 -                  if para=~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/;                             ocnt+=1 #table +                  if para=~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/;                      ocnt+=1 #table                      ocn_dv,ocn_sp="o#{ocno}","t#{ocnt}" -                  elsif para=~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/;                        ocnc+=1 #code block +                  elsif para=~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/;                ocnc+=1 #code block                      ocn_dv,ocn_sp="o#{ocno}","c#{ocnc}" -                  elsif para=~/^#{Mx[:gr_o]}(?:group|alt|verse)#{Mx[:gr_c]}/;         ocng+=1 #group, poem +                  elsif para=~/^#{Mx[:gr_o]}(?:group|alt|verse)#{Mx[:gr_c]}/; ocng+=1 #group, poem                      ocn_dv,ocn_sp="o#{ocno}","g#{ocng}" -                  elsif para=~/\{\S+?\.(?:png|jpg|gif)\s+/m;     ocni+=1 #image +                  elsif para=~/#{Mx[:lnk_o]}\S+?\.(?:png|jpg|gif)\s+/m;       ocni+=1 #image                      ocn_dv,ocn_sp="o#{ocno}","i#{ocni}" -                  else                                           ocnp+=1 #paragraph +                  else                                                        ocnp+=1 #paragraph                      ocn_dv,ocn_sp="o#{ocno}","p#{ocnp}"                    end                  end diff --git a/lib/sisu/v0/dal_doc_str_code.rb b/lib/sisu/v0/dal_doc_str_code.rb index 82ada040..27e20d51 100644 --- a/lib/sisu/v0/dal_doc_str_code.rb +++ b/lib/sisu/v0/dal_doc_str_code.rb @@ -170,7 +170,7 @@ module SiSU_document_structure_code        data.each do |line|          if line =~/\S/ \          and line !~/^code\{|^\}code|#{Mx[:gr_o]}code.+/ -          line.gsub!(/\s\s/,'  ') +          line.gsub!(/\s\s/,"#{Mx[:nbsp]}#{Mx[:nbsp]}")            line.gsub!(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # try sort for texpdf special case            if line =~/(?:https?|file|ftp):\/\/\S+$/              line.gsub!(/$/," #{Mx[:br_nl]}") diff --git a/lib/sisu/v0/dal_endnotes.rb b/lib/sisu/v0/dal_endnotes.rb new file mode 100644 index 00000000..47f872ec --- /dev/null +++ b/lib/sisu/v0/dal_endnotes.rb @@ -0,0 +1,132 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_endnotes +  class Endnotes +    def initialize(md,data,endnote_array=nil) +      @md,@data,@endnote_array=md,data,endnote_array +      @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 +    end +    def endnotes +      data=@data +      @tuned_file=[] +      endnote_no,endnote_ref=1,1 +                                                                                 #% endnote work zone +      data.each do |para| +                                                                                 # manually numbered endnotes <!e(\d)!> <!e_(\d)!> --> +        if @md.mod.inspect =~/--no-asterisk|--no-annotate/ +          para.gsub!(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') +        end +        if @md.mod.inspect =~/--no-dagger|--no-annotate/ +          para.gsub!(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') +        end +        unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ +          case para +                                                                                 # auto-numbered endnotes <!e!> <!e_!> --> +          when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ +            para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1')                                     # required 2003w31 +            word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) +            word_mode=endnote_call_number(word_mode) +            para=word_mode.join(' ') +            endnote_ref+=1 +          when /~\^(?:\s|$)|<:e>/ +                                                                                 #%Note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop) +            word_mode=para.scan(/#{Mx[:gr_o]}group#{Mx[:gr_c]}\n|\n#{Mx[:gr_o]}group-end#{Mx[:gr_c]}|\S+/m) +            word_mode=endnote_call_number(word_mode) +            para=word_mode.join(' ') +            endnote_ref+=1 +          end +        end +        @tuned_file << para +      end +      @endnote_counter,@endnote_counter_asterisk,@endnote_counter_dag=1,1,1 +      @tuned_file=@tuned_file.flatten +    end +    def endnote_call_number(data) +      data.each do |word| +        unless data =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ +          case word +          when /#{Mx[:en_a_o]}/ +            unless word =~/#{Mx[:en_a_o]}[*+]+/ +              word.gsub!(/#{Mx[:en_a_o]}/,"#{Mx[:en_a_o]}#{@endnote_counter} ") +              @endnote_counter+=1 +            end +          when /#{Mx[:en_b_o]}/ +            if word =~/#{Mx[:en_b_o]}[+]/ +              word.gsub!(/#{Mx[:en_b_o]}[+]/,"#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") +              @endnote_counter_dag+=1 +            else +              word.gsub!(/#{Mx[:en_b_o]}[*]?/,"#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") +              @endnote_counter_asterisk+=1 +            end +          when /~\^|<:e>/ +            if @endnote_array +              word.gsub!(/~\^|<:e>/,"#{@endnote_array[@endnote_counter-1]}") +              @endnote_counter+=1 +            end +          end +        end +      end +    end +  end +end +__END__ + diff --git a/lib/sisu/v0/dal_expand_insertions.rb b/lib/sisu/v0/dal_expand_insertions.rb new file mode 100644 index 00000000..17362092 --- /dev/null +++ b/lib/sisu/v0/dal_expand_insertions.rb @@ -0,0 +1,200 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_insertions +  class Insertions +    def initialize(data) +      @data=data +    end +    def output_filetypes_in_cmd(cmd_shortcut,source=nil) +      #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used +      cf_defaults=SiSU_Env::Info_processing_flag.new +      cmd_list=case cmd_shortcut.inspect +      when /0/; cf_defaults.cf_0 +      when /1/; cf_defaults.cf_1 +      when /2/; cf_defaults.cf_2 +      when /3/; cf_defaults.cf_3 +      when /4/; cf_defaults.cf_4 +      when /5/; cf_defaults.cf_5 +      end +      file_type_names={} +      file_type_names[:gen],file_type_names[:src]=[],[] +      file_type_names[:gen] <<= if cmd_list =~ /y/; 'sisu_manifest.html' +      end +      file_type_names[:gen] <<= if cmd_list =~ /h/; ['toc.html', 'doc.html'] +      end +      file_type_names[:gen] <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] +      end +      #file_type_names[:gen] <<= if cmd_list =~ /i/; 'manpage.1' +      #end +      file_type_names[:gen] <<= if cmd_list =~ /o/; 'opendocument.odt' +      end +      file_type_names[:gen] <<= if cmd_list =~ /b/; 'scroll.xhtml' +      end +      file_type_names[:gen] <<= if cmd_list =~ /x/; 'sax.xml' +      end +      file_type_names[:gen] <<= if cmd_list =~ /X/; 'dom.xml' +      end +      file_type_names[:gen] <<= if cmd_list =~ /a/; 'plain.txt' +      end +      file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt' +      end +      file_type_names[:gen] <<= if cmd_list =~ /w/; 'concordance.html' +      end +      file_type_names[:gen] <<= if cmd_list =~ /N/; 'digest.txt' +      end +      file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; source +      end +      file_type_names[:src] <<= if cmd_shortcut =~ /S/; "#{source}.zip" +      end +      file_type_names[:gen]=file_type_names[:gen].flatten +      file_type_names[:src]=file_type_names[:src].flatten +      file_type_names +    end +    def expand_insertions? +      data=@data +      tuned_file,tuned_file_tmp=[],[] +      data.each do |para| +        if para !~/^%+\s/ \ +        and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ +          txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil +          @u=SiSU_Env::Info_env.new.url +          if defined? @u.remote +            if para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/m +              pre,txt,cmd,source,url_dir,note="#{$1.strip} ",$2,$3,$4,$5,$6 +            elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/ +              pre,txt,cmd,source,url_dir,note='',$1,$2,$3,$4,$5 +            end +            manifest="#{pre}{#{txt} }#{@u.remote}/#{url_dir}/toc.html#{note}\n\n" +          else +            puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" +            if para =~/\{(?:~\^\s+)?(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ +              txt,cmd,url_dir,note=$1,$2,$3,$4 +              manifest="{ #{txt} }../#{url_dir}/toc.html#{note}\n\n" +            end +          end +          tuned_file_tmp << manifest +          output_filetypes=output_filetypes_in_cmd(cmd,source) +          output_filetypes[:gen].each do |o_f| +            describe = case o_f +            when /sisu_manifest.html/; '~^ document manifest' +            when /toc.html/;           ' html, segmented text' +            when /doc.html/;           ' html, scroll, document in one' +            when /landscape.pdf/;      ' pdf, landscape' +            when /portrait.pdf/;       ' pdf, portrait' +            when /opendocument.odt/;   ' odf:odt, open document text' +            when /scroll.xhtml/;       ' xhtml scroll' +            when /sax.xml/;            ' xml, sax' +            when /dom.xml/;            ' xml, dom' +            when /plain.txt/;          ' plain text utf-8' +            #when /manpage.1/;          ' man, 1' +            when /wiki.txt/;           ' wiki text' +            when /concordance.html/;   ' concordance' +            when /digest.txt/;         ' dcc, document content certificate (digests)' +            else nil +            end +            if describe +              tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry +                if describe =~/^~\^ / +                  "#{Mx[:nbsp]*4} {#{describe} }#{@u.remote}/#{url_dir}/#{o_f} " +                else +                  "#{Mx[:nbsp]*4} { #{describe} }#{@u.remote}/#{url_dir}/#{o_f} " +                end +              else +                if describe =~/^~\^ / +                  "#{Mx[:nbsp]*4} {#{describe} }../#{url_dir}/#{o_f} " +                else "#{Mx[:nbsp]*4} { #{describe} }../#{url_dir}/#{o_f} " +                end +              end +            end +          end +          output_filetypes[:src].each do |o_f| +            describe=case o_f +            when /#{source}\.zip/;     ' markup source (zipped) pod' +            when /#{source}/;          ' markup source text' +            else nil +            end +            if describe +              tuned_file_tmp << if @u.remote +                x=if describe =~/zip/ +                  "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_pod}/#{o_f} " +                else "#{Mx[:nbsp]*4} {#{describe} }#{@u.src_txt}/#{o_f} " +                end +              else +                x=if describe =~/zip/ +                  "#{Mx[:nbsp]*4} { #{describe} }../pod/#{o_f} " +                else "#{Mx[:nbsp]*4} { #{describe} }../zip/#{o_f} " +                end +              end +            end +          end +          tuned_file << 'group{' << tuned_file_tmp.join("\n") << '}group' +          #tuned_file << 'group{' << tuned_file_tmp.join("\n").strip << '}group' +          tuned_file_tmp=[] +        else tuned_file << para +        end +      end +      tuned_file +    end +  end +end +__END__ + diff --git a/lib/sisu/v0/dal_hash_digest.rb b/lib/sisu/v0/dal_hash_digest.rb new file mode 100644 index 00000000..7588bd47 --- /dev/null +++ b/lib/sisu/v0/dal_hash_digest.rb @@ -0,0 +1,176 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end + +module SiSU_hash +  class Object_digest +    def initialize(md,data,env=nil) +      @md,@data,@env=md,data,env +      @env ||=SiSU_Env::Info_env.new(@md.fns) +    end +    def object_digest +    # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes +    # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) +    # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) +    # [digests should not include other digests] +    # vim==/<[0-9a-f]\{#{@@dl}\}\(:[0-9a-f]\{#{@@dl}\}\)\?>/ +      require 'digest/md5' +      require 'digest/sha2' +      data=@data +      @tuned_file=[] +      data.compact! +      data.each do |para| +        para.strip! +        if para=~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}/ \ +        and para !~/#{Rx[:meta]}/ #test should not be necessary remove +          if @env.digest.type =~/sha256/ +            for hash_class in [ Digest::SHA256 ] +              @tuned_file << stamped(para,hash_class) +            end +          else +            for hash_class in [ Digest::MD5 ] +              @tuned_file << stamped(para,hash_class) +            end +          end +        else @tuned_file << para unless para.nil? +        end +      end +      @tuned_file=@tuned_file.flatten +      #use md5 or to create hash of each dal object including ocn, & add into to each dal object +    end +    def endnote_digest(data) +      para_bit=[] +      data.each do |en_plus| +        para_bit <<= case en_plus +        when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ +          if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ +            para_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4] +            stripped_en=strip_clean_of_markup(en_txt) +            digest_en_strip=if @env.digest.type =~/sha256/ +              Digest::SHA256.hexdigest(stripped_en) +            else +              Digest::MD5.hexdigest(stripped_en) +            end +            para_txt + en_open + en_txt + Mx[:id_o] + digest_en_strip + Mx[:id_c] + en_close +          else puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up +          end +        else en_plus +        end +      end +      para_bit.join +    end +    def stamped(para,hash_class) +      @tuned=[] +      para=strip_clean_extra_spaces(para) +      digest_all=hash_class.hexdigest(para) # print "#{hash_class.name}: "; puts digest_all #length==32 or 64 +      stripped=strip_clean_of_markup(para) +      digest_strip=hash_class.hexdigest(stripped) +      unless para =~/#{Mx[:fa_o]}code#{Mx[:fa_c]}/ +        case para +        when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m +          en_and_para,en_and_para_digest=[],[] +          para.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch +          para_plus_en=para.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) +          para_tail=if para =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m +            /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.*?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] +            #/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+(.+?#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]})/m.match(para)[1] +          else '' +          end +          para_plus_en << para_tail +          en_and_para_digest << endnote_digest(para_plus_en) +          para_new=en_and_para_digest.join(' ') +          @tuned << para_new + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? +        else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? +        end +      else @tuned << para + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless para.nil? +      end +      @tuned.join +    end +    def strip_clean_extra_spaces(s)                                              # dal output tuned +      s=s.dup +      s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ +      s=s.gsub(/ [ ]+/,' ') +      s=s.gsub(/^ [ ]+/,'') +      s=s.gsub(/ [ ]+$/,'') +      s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') +      s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') +    end +    def strip_clean_of_markup(s)                                                 # used for digest, define rules, make same as in db clean +      #consider: <\/?[ib]>|<(?:\/ )?br>|<del>(.+?)<\/del> +      s=s.dup +      s=s.gsub(/(?:<\/?[ib]>|#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}|#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|^#{Mx[:lv_o]}[1-6]:\S+?#{Mx[:lv_c]}|#{Mx[:en_a_o]}\d+\s.+?#{Mx[:en_a_c]})/m,'') # markup and endnotes removed +                                                                                 #% same as db clean --> +      s=s.gsub(/<del>(.+?)<\/del>/,'DELETED(\1)')                             # deletions +      s=s.gsub(/<sup>(\d+)<\/sup>/,'[\1]') +      s=s.gsub(/(?:#{Mx[:nbsp]})+/,' ') +      #s=s.gsub(/<!T[h]?¡.+?!>/,"[TABLE]\n")                                   # tables +      #s=s.gsub(/<!¡¡\d+(.+?)!>/,'\1')                                         # tables +      #s=s.gsub(/¡¡\d+¡/,' ')                                                  # tables +      #s=s.gsub(/¡/,' ')                                                       # tables tidy later +      #s=s.gsub(/<.+?>/,'') +      s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ')             # else image names found in search +      s=s.gsub(/\s\s+/,' ') +      s=s.strip +    end +  end +end +__END__ + diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb new file mode 100644 index 00000000..d7d5223e --- /dev/null +++ b/lib/sisu/v0/dal_idx.rb @@ -0,0 +1,322 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_book_index +  class Book_index +    def initialize(md,data,env=nil) +      @md,@data,@env=md,data,env +      @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ +      #@rgx_idx=/\s*#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ +      @rgx_idx_ocn_init=/#{Mx[:idx_o]}(.+?)#{Mx[:idx_c]}\s*#{Mx[:id_o]}~(\d+)\S+?#{Mx[:id_c]}/ +      @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ +      @rgx_idx_ocn=/(.+?)~(\d+)/ +      @rxp_lv1=/^#{Mx[:lv_o]}1:/ +      @rxp_lv2=/^#{Mx[:lv_o]}2:/ +      @rxp_lv3=/^#{Mx[:lv_o]}3:/ +      @rxp_seg=/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/ +      @rxp_to=Regexp.new("#{Mx[:id_o]}~(\\d+);(?:[oh]|[0-6]:)\\d+;\\w\\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|#{Mx[:id_o]}\S+?#{Mx[:id_c]}$") +      @env ||=SiSU_Env::Info_env.new(@md.fns) +    end +    def indexing_song +      data=@data +      data,sisu_markup_idx,html_idx=extract_book_index(data) +      data=clean_and_insert_index(data,sisu_markup_idx) +      [data,sisu_markup_idx,html_idx] +    end +    def extract_book_index(data) +      tuned_file=[] +      idx_array=[] +      data.each do |para| +        if para =~@rxp_seg; @seg=para[@rxp_seg,1] +        end +        idx_array << @rgx_idx_ocn_init.match(para)[0].gsub(@rgx_idx_ocn_init,"\\1~\\2~#{@seg}") if para =~ @rgx_idx_ocn_init +        tuned_file << para if para +      end +      idx_array=construct_idx_array(idx_array) if idx_array.length > 0 +      if idx_array.length > 0 +        the_idx=construct_book_index(idx_array) +        #screen_print(the_idx) if @md.cmd.inspect =~/V/ +        sisu_markup_idx,html_idx=nil,nil +        if @md.book_index +          idx=index(the_idx) +          output_html_idx(idx[:html]) +          html_idx=idx[:html] +          sisu_markup_idx=idx[:sst] +        end +      end +      [tuned_file,sisu_markup_idx,html_idx] +    end +    def construct_idx_array(idx_array) +      idx_lst=[] +      idx_array.each do |idx| +        idx_list,ocn,seg=@rgx_idx_ocn_seg.match(idx)[1..3] +        idx_lst <<=if idx_list =~/;/ +          g=idx_list.scan(/[^;]+/) +          idxl=[] +          g.each do |i| +            i.strip! +            idxl << { :rough_idx => i, :ocn => ocn, :seg => seg } +          end +          idxl +        else { :rough_idx => idx_list, :ocn => ocn, :seg => seg } +        end +      end +      idx_lst.flatten! +      idx_lst +    end +    def construct_book_index(idx_array) +      @the_idx={} +      idx_array.each do |idx| +        idx_lst=idx[:rough_idx].scan(/[^|:]+/) +        idx_lst[0].strip! +        if idx_lst[0] =~/.+?\+\d+/ +          use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] +        else use=idx_lst[0] +        end +        use=use[0].chr.capitalize + use[1,use.length] +        @the_idx[use]={} unless @the_idx[use] and defined? @the_idx[use] +        idx_lst.each do |i| +          i.strip! +          i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ +          x=if idx_lst.length == 1 or idx_lst[0].gsub(/\+\d+/,'') == i +            @the_idx[use]['a1']=[] unless @the_idx[use]['a1'] and defined? @the_idx[use]['a1'] +            x=if r +              @the_idx[use]['a1'] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", :seg => idx[:seg] } +              "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" +            else +              @the_idx[use]['a1'] << { :ocn => idx[:ocn], :seg => idx[:seg] } +              "#{i} #{idx[:ocn]}" +            end +          else +            @the_idx[use]['b1']={} unless @the_idx[use]['b1'] and defined? @the_idx[use]['b1'] +            @the_idx[use]['b1'][i]=[] unless @the_idx[use]['b1'][i] and defined? @the_idx[use]['b1'][i] +            x=if r +              @the_idx[use]['b1'][i] << { :ocn => idx[:ocn], :range => "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", :seg => idx[:seg] } +              "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" +            else +              @the_idx[use]['b1'][i] << { :ocn => idx[:ocn], :seg => idx[:seg] } +              "#{idx_lst[0]}:#{i} #{idx[:ocn]}" +            end +          end +        end +      end +      the_idx=@the_idx.sort +      #p the_idx; p '-----' +      the_idx +    end +    def index(the_idx) +      @x=1 +      @idx={} +      @idx[:sst],@idx[:html]=[],[] +      @idx[:sst] << "\n\n#{Mx[:br_page_new]}" +      @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" +      @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}" +      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] +      @idx[:html] << '<p>' +      alph.each {|x| @idx[:html] << %{<a href="##{x}">#{x}</a>, }} +      @idx[:html] << '</p>' +      letter=alph.shift +      @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="A">A</a></p>} +      the_idx.each do |i| +        i.each do |x| +          if x.class == String +            f=/^(\S)/.match(x)[1] +            if letter < f +              while letter < f +                if alph.length > 0 +                  letter=alph.shift +                  @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="#{letter}">#{letter}</a></p>} +                else break +                end +              end +            end +            @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } +            aname=x.gsub(/\s+/,'_') +            @idx[:html] << %{\n<p class="book_index_lev1"><a name="#{aname}"><b>#{x}</b></a>, } +            @o=@idx[:sst].index(@idx[:sst].last) #@o=@idx[:sst].length - 1 +            @q=@idx[:html].index(@idx[:html].last) #@o=@idx[:html].length - 1 +            print "\n" + x + ', ' if @md.cmd =~/V/ +          elsif x.class == Array +            p 'array error? -->' +            print x +          elsif x.class == Hash +            if x['a1'].class == Array +              x['a1'].each do |a| +                if a[:range] +                  @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } +                  @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, } +                  print a[:range] + ', ' if @md.cmd =~/V/ +                elsif a[:ocn] +                  @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{a[:seg]}.html##{a[:ocn]}, } +                  @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, } +                  print a[:ocn] + ', ' if @md.cmd =~/V/ +                else p 'error' +                end +              end +              @idx[:html][@q]=@idx[:html][@q] + '</p>' +            end +            if x['b1'] +              m=x['b1'] +              m=m.sort +              m.each do |k,y| +                if k !~/a1/ +                  @idx[:sst][@o]=@idx[:sst][@o] + %{#{k}, } +                  @idx[:html][@q]=@idx[:html][@q] + %{\n<p class="book_index_lev2">#{k}, } +                  print "\n\t" + k + ', ' if @md.cmd =~/V/ +                  y.each do |z| +                    if z[:range] +                      @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } +                      @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, } +                      print z[:range] + ', ' if @md.cmd =~/V/ +                    elsif z[:ocn] +                      @idx[:sst][@o]=@idx[:sst][@o] + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{@env.url.root}/#{@md.fnb}/#{z[:seg]}.html##{z[:ocn]}, } +                      @idx[:html][@q]=@idx[:html][@q] + %{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, } +                      print z[:ocn] + ', ' if @md.cmd =~/V/ +                    else p 'error' +                    end +                  end +                  @idx[:html][@q]=@idx[:html][@q] + '</p>' +                end +              end +            end +            @idx[:sst][@o]=@idx[:sst][@o] + " #{Mx[:id_o]}~0;0:0;x#{@x}#{Mx[:id_c]}" +            @x +=1 +          end +        end +      end +      print "\n" if @md.cmd =~/V/ +      @idx +    end +    def screen_print(the_idx) +      the_idx.each do |i| +        i.each do |x| +          if x.class == String +            print "\n" + x + ', ' +          elsif x.class == Array +            p 'array error? -->' +            print x +          elsif x.class == Hash +            if x['a1'].class == Array +              x['a1'].each do |a| +                if a[:range] +                  print a[:range] + ', ' +                elsif a[:ocn] +                  print a[:ocn] + ', ' +                else p 'error' +                end +              end +            end +            if x['b1'] +              m=x['b1'] +              m=m.sort +              m.each do |k,y| +                if k !~/a1/ +                  print "\n\t" + k + ', ' +                  #p y +                  y.each do |z| +                    if z[:range] +                      print z[:range] + ', ' +                    elsif z[:ocn] +                      print z[:ocn] + ', ' +                    else p 'error' +                    end +                  end +                end +              end +            end +          end +        end +      end +    end +    def output_html_idx(html_idx) +      if @md.book_index +        path="#{@env.path.output}/#{@md.fnb}" +        Dir.mkdir(path) unless FileTest.directory?(path) +        html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w') +        #puts "#{path}/#{@md.fn[:book_index]}" +        html_idx.each {|x| html_index_file << x } +        html_index_file.close +      end +    end +    def clean_and_insert_index(data,sisu_markup_idx) +      tuned_file=[] +      data.each do |para| +        para.gsub!(/\n*#{@rgx_idx}/m,'') +        tuned_file << para +        if para =~/#{Mx[:br_endnotes]}/ and sisu_markup_idx +          sisu_markup_idx.each do |idx| +            tuned_file << idx +          end +        end +      end +      tuned_file +    end +    def clean_index(data) +      tuned_file=[] +      data.each do |para| +        para.gsub!(/\n*#{@rgx_idx}/m,'') +        tuned_file << para +      end +      tuned_file +    end +  end +end +__END__ diff --git a/lib/sisu/v0/dal_images.rb b/lib/sisu/v0/dal_images.rb new file mode 100644 index 00000000..75fa333c --- /dev/null +++ b/lib/sisu/v0/dal_images.rb @@ -0,0 +1,125 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_images +  class Images +    def initialize(md,data) +      @md,@data=md,data +    end +    def images +      data=@data +      tuned_file=[] +      @rmgk=false +      if SiSU_Env::Info_settings.new.program?('rmagick'); @rmgk=SiSU_Env::Load.new('RMagick').prog +      else tell=SiSU_Screen::Ansi.new(@md.cmd,'use of RMagick is not enabled in sisurc.yml') +        tell.warn if @md.cmd =~/[vVM]/ +      end +      data.each do |para| +        para.strip! +        if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ +          if para !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+\s+/ +            m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ +            if @rmgk +              imgs=para.scan(m).flatten +              images=imgs.each do |image| +                dir=SiSU_Env::Info_env.new(@md.fns) +                path_image=[dir.path.image_source_local_tex,dir.path.image_source_remote_tex,dir.path.image_source_tex] +                image_path=nil +                path_image.each do |image_path| +                  break if FileTest.exist?("#{image_path}/#{image}") +                end +                if FileTest.exist?("#{image_path}/#{image}") +                  img=Magick::ImageList.new("#{image_path}/#{image}") +                  img_col,img_row=img.columns,img.rows +                  if img_col > img_row                                               #landscape +                    if img_col> 640 #480 +                      img_col=640 #480 +                      img_row=((1.00*img_col/img.columns)*img.rows).round +                    end +                  else                                                               #portrait +                    if img_col> 640 #480 +                      img_col=640 #480 +                      img_row=((1.00*img_col/img.columns)*img.rows).round +                    end +                    if img_row > 640 +                      img_row=640 +                      img_col=((1.00*img_row/img.rows)*img.columns).round +                    end +                  end +                  para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") +                else para.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') +                end +              end +            else +              images=para.scan(m) do |image| +                tell=SiSU_Screen::Ansi.new(@md.cmd,'where image dimensions have not been provided RMagick is required',image) +                tell.warn #unless @opt.cmd =~/q/ +              end +            end +          end +        end +        para.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if para =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/ +        tuned_file << para unless para.nil? +      end +      tuned_file +    end +  end +end +__END__ diff --git a/lib/sisu/v0/dal_metadata.rb b/lib/sisu/v0/dal_metadata.rb new file mode 100644 index 00000000..900c5495 --- /dev/null +++ b/lib/sisu/v0/dal_metadata.rb @@ -0,0 +1,228 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_metadata +  class Metadata +    def initialize(md,data) +      @md,@data=md,data +      l=SiSU_Env::Standardise_language.new.file_to_language(md.fns) +      language=l[:l] +      @tr=SiSU_Translate::Source.new(md,language) +    end +    def metadata +      data=@data +      meta,@dc,@rc,@cvs,dctitle,add=Array.new(6){[]} +      dir=SiSU_Env::Info_env.new(@md.fns) +      base_html="#{dir.url.root}/#{@md.fnb}" +      ocnm=ocnd=ocnv=0 +      ocnm+=1 +      header1="\n#{Mx[:lv_o_1]}meta#{Mx[:lv_c]}Document Information (metadata) #{Mx[:id_o]}~0;0:0;m#{ocnm}#{Mx[:id_c]}" +      ocnm+=1 +      header4="\n#{Mx[:lv_o_4]}metadata#{Mx[:lv_c]}Metadata #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" +      ocnm+=1; ocnd+=1 +      head_no_dc="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +      ocnm+=1; ocnd+=1 +      head_no_dc_tag="#{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +      data.each do |para| +        case para +        when /^#{Mx[:meta_o]}(title|creator|author|translator|translated_by|illustrator|illustrated_by|prepared_by|digitized_by|description|publisher|contributor|date\.created|date\.issued|date\.available|date\.valid|date\.modified|date|type|format|rights|identifier|source|language)#{Mx[:meta_c]}/i +          m=$1 +          ocnm+=1; ocnd+=1 +          @dc << case para +          when /^#{Mx[:meta_o]}title#{Mx[:meta_c]}/ +            "\n#{@tr.dc_title}: #{Mx[:fa_underscore_o]}#{@md.dc_title}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}(?:creator|author)#{Mx[:meta_c]}/ +            "\n#{@tr.creator}: #{Mx[:fa_underscore_o]}#{@md.dc_creator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /#{Mx[:meta_o]}(?:translator|translated_by)#{Mx[:meta_c]}/ +            "\n#{@tr.translator}: #{Mx[:fa_underscore_o]}#{@md.translator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}(?:illustrator|illustrated_by)#{Mx[:meta_c]}/ +            "\n#{@tr.illustrator}: #{Mx[:fa_underscore_o]}#{@md.illustrator}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}prepared_by#{Mx[:meta_c]}/ +            "\n#{@tr.prepared_by}: #{Mx[:fa_underscore_o]}#{@md.prepared_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}digitized_by#{Mx[:meta_c]}/ +            "\n#{@tr.digitized_by}: #{Mx[:fa_underscore_o]}#{@md.digitized_by}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}description#{Mx[:meta_c]}/ +            "\n#{@tr.description}: #{Mx[:fa_underscore_o]}#{@md.dc_description}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}subject#{Mx[:meta_c]}/ +            "\n#{@tr.subject}: #{Mx[:fa_underscore_o]}#{@md.dc_subject}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}abstract#{Mx[:meta_c]}/ +            "\n#{@tr.abstract}: #{Mx[:fa_underscore_o]}#{@md.dc_abstract}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}publisher#{Mx[:meta_c]}/ +            "\n#{@tr.publisher}: #{Mx[:fa_underscore_o]}#{@md.dc_publisher}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}contributor#{Mx[:meta_c]}/ +            "\n#{@tr.contributor}: #{Mx[:fa_underscore_o]}#{@md.dc_contributor}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}date.created#{Mx[:meta_c]}/ +            "\n#{@tr.date_created}: #{Mx[:fa_underscore_o]}#{@md.dc_date_created}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}date.issued#{Mx[:meta_c]}/ +            "\n#{@tr.date_issued}: #{Mx[:fa_underscore_o]}#{@md.dc_date_issued}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}date.available#{Mx[:meta_c]}/ +            "\n#{@tr.date_available}: #{Mx[:fa_underscore_o]}#{@md.dc_date_available}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}date.modified#{Mx[:meta_c]}/ +            "\n#{@tr.date_modified}: #{Mx[:fa_underscore_o]}#{@md.dc_date_modified}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}date.valid#{Mx[:meta_c]}/ +            "\n#{@tr.date_valid}: #{Mx[:fa_underscore_o]}#{@md.dc_date_valid}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}date#{Mx[:meta_c]}/ +            "\n#{@tr.date}: #{Mx[:fa_underscore_o]}#{@md.dc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}type#{Mx[:meta_c]}/ +            "\n#{@tr.type}: #{Mx[:fa_underscore_o]}#{@md.dc_type}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}format#{Mx[:meta_c]}/ +            "\n#{@tr.format}: #{Mx[:fa_underscore_o]}#{@md.dc_format}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}rights#{Mx[:meta_c]}/ +            "\n#{@tr.rights}: #{Mx[:fa_underscore_o]}#{@md.dc_rights}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}identifier#{Mx[:meta_c]}/ +            "\n#{@tr.identifier}: #{Mx[:fa_underscore_o]}#{@md.dc_identifier}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}source#{Mx[:meta_c]}/ +            "\n#{@tr.source}: #{Mx[:fa_underscore_o]}#{@md.dc_source}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}language#{Mx[:meta_c]}/ +            "\n#{@tr.language}: #{Mx[:fa_underscore_o]}#{@md.dc_language}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}language.original#{Mx[:meta_c]}/ +            "\n#{@tr.language_original}: #{Mx[:fa_underscore_o]}#{@md.language_original}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}relation#{Mx[:meta_c]}/ +            "\n#{@tr.relation}: #{Mx[:fa_underscore_o]}#{@md.dc_relation}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}coverage#{Mx[:meta_c]}/ +            "\n#{@tr.coverage}: #{Mx[:fa_underscore_o]}#{@md.dc_coverage}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}keywords#{Mx[:meta_c]}/ +            "\n#{@tr.keywords}: #{Mx[:fa_underscore_o]}#{@md.keywords}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}comments#{Mx[:meta_c]}/ +            "\n#{@tr.comments}: #{Mx[:fa_underscore_o]}#{@md.comments}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}cls_loc#{Mx[:meta_c]}/ +            "\n#{@cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}cls_dewey#{Mx[:meta_c]}/ +            "\n#{@tr.cls_dewey}: #{Mx[:fa_underscore_o]}#{@md.cls_dewey}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}(?:cls_gutenberg|cls_pg)#{Mx[:meta_c]}/ +            "\n#{@tr.cls_gutenberg}: #{Mx[:fa_underscore_o]}#{@md.cls_gutenberg}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +            #"\n#{@tr.cls_gutenberg}: <u>#{@md.cls_pg}</u> #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}cls_isbn#{Mx[:meta_c]}/ +            "\n#{@tr.cls_isbn}: #{Mx[:fa_underscore_o]}#{@md.cls_isbn}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}prefix(?:_a)?#{Mx[:meta_c]}/ +            "\n#{@tr.prefix_a}: #{Mx[:fa_underscore_o]}#{@md.prefix_a}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          when /^#{Mx[:meta_o]}prefix_b#{Mx[:meta_c]}/ +            "\n#{@tr.prefix_b}: #{Mx[:fa_underscore_o]}#{@md.prefix_b}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}" +          else para.gsub(/^#{Mx[:meta_o]}(#{m})\s+(.+)/m,"\n#{m.capitalize}: #{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};d#{ocnd}#{Mx[:id_c]}") +          end +        end +      end +      ocnm+=1; ocnv+=1 +      head_no_rc="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +      ocnm+=1; ocnv+=1 +      head_no_rc_tag="#{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +      data.each do |para| +        case para +        when /^0~(?:cvs|rcs)\+\s+/ #note the + sign to turn on use of cvs id +          ocnm+=1; ocnv+=1 +          @cvs << "#{@tr.sc_number}: #{Mx[:fa_underscore_o]}#{@md.sc_number}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +          ocnm+=1; ocnv+=1 +          @cvs << "#{@tr.sc_date}: #{Mx[:fa_underscore_o]}#{@md.sc_date}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +          ocnm+=1; ocnv+=1 +          @cvs << "CVS/RCS time: #{Mx[:fa_underscore_o]}#{@md.sc_time}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +          ocnm+=1; ocnv+=1 +        when /^0~cvs[+\s]/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP +        when /^0~cvs\s+/ #enable pattern above instead if you wish the default to be to include cvs tags from all documents KEEP +        end +      end +      if true #default version information +        ocnm+=1; ocnv+=1 +        if @md.sc_filename \ +        and @md.sc_filename.length > 3 +          @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.sc_filename}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +        else @rc << "#{@tr.sourcefile}: #{Mx[:fa_underscore_o]}#{@md.fns}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +        end +        ocnm+=1; ocnv+=1 +        if @md.file_encoding \ +        and @md.file_encoding.length > 3  #translate +          @rc << "Filetype: #{Mx[:fa_underscore_o]}#{@md.file_encoding}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +        end +        ocnm+=1; ocnv+=1 +        if @md.dgst #change. enable by default +          @rc << "#{@tr.sourcefile_digest}, #{@md.dgst[0]} #{Mx[:fa_underscore_o]}#{@md.dgst[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +          ocnm+=1; ocnv+=1 +        end +        if @md.dgst_skin #change. enable by default +          @rc << "Skin_Digest: #{@md.dgst_skin[0]} #{Mx[:fa_underscore_o]}#{@md.dgst_skin[1]}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +          ocnm+=1; ocnv+=1 +        end +        @rc << "#{Mx[:fa_bold_o]}Generated#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 +        @rc << "#{@tr.last_generated}: #{Mx[:fa_underscore_o]}#{Time.now}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +        ocnm+=1; ocnv+=1 +        if @md.sisu_version[:version] +          @rc << "#{@tr.sisu_version}: #{Mx[:fa_underscore_o]}#{@md.sisu_version[:project]}#{Mx[:fa_underscore_c]}  #{Mx[:fa_underscore_o]}#{@md.sisu_version[:version]}#{Mx[:fa_underscore_c]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]}) #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +          ocnm+=1; ocnv+=1 +        end +        @rc << "#{@tr.ruby_version}: #{Mx[:fa_underscore_o]} #{@md.ruby_version}#{Mx[:fa_underscore_c]} #{Mx[:id_o]}~0;m#{ocnm};v#{ocnv}#{Mx[:id_c]}" +      end +      meta << Mx[:br_page_new] << header1 << header4 +      meta << "Document Manifest @\n #{base_html}/#{@md.fn[:manifest]} #{Mx[:id_o]}~0;m#{ocnm};m#{ocnm}#{Mx[:id_c]}" +      meta << "#{Mx[:fa_bold_o]}Dublin Core#{Mx[:fa_bold_c]} (DC) #{head_no_dc}" if @dc.length > 0 +      meta << "#{Mx[:fa_italics_o]}DC tags included with this document are provided here.#{Mx[:fa_italics_c]} #{head_no_dc_tag}" if @dc.length > 0 +      @dc.each { |x| meta << x } +      meta << "#{Mx[:fa_bold_o]}Version Information#{Mx[:fa_bold_c]} #{head_no_rc}" if @rc.length > 0 +      if @cvs.length > 0 +        meta << "#{Mx[:fa_italics_o]}Note the version information provided here, is specific to the host site.#{Mx[:fa_italics_c]} #{head_no_rc_tag}" +        @cvs.each { |x| meta << x } +      end +      @rc.each { |x| meta << x } +      ## ENDNOTE RELATED endnote related +      meta << "\n#{Mx[:br_eof]}" +      meta=SiSU_hash::Object_digest.new(@md,meta,@env).object_digest +    end +  end +end +__END__ diff --git a/lib/sisu/v0/dal_numbering.rb b/lib/sisu/v0/dal_numbering.rb new file mode 100644 index 00000000..fd873da2 --- /dev/null +++ b/lib/sisu/v0/dal_numbering.rb @@ -0,0 +1,374 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_numbering +  class Numbering +    def initialize(md,data) +      @md,@data=md,data +    end +    def numbering_song +      data=@data +      data=number_plaintext_para(data) +      data=name_endnote_seg(data) #tr issue +      data=auto_number_heading_ie_title(data) #tr issue +      data=ocn(data) #watch +      data=minor_numbering(data) +      data=name_para_seg_filename(data) +      data=set_heading_seg(data) unless @md.set_heading_seg +      data=set_heading_top(data) unless @md.set_heading_top +      data=set_header_title(data) unless @md.set_header_title +      data +    end +    def number_plaintext_para(data) +      @tuned_file=[] +      data.each do |para| +        if para !~/#{Mx[:gr_o]}(?:code|group|alt|poem|verse)#{Mx[:gr_c]}|#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ +          para.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks +        end +        para.gsub!(/^/,"\n") unless para =~/#{Mx[:tc_p]}/u +        para.gsub!(/^\s+|\s$/,"\n") +        @tuned_file << para +      end +      @tuned_file=@tuned_file.flatten +    end +    def name_endnote_seg(data) +      tuned_file=data +      if @md.flag_auto_endnotes \ +      and @md.flag_separate_endnotes_make +        tuned_file << "\n#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}Endnotes #{Mx[:gl_o]}-##{Mx[:gl_c]} #{Mx[:id_o]}~0;0:0;u0#{Mx[:id_c]}" +      end +      tuned_file << "\n#{Mx[:br_endnotes]}" #DECIDE ON +      tuned_file=tuned_file.flatten +    end +    def owner_details_seg +      data << "#{Mx[:lv_o]}4:owner.details#{Mx[:lv_c]}Owner Details" +    end +    def number_sub_heading(para,num,title_no) +      case para +      when /#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/;  para.gsub!(/#{Mx[:lv_o]}#{num}:-#{Mx[:lv_c]}/,"#{title_no} ") +      when /^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/; para.gsub!(/^#{Mx[:lv_o]}#{num}:##{Mx[:lv_c]}/,"#{title_no} ") +      when /^#{Mx[:lv_o]}#{num}:[a-z_\.]+#{Mx[:lv_c]}/ +        para.gsub!(/^#{Mx[:lv_o]}#{num}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i,%{#{Mx[:lv_o]}#{num}:\\1#{Mx[:lv_c]} #{title_no} \\2  #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) +      when /^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}\s*#{title_no}/ +        para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]}")                #where title contains title number +      else para.gsub!(/^#{Mx[:lv_o]}#{num}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{num}:#{title_no}#{Mx[:lv_c]} #{title_no} ") #main, where title number is to be provided +      end +      if @md.toc_lev_limit \ +      and @md.toc_lev_limit < num +        para.gsub!(/^#{Mx[:lv_o]}[5-9]:\S*?#{Mx[:lv_c]}/,'!_ ') #bold line, watch +      end +      para +    end +    def auto_number_heading_ie_title(data)                                             #also does some segment naming +      @tuned_file=[] +      if @md.markup =~/num_top/ \ +      or @md.num_top # watch, 2003w23 +        input="#{@md.markup}"[/num_top\=([1-6])/,1] if @md.markup +        input||=@md.num_top if @md.num_top !~/^$/ +      end +      num_top=input.to_i +      t_no1=t_no2=t_no3=t_no4=0 +      no1=num_top; no2=(num_top + 1); no3=(num_top + 2);  no4=(num_top + 3) +      t_not=0 +      data.each do |para| #@md.seg_names << [additions to segment names] +        if (@md.markup =~/num_top/ \ +        or (@md.num_top \ +        and @md.num_top !~/^$/)) \ +        and para !~/^#{Rx[:meta]}/ +          if (para =~/^(?:#{no1}|^#{no2}|^#{no3}#{no4})~#/ \ +          and para !~/^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}/) +            t_not+=1 #; t_no2=0; t_no3=0 +            para.gsub!(/^(#{Mx[:lv_o]}#{no1}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") +            para.gsub!(/^(#{Mx[:lv_o]}#{no2}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") +            para.gsub!(/^(#{Mx[:lv_o]}#{no3}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") +            para.gsub!(/^(#{Mx[:lv_o]}#{no4}):#(#{Mx[:lv_c]})/,"\\1:ps#{t_not}\\2") +          end +          if para =~/#{Mx[:lv_o]}#{no1}:/ +            @subnumber=1 +            @subnumber=0 if para =~/#{Mx[:lv_o]}#{no1}:/ +          end +          if para =~/^#{Mx[:lv_o]}[1-6]:[\w-]*#{Mx[:lv_c]}/ \ +          and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s*[\d.]+)\s/ \ +          and para !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ +            if para =~/^#{Mx[:lv_o]}#{no1}:/ +              t_no1+=1; t_no2=0; t_no3=0 +              title_no="#{t_no1}" +              if not @md.seg_names.nil? \ +              and not @md.seg_names.include?(title_no) +                para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*(\S+)#/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]} \\1 #{title_no} ") #shift placement of auto-number to after first word, e.g. Article # not # Article, added on occasion of ABF (20040329) +                para.gsub!(/^#{no1}\{\s+(Article|Clause|Section)\s+#/i,%{#{no1}~#{title_no} \\1 #{title_no}. }) +                unless para =~/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}\s*[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review +                  para.gsub!(/^#{Mx[:lv_o]}#{no1}:#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:#{title_no}#{Mx[:lv_c]}#{title_no}. ") +                end +                @md.seg_names << title_no +              #else puts "warning segment name #{title_no} already exists" +              end +              unless para =~/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required +                para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)#{Mx[:lv_c]}\s*(.+)/i, +                  %{#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}#{title_no}. \\2 #{Mx[:fa_o]}:name##{title_no}#{Mx[:fa_c]}}) +              end +              para.gsub!(/^#{Mx[:lv_o]}#{no1}:##{Mx[:lv_c]}/,"#{title_no}. ") #watch +              para.gsub!(/^#{no1}~#\s*/,"#{title_no}. ") +            end +            if para =~/^#{Mx[:lv_o]}#{no2}:\S*?#{Mx[:lv_c]}/ +              t_no2+=1; t_no3=0 +              title_no="#{t_no1}.#{t_no2}" +              para=number_sub_heading(para,no2,title_no) +            end +            if para =~/^#{Mx[:lv_o]}#{no3}:\S*?#{Mx[:lv_c]}/ +              t_no3+=1 +              title_no="#{t_no1}.#{t_no2}.#{t_no3}" +              para=number_sub_heading(para,no3,title_no) +            end +          elsif para =~/^#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}/ # endnotes, watch2005 +            para.gsub!(/^#{Mx[:lv_o]}#{no1}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no1}:\\1#{Mx[:lv_c]}") #"#{no1}~\\1 ") +            para.gsub!(/^#{Mx[:lv_o]}#{no2}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no2}:\\1#{Mx[:lv_c]}") +            para.gsub!(/^#{Mx[:lv_o]}#{no3}:([a-z_\.]+)-#{Mx[:lv_c]}/,"#{Mx[:lv_o]}#{no3}:\\1#{Mx[:lv_c]}") +          end +        elsif @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 +          if para =~/^#{Mx[:lv_o]}[1-9]:#{Mx[:lv_c]}([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d +            name_num=$1 +            para.gsub!(/^#{Mx[:lv_o]}([1-9]:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{name_num}#{Mx[:lv_c]}") +          end +          if @md.toc_lev_limit +          end +        end +        @tuned_file << para +      end +      @tuned_file=@tuned_file.flatten +    end +    def ocn(data)                                                                      #and auto segment numbering increment +      @tuned_file=[] +      object_array=SiSU_document_structure::OCN.new(@md,data).ocn +      object_array.each do |o| +        @tuned_file <<= if o.ocn; "#{o.txt} #{Mx[:id_o]}~#{o.ocn};#{o.lv};#{o.type}#{Mx[:id_c]}" #main ocn descriptor +        else o.txt +        end +      end +      @tuned_file=@tuned_file.flatten +    end +    def minor_numbering(data)                                                          #and auto segment numbering increment +      @tuned_file=[] +      number_small,letter_small=0,0 +      letter=%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 ) +      data.each do |para| +        if para =~/\w|\S|<|\(/ +          if para !~/^%% |#{Rx[:meta]}|^0~|^#{Mx[:lv_o]}endnotes:|^4~endnotes|^<\/center>|<:ee>|<:e[:_]>|^\^~ |<:e[:_]\d+?>|^#{Mx[:fa_o]}:p[bn]#{Mx[:fa_c]}|^<:\#|<:- |<[:!]!4|#{Mx[:gr_o]}(?:alt|code|group|poem|table)#{Mx[:gr_c]}|^(?:alt|code|group|poem|table)\{|^\}(?:alt|code|group|poem|table)|^\}table$|<table|<\/table>|<td|<\/td>|<th|<\/th>|<tr>|<\/tr>|<hr width|<:4-endnotes>|\[endnotes\]|<:zz>|<:isbn-|<:journal-|<:conference-|#{Mx[:br_endnotes]}/i #ocn here #  added with Tune.code #¡ +            if para=~/^#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}/; number_small,letter_small=0,0                    #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) +            end +            if para =~/^#[ 1]/ +              letter_small=0 +              number_small=0 if para =~ /^#1/ +              number_small+=1 +              para.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004 +            end +            if para =~/^_# / +              para.gsub!(/^_# /,"#{Mx[:fa_o]}:i1#{Mx[:fa_c]} #{letter[letter_small]}. ") #change 2004 +              letter_small+=1 +            end +          end +        end +        @tuned_file << para +      end +      @tuned_file=@tuned_file.flatten +    end +    def name_para_seg_filename(data) +      # paragraph name/numbering rules +      # manual naming overrides, manual naming may be +      #   alpha-numeric characters mixed, +      #   numeric only (a number), if +      #     all segments have been named, +      #     the numbers used are over 1000 or +      #     it is  not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) +      #       [for now a warning is printed for such documents on use of maintenance or very-verbose flag] +      # auto-naming takes the form of giving numbers to segments +      # the rules for which are as follows +      #   if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.) +      #   otherwise the level 4 segment number from the embedded document structure info is used +      #   if there is none a sequential number is designated, preceded by an underscore +      @tuned_file=[] +      art_filename_auto=1 +      @counter=1 +      @unique_auto_name=[] +      if not @md.seg_autoname_safe and @md.cmd =~/[MV]/ +        puts 'manual segment names, numbers used as names, risk warning (segmented html)' +      end +      data.each do |para| +        para=SiSU_document_structure::Structure.new(@md,para).structure_markup +        if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}/ +          if para=~/^#{Mx[:lv_o]}[4]:#{Mx[:lv_c]}/ \ +          and not @md.set_heading_seg +            @md.set_heading_seg=true +          end +          if para =~/^#{Mx[:lv_o]}[456]:#{Mx[:lv_c]}(?:\s*\S+)?\s+([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name +            pattern=$1 +            pattern.gsub!(/(?:[:,-]|\W)/,'.') +            pattern.gsub!(/\.$/,'') +            if not @md.seg_names.nil? \ +            and not @md.seg_names.include?(pattern) +              para.gsub!(/^#{Mx[:lv_o]}([456]):#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1:#{pattern}#{Mx[:lv_c]}") +              @md.seg_names << pattern +            else puts 'warn, there may be a conflicting numbering scheme' if @md.cmd =~/[VM]/ +            end +          end +          if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}.+?;4:(\d+);/m #extract segment name from embedded document structure info +            pattern=$1 +            pattern.gsub!(/(?:[:,-]|\W)/,'.') +            pattern.gsub!(/\.$/,'') +            if not @md.seg_names.nil? \ +            and not @md.seg_names.include?(pattern) +              para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1#{pattern}#{Mx[:lv_c]}") +              @md.seg_names << pattern +            else +              para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,"#{Mx[:lv_o]}\\1~#{pattern}#{Mx[:lv_c]}") +              @md.seg_names << "~#{pattern}" +            end +          end +          if para =~/^#{Mx[:lv_o]}4:#{Mx[:lv_c]}/ #if still not segment name, provide a numerical one +            if not @md.seg_names.nil? \ +            and not @md.seg_names.include?(art_filename_auto) +              para.gsub!(/^#{Mx[:lv_o]}(4:)#{Mx[:lv_c]}/,%{#{Mx[:lv_o]}\\1~#{art_filename_auto}#{Mx[:lv_c]}}) +              @md.seg_names << art_filename_auto +            else puts 'segment name (numbering) error' +            end +            art_filename_auto+=1 +          end +        end +        @tuned_file << if para =~/^#{Mx[:lv_o]}([1-6]):\S*?#{Mx[:lv_c]}/m \ +        and (@md.pagenew or @md.pagebreak) +          m=$1 #watch ref~ +          para_tmp=[] +          if @md.pagenew.inspect =~/#{m}/;           para_tmp << "#{Mx[:br_page_new]}\n" << para +          elsif @md.pagebreak.inspect =~/#{m}/;         para_tmp << "#{Mx[:br_page]}\n" << para +          end +          para_result=unless para_tmp.length > 0; para +          else                       para_tmp +          end +        else                         para +        end +      end +      if @md.seg_names.length > 0 +        @md.set_heading_seg=true +      end +      @tuned_file=@tuned_file.flatten +    end +    def set_heading_top(data)                                                         #% make sure no false positives +      unless @md.set_heading_top +        puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.cmd =~/[MV]/ +        @tuned_file=[] +        data.each do |para| +          unless @md.set_heading_top +            if para !~/^(?:#{Rx[:meta]}|@\S+:|0~\S+)\s/m \ +            and para !~/\A\s*\Z/m +              @md.set_heading_top=true +              head=if @md.title ; "#{Mx[:lv_o]}1:#{Mx[:lv_c]} #{@md.title}" +              else                "#{Mx[:lv_o]}1:#{Mx[:lv_c]} [no title provided]" +              end +              @tuned_file << head +            end +          end +          @tuned_file << para +        end +        @tuned_file=@tuned_file.flatten +      end +    end +    def set_heading_seg(data)                                                          #% make sure no false positives +      unless @md.set_heading_seg +        puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.cmd =~/[MV]/ +        @tuned_file=[] +        data.each do |para| +          unless @md.set_heading_seg +            if para !~/^(?:#{Rx[:meta]}|#{Mx[:lv_o]}[123]:\S*?#{Mx[:lv_c]})/m \ +            and para !~/\A\s*\Z/m \ +            and para !~/#{Mx[:br_page]}|#{Mx[:br_page_new]}/ +              @md.set_heading_seg=true +              head=if @md.title ; "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [#{@md.title}]" +              else                "#{Mx[:lv_o]}4:seg#{Mx[:lv_c]} [segment]" +              end +              @tuned_file << head +            end +          end +          @tuned_file << para +        end +        @tuned_file=@tuned_file.flatten +      end +    end +    def set_header_title(data)                                                         #% make sure no false positives +      unless @md.set_header_title +        puts "\t no document title provided, (will have to manufacture one)" if @md.cmd =~/[MV]/ +        @tuned_file=[] +        data.each do |para| +          unless @md.set_header_title +            if para !~/^%{1,2}\s/m \ +            and para !~/\A\s*\Z/m +              @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" +              @md.title=@md.heading_seg_first +              @md.set_header_title=true +            end +          end +          @tuned_file << para +        end +        @tuned_file=@tuned_file.flatten +      end +    end +  end +end +__END__ diff --git a/lib/sisu/v0/dal_substitutions_and_insertions.rb b/lib/sisu/v0/dal_substitutions_and_insertions.rb new file mode 100644 index 00000000..dad07ec9 --- /dev/null +++ b/lib/sisu/v0/dal_substitutions_and_insertions.rb @@ -0,0 +1,131 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   #___# + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_substitute_and_insert +  class SI +    def initialize(md,data) +      @md,@data=md,data +    end +    def substitutions_and_insertions? +      data=@data +      data_expand=[] +      if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) +        data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'') +        data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'') +      end +      if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier +        data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1') +        data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1') +      end +      data.each do |para| +        if para =~/<:insert\d+!?>/ \ +        and para !~/^%\s+/ +          @skin.select +          ins=SiSU_Viz::Inserts.new +          case para +          when /^\s*<:insert1>\s*$/ +            para=[] +            ins.insert1.split(/\n\n/).each{|x| para << x } +          when /^\s*<:insert2>\s*$/ +            para=[] +            ins.insert2.split(/\n\n/).each{|x| para << x } +          when /^\s*<:insert3>\s*$/ +            para=[] +            ins.insert3.split(/\n\n/).each{|x| para << x << "\n"} +            para=ins.insert3 +          when /^\s*<:insert4>\s*$/ +            para=[] +            ins.insert4.split(/\n\n/).each{|x| para << x << "\n"} +            para=ins.insert4 +          when /^\s*<:insert5>\s*$/ +            para=[] +            ins.insert5.split(/\n\n/).each{|x| para << x << "\n"} +          when /^\s*<:insert6>\s*$/ +            para=[] +            ins.insert6.split(/\n\n/).each{|x| para << x << "\n"} +          when /^\s*<:insert7>\s*$/ +            para=[] +            ins.insert7.split(/\n\n/).each{|x| para << x << "\n"} +          end +          para.each{|x| data_expand << x } +        else data_expand << para +        end +        data_expand.flatten! +        data_expand.compact! +      end +      data_expand.each do |para| +        para=if @md.markup_version.to_f >= 0.38 +          SiSU_document_structure::Structure.new(@md,para).structure_markup_normalize +        else +          SiSU_document_structure::Structure.new(@md,para).structure_marks +        end +        #para.gsub!(/<url:(\S+?)>/,'\1') #consider, would permit use of text hyperlinks if desired, dal_syntax more appropriate? +        para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#')                                    #conditional header for incorporated document 2004w12 +        if para =~/^@\S+?:/ +          para.gsub!(/^@(\S+?):\s+/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}") +          para.gsub!(/^@(\S+?):([+-])\s+/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}") +        end +      end +    end +  end +end +__END__ + diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index c3bd8a7d..cbcd42f9 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -238,15 +238,29 @@ module SiSU_Syntax            line=line_array.join(' ')            line=line.strip          end -        line.gsub!(/~\{(.+?)\}~/m,"#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") -        line.gsub!(/~\[(.+?)\]~/m,"#{Mx[:en_b_o]}\\1#{Mx[:en_b_c]}") -        line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 #{@md.title} - #{@md.subtitle},<br />\\2#{@md.dc_creator}") +        line.gsub!(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]) +        line.gsub!(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]) #default if markup does not specify +        line.gsub!(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) +        if @md.subtitle and not @md.subtitle.empty? +          if line =~/(?:by\s+)?(?:@creator|@author)/ +            line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.title} - #{@md.subtitle},<br />\\2#{@md.dc_creator}") +          else +            line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") +          end +        else +          if line =~/(?:by\s+)?(?:@creator|@author)/ +            line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.title},<br />\\2#{@md.dc_creator}") +          else +            line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s*$/,"\\1 #{@md.title}") +          end +        end          line.gsub!(/^(1~\??) @title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}")                    #          line.gsub!(/^(#{Mx[:lv_o]}[23]:\??#{Mx[:lv_c]}) (?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 \\2#{@md.dc_creator}")                    #          line.gsub!(/<((?:https?|file):\/\/\S+?)>/,'< \1 >')                    #catch problem markup          line.gsub!(/\}\.\.\/(\S+)/,"\}#@output_url/\\1")                       #means you are not supporting relative links (only relevant in html), converted to static here          line.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu')                                                    #adjustment 2005w30          line.gsub!(/<!(\S+)!>/,'<:\1>')                                        #escaped special character +        line.gsub!(/ /,"#{Mx[:nbsp]}")                                             #escaped special character          line.gsub!(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}")                                             #escaped special character          line.gsub!(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}")                                            #escaped special character          line.gsub!(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}")                                            #escaped special character @@ -273,44 +287,46 @@ module SiSU_Syntax          line.gsub!(/^(#{Mx[:lv_o]}[56]:(\S+?)#{Mx[:lv_c]})\s*(.+)/,"\\1 \\3 #{Mx[:mk_o]}:name#\\2#{Mx[:mk_c]}")   #html name marker <a name="\\1"></a>, however at present takes you to correct position within sub-toc, will nneed to clean from sub-toc leaving in main body only          line.gsub!(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}")                     #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ')          if line=~/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m -          line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ ([^}]+?)\s*\}((?:https?|file|ftp):\S+)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,"\\1{ \\2 }\\3 #{Mx[:en_a_o]} \\3 \\4 #{Mx[:en_a_c]}") # watch +          line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ ([^}]+?)\s*\}((?:https?|file|ftp):\S+)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, +            "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch          end          if line=~/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s|$))/m -          line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s|$))/m,"\\1{ \\2 }\\3\\4 #{Mx[:en_a_o]} \\3 #{Mx[:en_a_c]} ") +          line.gsub!(/(^|#{Mx[:gl_c]}| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s|$))/m, +            "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ")             #text url endnote url shortcut {~^ [text] }http://url is { [text] }http://url #{Mx[:en_a_o]} http://url #{Mx[:en_a_c]} [plus adjustment for commas]             #means for this class, non-object, un-numbered ~# will not work # shortcut should not be used in conjunction with rebgular matches #reversed order, and addition of no-tilde..          end          #line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch          line.gsub!(/<:?p([nb])>/,"#{Mx[:fa_o]}p\\1#{Mx[:fa_c]}")               #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ')        # depreciated -->#{Mx[:fa_c]} -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")              #emphasis -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")              #bold -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}")  #underscore -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)c\{(.+?)\}c/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}")        #italics +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")              #emphasis +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")              #bold +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}")  #underscore +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)c\{(.+?)\}c/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}")        #italics        # depreciated ^ -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")              #emphasis -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")            #bold -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}")  #underscore -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}")     #italics -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}")     #cite /blockquote? +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")              #emphasis +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")            #bold +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}")  #underscore +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}")     #italics +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}")     #cite /blockquote?          line.gsub!(/(^|[^\\])\^\{(.+?)\}\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}")                                 #superscript -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |\(|\>|\S)9\{(.+?)\}9/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}")           #superscript +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|\(|\>|\S)9\{(.+?)\}9/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}")           #superscript          line.gsub!(/(^|[^\\]),\{(.+?)\},/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}")                                 #subscript -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}")   #subscript -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}")              #inserted text -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}")                #inserted text -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}")                #strikethrough - deleted text -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}")                #deleted text -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")                     #bold single word, watch -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")                     #bold single word, watch -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}\\3") #underscore single word, watch (made more complicated by url decoration escape tag (_url)) +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/,"\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}")   #subscript +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}")              #inserted text +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/,"\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}")                #inserted text +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}")                #strikethrough - deleted text +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}")                #deleted text +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")                     #bold single word, watch +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}")                     #bold single word, watch +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}\\3") #underscore single word, watch (made more complicated by url decoration escape tag (_url))          line.gsub!(/(^|#{Mx[:gl_c]}|\s+)-([^{]\S+?)-( |$)/,"\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}\\3")                                        #underscore single word, watch -        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added -        line.gsub!(/<[:e]\s+(.+?)!?>/,"#{Mx[:en_a_o]} \\1 #{Mx[:en_a_c]}")                                                                                     #not tested +        line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added +        line.gsub!(/<[:e]\s+(.+?)!?>/,"#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}")                                                                                     #not tested          line.gsub!(/^\s*_\*\s*/,"#{Mx[:gl_bullet]}")                               #bullets, shortcut -        #line.gsub!(/^\s*_(\*+)\s*/,"#{Mx[:gl_bullet]}")                               #bullets, shortcut +        line.gsub!(/=\{(.+?)\}/,"#{Mx[:idx_o]}\\1#{Mx[:idx_c]}")                   #          line.gsub!(/^\s*_([1-9])\*\s*/,"#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}")                               #bullets, shortcut          #line.gsub!(/^\s*_([1-9])(\*+)\s*/,"#{Mx[:fa_o]}:i\\1#{Mx[:fa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}")                               #bullets, shortcut          line.gsub!(/^\s*_([1-9])\s+/,"#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}")                                                                 #indent @@ -326,8 +342,9 @@ module SiSU_Syntax          #line.gsub!(/<:\/hi>/,'</span>')          line.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n")          line.gsub!(/[ ]+($)/,'\1') -        #line.gsub!(/\{(.+?)\}(https?:\S+)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked (text or image) -        #line.gsub!(/\{(.+?)\}(image)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2")      #linked image +        line.gsub!(/\{\s*(.+?)\s*\}(https?:\S+)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked (text or image) +        line.gsub!(/\{\s*(.+?)\s*\}(image)/,"#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2")      #linked image +        #line.gsub!(/(#{Mx[:lnk_c]})\s*((?:https?|file|ftp):\S+?)/m,'\1\2')          ##semantic          #line.gsub!(/([a-z](?:[a-z_:.]+?[a-z])?)+(?::\{(.+?)\}:\1)/m,"\\1#{Mx[:sm_set_o]}\\2#{Mx[:sm_set_c]}\\1")          #line.gsub!(/;\{\s*(.+?)\s*\};([a-z]+(?:[_:.][a-z]+)*)/,"#{Mx[:sm_subset_o]}\\1#{Mx[:sm_subset_c]}\\2") @@ -339,7 +356,8 @@ module SiSU_Syntax          line.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy          line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert <br> <br /> back, clumsy          line.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy -        line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n  ") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") +        line.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") +        line        else # 0~        end        line diff --git a/lib/sisu/v0/db_columns.rb b/lib/sisu/v0/db_columns.rb index fcb37812..87e14b01 100644 --- a/lib/sisu/v0/db_columns.rb +++ b/lib/sisu/v0/db_columns.rb @@ -62,28 +62,28 @@  module SiSU_DB_columns    class Column_size      def lt_title -      320 +      600      end      def lt_subtitle -      320 +      600      end      def lt_creator -      200 +      600      end      def lt_illustrator -      200 +      600      end      def lt_translator -      200 +      600      end      def lt_prepared_by -      200 +      600      end      def lt_digitized_by -      200 +      600      end      def lt_subject -      400 +      600      end      def lt_date        10 @@ -104,25 +104,25 @@ module SiSU_DB_columns        10      end      def lt_type -      100 +      600      end      def lt_description -      800 +      2000      end      def lt_publisher -      120 +      600      end      def lt_contributor -      120 +      600      end      def lt_format -      100 +      600      end      def lt_identifier        256      end      def lt_source -      100 +      200      end      def lt_language        30 @@ -143,16 +143,16 @@ module SiSU_DB_columns        100      end      def lt_rights -      800 +      2000      end      def lt_copyright -      200 +      2000      end      def lt_owner -      100 +      600      end      def lt_keywords -      200 +      600      end      def lt_comment        600 diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 1e788f8e..f02ccd3f 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -141,19 +141,19 @@ module SiSU_DB_import        string.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"<br />\n")        string.gsub!(/#{Mx[:gr_o]}(?:code|alt|group|verse)(?:-end)?#{Mx[:gr_c]}/,'')        string.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') -      string.gsub!(/\{\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)\}\S+/,'[image: \1] \2') -      string.gsub!(/\{\s*(.+?)\s*\}(?:https?|file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') +      string.gsub!(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2') +      string.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2')      end      def strip_markup(string) #define rules, make same as in dal clean        string.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]')        string.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/,'') -      string.gsub!(/(?: \\;)+/,' ') +      string.gsub!(/(?: \\;|#{Mx[:nbsp]})+/,' ')        string.gsub!(/#{Mx[:gr_o]}T[h]?#{Mx[:tc_p]}.+?#{Mx[:gr_c]}/u,"[TABLE]\n")             #tables #CHECK should take whole table        string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1')         #tables        string.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' ')                          #tables        string.gsub!(/#{Mx[:tc_p]}/u,' ')                                                     #tables tidy later        string.gsub!(/<.+?>/,'') -      string.gsub!(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search +      string.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search        string.gsub!(/\s\s+/,' ')        string.strip!      end @@ -402,7 +402,8 @@ module SiSU_DB_import                  end                  txt=endnotes(txt).clean_text                end -              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_minus +              txt_obj={:txt =>txt,:col =>@col} +              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_minus                special_character_escape(@col[:body])                @col[:plaintext]=@col[:body].dup                strip_markup(@col[:plaintext]) @@ -443,7 +444,8 @@ module SiSU_DB_import                  end                  txt=endnotes(txt).clean_text(@base_url)                end -              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus +              txt_obj={:txt =>txt,:col =>@col} +              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus                special_character_escape(@col[:body])                @col[:plaintext]=@col[:body].dup                strip_markup(@col[:plaintext]) @@ -482,7 +484,8 @@ module SiSU_DB_import                  end                  txt=endnotes(txt).clean_text(@base_url)                end -              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus +              txt_obj={:txt =>txt,:col =>@col} +              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus                special_character_escape(@col[:body])                @col[:plaintext]=@col[:body].dup                strip_markup(@col[:plaintext]) @@ -521,7 +524,8 @@ module SiSU_DB_import                  end                  txt=endnotes(txt).clean_text(@base_url)                end -              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus +              txt_obj={:txt =>txt,:col =>@col} +              @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus                special_character_escape(@col[:body])                @col[:plaintext]=@col[:body].dup                strip_markup(@col[:plaintext]) @@ -570,11 +574,14 @@ module SiSU_DB_import                if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last                end                @col[:body]=if txt=~/#{Mx[:gr_o]}T[h]?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/ #watch -                SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).html_table +                txt_obj={:txt =>txt,:col =>@col} +                SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).html_table                elsif txt=~/^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/ -                SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).indent($1) +                txt_obj={:txt =>txt,:col =>@col} +                SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).indent($1)                else -                SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).norm +                txt_obj={:txt =>txt,:col =>@col} +                SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).norm                end                special_character_escape(@col[:body])                @col[:plaintext]=@col[:body].dup @@ -593,7 +600,8 @@ module SiSU_DB_import                      nr,txt,digest_clean=$1,$2,$3                    end                    @id_n+=1 -                  body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote +                  txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} +                  body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote                    special_character_escape(body)                    special_character_escape(txt)                    strip_markup(txt) @@ -633,7 +641,8 @@ module SiSU_DB_import                      nr,txt,digest_clean=$1,$2,$3                    end                    @id_n+=1 -                  body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote +                  txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} +                  body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote                    special_character_escape(body)                    special_character_escape(txt)                    strip_markup(txt) @@ -674,7 +683,8 @@ module SiSU_DB_import                      nr,txt,digest_clean=$1,$2,$3                    end                    @id_n+=1 -                  body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote +                  txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} +                  body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote                    special_character_escape(body)                    special_character_escape(txt)                    strip_markup(txt) diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 4129893a..a3e1b16d 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -936,7 +936,7 @@ module SiSU_Viz  </td>  <td valign="top" align="justify">}      end -    def margin_css +    def margin_css #unused, check        '<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">  <tr><td valign="top" align="justify"> '      end @@ -1627,11 +1627,12 @@ WOK  #{table_close*4}}      end      def credits_sisu -      %{#{widgets_open} +      %{<div class="substance"> +<table summary="SiSU summary" bgcolor="#ffffff" cellpadding="4" border="0">  <tr><td>    #{widget_sisu}    #{widget_way_better} -</table>} +</table></div>}      end      def credits_splash      end @@ -2094,10 +2095,10 @@ WOK        end        def landscape          def w -          262 +          238          end          def h -          168 +          160          end          def img_px            348 @@ -2112,7 +2113,7 @@ WOK            166          end          def h -          216 +          212          end          def img_px            468 @@ -2121,7 +2122,7 @@ WOK        end        def landscape          def w -          242 +          226          end          def h            166 @@ -2139,7 +2140,7 @@ WOK            168          end          def h -          294 +          286          end          def img_px            474 @@ -2148,7 +2149,7 @@ WOK        end        def landscape          def w -          314 +          296          end          def h            166 @@ -2166,7 +2167,7 @@ WOK            140          end          def h -          210 +          204          end          def img_px            356 @@ -2175,10 +2176,10 @@ WOK        end        def landscape          def w -          216 +          200          end          def h -          136 +          130          end          def img_px            280 @@ -2193,7 +2194,7 @@ WOK            112          end          def h -          170 +          162          end          def img_px            280 @@ -2202,10 +2203,10 @@ WOK        end        def landscape          def w -          176 +          152          end          def h -          110 +          100          end          def img_px            230 diff --git a/lib/sisu/v0/digests.rb b/lib/sisu/v0/digests.rb index 9510a12a..42fa6962 100644 --- a/lib/sisu/v0/digests.rb +++ b/lib/sisu/v0/digests.rb @@ -161,8 +161,8 @@ module SiSU_Digest_view              end              ima=[]              if para !~/^%+\s/ \ -            and para =~/(?:^|[^_\\])\{(\S+\.(png|jpg|gif))\s.+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/ -              images=para.scan(/(?:^|[^_\\])\{(\S+\.(?:png|jpg|gif))\s.+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/).flatten +            and para =~/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/ +              images=para.scan(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/).flatten              else image=nil              end              x=case para diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index 5b9639dd..df53d1b7 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -65,8 +65,8 @@ module SiSU_HTML    require "#{SiSU_lib}/defaults"    include SiSU_Viz    require "#{SiSU_lib}/html_table" -  require "#{SiSU_lib}/html_format_css" -  include SiSU_HTML_Format_type +  require "#{SiSU_lib}/html_format" +  include SiSU_HTML_Format    require "#{SiSU_lib}/html_segments"    require "#{SiSU_lib}/html_scroll"    include SiSU_HTML_seg @@ -106,7 +106,7 @@ module SiSU_HTML          toc=SiSU_HTML::Source::Toc.new(data,@md).songsheet          links_guide=SiSU_HTML::Source::Links_guide.new(data,@md).toc          data=@tuned_file_array -        scr_toc=SiSU_HTML::Source::Scroll_head_and_segtoc.new(data,@md,toc,links_guide).in_common #watch +        scr_toc=SiSU_HTML::Source::Scroll_head_and_segtoc.new(@md,toc,links_guide).in_common #watch          SiSU_HTML::Source::Seg.new(data,@md).songsheet          data=@tuned_file_array          scr=SiSU_HTML::Source::Scroll.new(data,@md).songsheet @@ -155,7 +155,7 @@ module SiSU_HTML        def tuned_file_instructions          @tell=SiSU_Screen::Ansi.new(@md.cmd)          if @md -          @md.sfx='' +          #@md.sfx=''            @md.sfx='' if @md.cmd =~/z/            if @md.cmd =~/h/ \            or @md.fns =~/\~[a-z]{2,3}\.s?/ #multilingual document protection is a bit arbitrary, (needed by existing server configuration), add configuration overide... @@ -173,9 +173,6 @@ module SiSU_HTML          @md.file_type='html' if @md.cmd =~/[hon]/          directories          newfilename=%{#{@env.path.output}/#{@md.fnb}/#{@md.fn[:index]}} if @md.file_type =~/html/ -        my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) -        @fnm=my_make_source_file.marshal_meta -        @tune_verse_marshal=my_make_source_file.marshal_tune          dal_array=@particulars.dal_array # dal file drawn here          @tuned_file_array=SiSU_Tune::Tune.new(dal_array,@md).songsheet          @tuned_file_array @@ -190,7 +187,7 @@ module SiSU_HTML        end        def toc          @links_guide_toc=[] -        format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md)          guide_type='horzontal' #values: horizontal or vertical          @links_guide_toc << format_head_toc.links_guide_open(guide_type)          if defined? @md.lnk \ @@ -201,24 +198,25 @@ module SiSU_HTML                else                              '_top'                end                s_lnk_url,s_lnk_lnk=l[:url],l[:say] -              lev_para_ocn=SiSU_HTML_Format_type::Format_toc.new(@md,s_lnk_url,s_lnk_lnk,target) +              txt_obj={:lnk_url =>s_lnk_url,:lnk_txt =>s_lnk_lnk,:target =>target} +              lev_para_ocn=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)                @links_guide_toc << lev_para_ocn.links_guide if s_lnk_lnk              end            end          end -        format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md)          @links_guide_toc << format_head_toc.links_guide_close #(guide_type)          @links_guide_toc        end      end      class Endnotes -      include SiSU_HTML_Format_type +      include SiSU_HTML_Format        def initialize(data,md)          @data,@md=data,md        end        def scroll          @scr_endnotes=[] -        format_head_scroll=SiSU_HTML_Format_type::Head_scroll.new(@md) +        format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md)          @scr_endnotes << format_head_scroll.title_endnote          @data.each do |para|            pg=para.dup @@ -236,7 +234,8 @@ module SiSU_HTML                  endnote_array << pg.scan(/#{Mx[:en_b_o]}[\d+]+(.+?)#{Mx[:en_b_c]}/m)                end                endnote_array.flatten.each do |note| -                format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,note) +                txt_obj={:txt =>note} +                format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,txt_obj)                  @scr_endnotes << format_scroll.endnote_body                end              end @@ -246,7 +245,7 @@ module SiSU_HTML        end      end      class Toc <Links_guide -      @@toc={ :seg=>[],:scr=>[] } +      @@toc={ :seg=>[],:seg_mini=>[],:scr=>[] }        @@seg_url=''        @@dp,@@firstseg=nil,nil        def initialize(data='',md=nil) @@ -255,12 +254,13 @@ module SiSU_HTML          @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern          @pat_heading=/^(?:#{Mx[:lv_o]}[1-6]:\S*?#{Mx[:lv_c]}\s*)?(.*)#{Mx[:id_o]}~(\d+);(?:[hm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/          @pat_strip_heading_name=/<a name="h?\d.*?">(.+?)<\/a>/ -        @tell=SiSU_Screen::Ansi.new(@md.cmd) +        @tell=SiSU_Screen::Ansi.new(@md.cmd) if @md        end        def songsheet #extracts toc for scroll & seg          SiSU_Screen::Ansi.new(@md.cmd,'Toc').txt_grey unless @md.cmd =~/q/          toc=nil          @@firstseg=nil +        @@toc={ :seg=>[],:seg_mini=>[],:scr=>[] }          @data.each do |para|            if para =~/^(?:#{Mx[:lv_o]}[1-6]:|4~!)/              para_toc=para.dup @@ -272,7 +272,7 @@ module SiSU_HTML              when /^\s*#{Mx[:lv_o]}4:\S+/; Toc.new(para_toc,@md).level_4              when /^\s*#{Mx[:lv_o]}5:\S*/; Toc.new(para_toc,@md).level_5              when /^\s*#{Mx[:lv_o]}6:\S*/; Toc.new(para_toc,@md).level_6 -            when /^\s*4~!/;      Toc.new(para_toc).level_crosslink +            when /^\s*4~!/;               Toc.new(para_toc).level_crosslink              else              end              if @@firstseg.nil? \ @@ -282,6 +282,7 @@ module SiSU_HTML              if toc                begin                  @@toc[:seg] << toc[:seg] if toc[:seg] +                @@toc[:seg_mini] << toc[:seg_mini] if toc[:seg_mini]                  @@toc[:scr] << toc[:scr] if toc[:scr]                rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error                end @@ -291,6 +292,10 @@ module SiSU_HTML          @md.firstseg=@@firstseg          @@toc        end +      def minitoc +        minitoc=@@toc[:seg_mini].to_s +        '<div class="toc">' + minitoc + '</div>' +      end      protected        def rss #sort all wrong, disabled but kept          @@toc[:seg] <<<<WOK @@ -308,26 +313,34 @@ WOK        end        def level_doc_owner_details          if @md.stmp =~/\w\w/ -          format_head_scroll=SiSU_HTML_Format_type::Head_scroll.new(@md) +          format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md)            @@toc[:scr] << format_head_scroll.toc_owner_details          end        end +#not used -->        def level_endnotes          if @md.flag_endnotes -          format_head_scroll=SiSU_HTML_Format_type::Head_scroll.new(@md) +          format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md)            @@toc[:scr] << format_head_scroll.toc_endnote          end        end +      def level_concordance +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) +        @@toc[:seg_mini] << format_head_toc.mini_seg_concordance +      end        def level_metadata -        format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md)          @@toc[:scr] << format_head_toc.metadata          @@toc[:seg] << format_head_toc.seg_metadata +        @@toc[:seg_mini] << format_head_toc.mini_seg_metadata        end        def level_word_index -        format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@d0c) +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c)          @@toc[:scr] << format_head_toc.concordance          @@toc[:seg] << format_head_toc.concordance +        @@toc[:seg_mini] << format_head_toc.mini_concordance        end +# <-- not used        def level_1          para=@data          unless para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -337,7 +350,7 @@ WOK          linkname,link=$1.strip,$2 if $&            if link \            and link !~/#/ #% keep eye on link -            p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) +            p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link)            end            title=unless para =~/Document Information/; linkname          else @@ -345,11 +358,19 @@ WOK            %{<b><a href="#{@md.fnl[:pre]}#{link}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}">#{linkname}</a></b>}          end          toc={} -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc[:seg]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/            format_toc.lev0          else format_toc.lev1          end +        toc[:seg_mini]=if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ +          x=if @md.concord_make +            format_toc.mini_concord_tail +          else format_toc.mini_tail +          end +        else format_toc.mini_lev1 +        end          title=if para =~/(#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/            m=/#{$1}/            para.gsub!(m,'') @@ -364,7 +385,8 @@ WOK            end            %{<b><a href="##{link}">#{linkname}</a></b>}          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc[:scr]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/            format_toc.lev0          else format_toc.lev1 @@ -377,21 +399,24 @@ WOK            para.gsub!(@pat_strip_heading_name,'\1')          end          para[@pat_heading] -        linkname,link=$1.strip,$2 if $& -        if link \ -        and link !~/#/ -          p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) +        linkname,ocn=$1.strip,$2 if $& +        if ocn \ +        and ocn !~/#/ +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn)          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,linkname) +        txt_obj={:txt =>linkname} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc={}          toc[:seg]=format_toc.lev2 +        toc[:seg_mini]=format_toc.mini_lev2          if para =~/(#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/            m=/#{$1}/            para.gsub!(m,'')            title=linkname          else title=%{#{p_num.goto}#{linkname}</a>}          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc[:scr]=format_toc.lev2          toc        end @@ -400,21 +425,24 @@ WOK          para.gsub!(@pat_strip_heading_name,'\1')          para.gsub(/(.*?)<a name="(\d+)"><\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect          para[@pat_heading] -        linkname,link=$1.strip,$2 if $& -        if link \ -        and link !~/#/ -          p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) +        linkname,ocn=$1.strip,$2 if $& +        if ocn \ +        and ocn !~/#/ +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn)          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,linkname) +        txt_obj={:txt =>linkname} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc={}          toc[:seg]=format_toc.lev3 +        toc[:seg_mini]=format_toc.mini_lev3          if para =~/(#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/            m=/#{$1}/            para.gsub!(m,'')            title=linkname          else title=%{#{p_num.goto}#{linkname}</a>}          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc[:scr]=format_toc.lev3          toc        end @@ -424,8 +452,8 @@ WOK            unless para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/              para.gsub!(@pat_strip_heading_name,'\1')              para[@pat_heading] -            linkname,link=$1.strip,$2 if $& -            p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link +            linkname,ocn=$1.strip,$2 if $& +            p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn            end            para.gsub!(/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'')            if para =~/^#{Mx[:lv_o]}4:/ @@ -433,23 +461,30 @@ WOK                %{  <a href="#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}" target="_top">      \\2    </a> }) +            if seg_link =~/(#{Mx[:id_o]}\~\d+;(?:\w|[0-6]:\d+);\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/m +              m=/#{$1}/m +              seg_link.gsub!(m,'') +            end              @@seg_url=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?$/,1]            elsif para =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/              seg_link=para.gsub(/^\s*(#{@md.lv4}\s+)\s*(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/,                %{<a href="#{@md.fnl[:pre]}\\2#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}" } +                %{target="_top">\\1 \\2 \\3</a> })            end -          p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link -          format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,seg_link) +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn +          txt_obj={:txt =>seg_link} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)            toc={}            toc[:seg]=format_toc.lev4 +          toc[:seg_mini]=format_toc.mini_lev4            if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/              m=/#{$1}/              para.gsub!(m,'')              title=linkname            else title=%{#{p_num.goto}#{linkname}</a>} if p_num            end -          format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +          txt_obj={:txt =>title} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)            toc[:scr]=format_toc.lev4            toc          end @@ -460,10 +495,10 @@ WOK            para.gsub!(@pat_strip_heading_name,'\1')          end          para[@pat_heading] -        linkname,link=$1.strip,$2 if $& -        if link \ -        and link !~/#/ -          p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) +        linkname,ocn=$1.strip,$2 if $& +        if ocn \ +        and ocn !~/#/ +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn)          end          toc={}          if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -471,14 +506,17 @@ WOK            para.gsub!(m,'')            title=linkname          else -          lnk_n_txt=%{  <a href="#{@md.fnl[:pre]}#{@@seg_url}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}##{link}"> +          lnk_n_txt=%{  <a href="#{@md.fnl[:pre]}#{@@seg_url}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}##{ocn}">      #{linkname}    </a>} -          format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,lnk_n_txt) +          txt_obj={:txt =>lnk_n_txt} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)            toc[:seg]=format_toc.lev5 +          toc[:seg_mini]=format_toc.mini_lev5            title=%{#{p_num.goto}#{linkname}</a>}          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc[:scr]=format_toc.lev5          toc        end @@ -488,10 +526,10 @@ WOK            para.gsub!(@pat_strip_heading_name,'\1')          end          para[@pat_heading] -        linkname,link=$1.strip,$2 if $& -        if link \ -        and link !~/#/ -          p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) +        linkname,ocn=$1.strip,$2 if $& +        if ocn \ +        and ocn !~/#/ +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn)          end          toc={}          if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -499,14 +537,17 @@ WOK            para.gsub!(m,'')            title=linkname          else -          lnk_n_txt=%{  <a href="#{@md.fnl[:pre]}#{@@seg_url}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}##{link}"> +          lnk_n_txt=%{  <a href="#{@md.fnl[:pre]}#{@@seg_url}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}##{ocn}">      #{linkname}    </a>} -          format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,lnk_n_txt) +          txt_obj={:txt =>lnk_n_txt} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)            toc[:seg]=format_toc.lev6 +          toc[:seg_mini]=format_toc.mini_lev6            title=%{#{p_num.goto}#{linkname}</a>}          end -        format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,title) +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj)          toc[:scr]=format_toc.lev6          toc        end @@ -535,22 +576,22 @@ WOK        end      end      class Scroll_head_and_segtoc < Toc -      def initialize(data,md='',toc='',links_guide_toc='') -        @data,@md,@toc,@links_guide_toc=data,md,toc,links_guide_toc +      def initialize(md='',toc='',links_guide_toc='') +        @md,@toc,@links_guide_toc=md,toc,links_guide_toc          @vz=SiSU_Env::Get_init.instance.skin        end        def in_common          toc_shared=[]          @segtoc=[]          SiSU_Screen::Ansi.new(@md.cmd,'Scroll & Segtoc').txt_grey unless @md.cmd =~/q/ -        format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md)          dochead=format_head_toc.head          dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge          ads=SiSU_HTML_promo::Ad.new(@md)          toc_shared << dochead << ads.div.major          @segtoc << format_head_toc.head << ads.div.major -        toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format_type::Head_toc.method_defined? :toc_head_escript -        @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format_type::Head_toc.method_defined? :toc_head_escript +        toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript +        @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript          toc_shared << format_head_toc.scroll_head_navigation_band          if @md.dc_rights            rights=format_head_toc.rights @@ -561,26 +602,30 @@ WOK            prefix_b=SiSU_Tune::Clean_html.new(prefix_b).clean          end          @seg_toc_band=format_head_toc.seg_head_navigation_band('pdf') #bug, vary depending on type of doc !! examine +        @seg_toc_band_bottom=format_head_toc.seg_head_navigation_band_bottom('pdf') #bug, vary depending on type of doc !! examine          @segtoc << @seg_toc_band          toc_shared << format_head_toc.scroll_head_title_banner_open          @segtoc << format_head_toc.seg_head_title_banner_open          tmp_head=nil          doc_title_endnote=@md.title.gsub(/(\*+)/,'<sup><a href="#endnotes">\1</a></sup>')          tmp_head=doc_title_endnote + "\n" -        format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) +        txt_obj={:txt =>tmp_head} +        format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj)          toc_shared << format_txt_obj.center_bold          @segtoc << format_txt_obj.center_bold          if not @md.subtitle.nil? \          and not @md.subtitle.empty?            tmp_head=@md.subtitle + "\n" -          format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) +          txt_obj={:txt=>tmp_head} +          format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj)            toc_shared << format_txt_obj.center_bold            @segtoc << format_txt_obj.center_bold          end          if @md.dc_creator            creator_endnote=@md.dc_creator.gsub(/(\*+)/,%{ <sup><a href="#notes">\\1</a></sup>})            tmp_head=creator_endnote + "\n" -          format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) +          txt_obj={:txt =>tmp_head} +          format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj)            toc_shared << format_txt_obj.center_bold            @segtoc << format_txt_obj.center_bold          end @@ -606,7 +651,7 @@ WOK          @segtoc << prefix_b if @md.prefix_b          #Segtoc tail added here          @segtoc << "</p>\n" #bugfix sort later DEBUGNOW -        @segtoc << @seg_toc_band +        @segtoc << @seg_toc_band_bottom          ads=SiSU_HTML_promo::Ad.new(@md)          @segtoc << format_head_toc.seg_navigation_tail << ads.div.close << ads.display << format_head_toc.html_close          @segtoc.flatten!.compact! diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 03d97a8d..a73f3533 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -55,16 +55,15 @@     <ralph@amissah.com>     <ralph.amissah@gmail.com> - ** Description: base formatting template for html generation + ** Description: html formating, css template  =end  module SiSU_HTML_Format    include SiSU_Viz    class Paragraph_number -    def initialize(md,paranum) -      @md=md -      @paranum=paranum[/(\d+)/m,1] -      @paranum ||='' +    def initialize(md,ocn) +      @md,@ocn=md,ocn[/(\d+)/m,1] +      @ocn ||=''        vz=SiSU_Env::Get_init.instance.skin        @skin_no_ocn=if defined? vz.ocn_display_off \        and vz.ocn_display_off == true @@ -77,76 +76,31 @@ module SiSU_HTML_Format        or @md.mod.inspect =~/--no-ocn/ \        or @skin_no_ocn          ocn_class='ocn_off' -        @paranum.gsub(/^(\d+|)$/, -        %{  <p class="#{ocn_class}"> -      -  </p>}) +        @ocn.gsub(/^(\d+|)$/, +        %{<label class="#{ocn_class}"> </label>}) +      elsif @ocn.to_i == 0 +        @ocn.gsub(/^(\d+|)$/, +        %{<label class="#{ocn_class}"><a name="#{@ocn}"> </a></label>})        else          ocn_class='ocn' -        @paranum.gsub(/^(\d+|)$/, -        %{  <p class="#{ocn_class}"> -      \\1 -  </p>}) +        @ocn.gsub(/^(\d+|)$/, +        %{<label class="#{ocn_class}"><a name="#{@ocn}">\\1</a></label>})        end      end      def name -      %{<a name="#@paranum" />} +      %{<a name="#{@ocn}"></a>}      end      def id #w3c? "tidy" complains about numbers as identifiers ! annoying -      %{id="o#@paranum"} +      %{id="o#{@ocn}"}      end      def goto -      %{<a href="##@paranum">} -    end -  end -  class Paragraph_id_ocn #used by table version #work area 2003w48 -    attr_accessor :paranum,:font,:p_num -    def initialize(md,paranum) -      @paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,SiSU_HTML_Format::Paragraph_number.new(md,paranum) #font -    end -    def txt -      %{  <p #{@p_num.id} align="justify">#{@p_num.name} -  <font #{@vz.font_size_txt} #{@vz.font_color} #{@vz.font_face}>} -    end -    def txt_00 -      %{  <p #{@p_num.id} align="justify">#{@p_num.name} -  <font #{@vz.font_size_txt_00} #{@vz.font_color} #{@vz.font_face}>} -    end -    def font_citation -      %{<font #{@vz.font_size_txt} #{@vz.font_face}>} -    end -    def endnote -      %{  <p #{@p_num.id} align="justify">#{@p_num.name} -  <font #{@vz.font_size_endnote} #{@vz.font_color} #{@vz.font_face}>} -    end -    def table -      %{  <p #{@p_num.id} align="left">#{@p_num.name} -  <font #{@vz.font_small} #{@vz.font_color} #{@vz.font_face}>} -    end -    def tiny -      %{  <p #{@p_num.id} align="justify">#{@p_num.name} -  <font #{@vz.font_tiny} #{@vz.font_color} #{@vz.font_face}>} -    end -    def small -      %{  <p #{@p_num.id} align="justify">#{@p_num.name} -  <font #{@vz.font_small} #{@vz.font_color} #{@vz.font_face}>} # keep but not used? -    end -    def font_tiny -      %{<font #{@vz.font_tiny} #{@vz.font_face}>} -    end -    def font_small -      %{<font #{@vz.font_small} #{@vz.font_face}>} -    end -    def header_ -      %{  <p #{@p_num.id} align="center">#{@p_num.name} -  <font #@vz.font color="#@color" #{@vz.font_face}>} +      %{<a href="##{@ocn}">}      end    end    class Head_information      include SiSU_Viz -    include SiSU_HTML_Format      attr_reader :md,:sfx,:pdf,:rdf,:vz -    def initialize(md='') +    def initialize(md)        @md=md        @sfx,@pdf=@md.sfx,@md.pdf        @rdf=SiSU_XML_tags::RDF.new(md) @@ -188,6 +142,10 @@ module SiSU_HTML_Format      #{@vz.txt_home}    </a></h1>}      end +    def html_close #moved +    %{</body> +</html>} +    end    end    class Widget < Head_information      def initialize(md) @@ -272,6 +230,8 @@ module SiSU_HTML_Format        end      end    end +  class XML +  end    class Head_toc < Head_information      def initialize(md)        super(md) @@ -333,6 +293,25 @@ WOK  #{@vz.table_close}  <p />}      end +    def seg_head_navigation_band_bottom(type='') +      if type=~/pdf/ +        @tocband_segtoc=make_scroll_seg_pdf +      end +      firstseg=%{<a href="#{@md.fnl[:pre]}#{@md.firstseg}#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" alt="->"> +      #{@vz.png_nav_nxt} +    </a>} if @md.firstseg =~/\S+/ +      %{<table summary="table of contents segment navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> +<tr><td width="20%"> +   +</td> +<td width="60%" align="center"> +  #@tocband_segtoc +</td> +<td width="20%" align="right"> +   #{firstseg}  +#{@vz.table_close} +<p />} +    end      def manifest_link(text)    %{<font size=2>      <a href="#{@md.fn[:manifest]}" target="_top" #{@vz.js_manifest}>#{text}</a> @@ -401,20 +380,35 @@ WOK    <title>      #{@md.html_title}    </title> -  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> -  #{@rdf.rdftoc} -  #{@rdf.metatag_html} -  #{@vz.font_css_table_file} +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +#{@rdf.rdftoc} +#{@rdf.metatag_html} +#{@css.html}  </head>  #{@vz.color_body} -  <a name="top" id="top"></a> -  <a name="up" id="up"></a> -  <a name="start" id="start"></a> -  #{@vz.js_top}} +<a name="top" id="top"></a> +<a name="up" id="up"></a> +<a name="start" id="start"></a> +#{@vz.js_top}} +    end +    def concordance +      if @md.concord_make +      %{#{@vz.margin_css} +  <h4 class="toc"> +    <a href="./#{@md.fn[:concordance]}" #{@vz.js_concordance}> +      <i>Concordance</i> +    </a> +  </h4> +#{@vz.table_close}} +      else +      %{#{@vz.margin_css} +#{@vz.table_close}} +      end      end      def links_guide_vertical_open #???        url=(defined? @vz.url_hp) && @vz.url_hp =~/^http:\/\/\S+$/ ? @vz.url_hp : @vz.url_home -      %{<div id="vertical_links"> +      %{ +<div id="vertical_links">    <ul id="vertical">    <li class="refbold">      <a href="#{url}" #{@vz.js_home}> @@ -433,7 +427,8 @@ WOK      end      def links_guide_horizontal_open #???        url=(defined? @vz.url_hp) && @vz.url_hp =~/^http:\/\/\S+$/ ? @vz.url_hp : @vz.url_home -      %{<div id="horizontal_links"> +      %{ +<div id="horizontal_links">    <ul id="horizontal">    <li class="refbold">      <a href="#{url}" #{@vz.js_home}> @@ -475,7 +470,8 @@ WOK      </a>    </li>    </ul> -</div>} +</div> +}        end        %{ #{insert}  <!- quick ref -!>} @@ -540,15 +536,12 @@ WOK  #{@vz.table_close}}      end      def metadata -      %{#{@vz.margin_txt_3} -#{@vz.paragraph_font_small} -  <a href="#@metalink" #{@vz.js_metalink}> -    <i>MetaData</i> -    <font size="1" color="#777777"> -          -    </font> -  </a> -  </font> +      %{#{@vz.margin_css} +  <h4 class="toc"> +    <a href="#@metalink" #{@vz.js_metalink}> +      <i>MetaData</i> +    </a> +  </h4>  #{@vz.table_close}}      end      def seg_metadata @@ -556,7 +549,9 @@ WOK        metadata      end      def seg_tail -      %{<p> <p> +      %{ +<div class="main_column"> +<p> <p>  <table summary="toc segment tail" bgcolor=#{@vz.color_band1}>  <tr><td width="20%">    #{@vz.banner_band} @@ -575,11 +570,17 @@ WOK  <a name="end" id="end"></a>  <a name="finish" id="finish"></a>  <a name="stop" id="stop"></a> -<a name="credits"></a>} +<a name="credits"></a> +</div> +</div> +</div> +}      end -    def scroll_tail +    def scroll_tail #debug        nav=scroll_head_navigation_band -      %{#{nav} +      %{ +<div class="main_column"> +#{nav}  #{@vz.credits_splash}  #{@vz.credits_sisu}  <a name="bottom" id="bottom"></a> @@ -587,11 +588,17 @@ WOK  <a name="end" id="end"></a>  <a name="finish" id="finish"></a>  <a name="stop" id="stop"></a> -<a name="credits"></a>} +<a name="credits"></a> +</div> +</div> +</div> +}      end      def seg_navigation_tail #this is a bug area, look up and "tidy"        #nav=scroll_head_navigation_band -      %{<p> </p> +      %{ +<div class="main_column"> +<p> </p>  #{@vz.credits_splash}  #{@vz.credits_sisu}  <a name="bottom" id="bottom"></a> @@ -599,96 +606,15 @@ WOK  <a name="end" id="end"></a>  <a name="finish" id="finish"></a>  <a name="stop" id="stop"></a> -<a name="credits"></a>} -    end -  end -  def html_close -    %{</body> -</html>} -  end -  class Head_scroll < Head_toc -    def initialize(md) -      super(md) -    end -    def toc_owner_details -      %{#{@vz.margin_txt_3} -#{@vz.paragraph_font_small} -  <a href="#owner.details"> -    Owner Details -    <font size="1" color="#777777"> -          -    </font> -  </a> -  </font> -#{@vz.table_close}} -    end -    def table -      %{<table summary="scroll table" width=#{@vz.table_width_1} border="0" bgcolor="white" cellpadding="0"> -<tr><th width=#{@@indent['level_1']} align="right"> -</th> -<td valign="top"> -#{@vz.paragraph_txt}} -    end -    def table1 -      %{<table summary="scroll table1" width=#{@vz.table_width_1} border="0" cellpadding=#{@vz.table_cellpad_box} #{@vz.color_color_table1} align="justify"> -<tr><td valign="top"> -#{@vz.paragraph_txt}} -    end -    def table2 -      %{<table summary="scroll table2" width=#{@vz.table_width_1} border="0" cellpadding=#{@vz.table_cellpad_box} #{@vz.color_color_table2} align="justify"> -<tr><td valign="top"> -#{@vz.paragraph_txt}} -    end -    def toc_endnote -      %{#{@vz.margin_txt_3} -#{@vz.paragraph_font_small} -  <a href="#endnotes"> -    Endnotes -  </a> -#{@vz.table_close}} -    end -    def title_endnote -      %{#{@vz.margin_txt_0} -  #{@vz.paragraph_txt} -  <a name="endnotes" id="endnotes"></a> -#{@vz.margin_num} -    -#{@vz.table_close}} -    end -    def tail -      %{<br /> -#{@vz.margin_txt_0} -<table summary="scroll tail" bgcolor="#777777"> -<tr><td width="20%"> -#{@vz.banner_band} -</td> -<td width="60%"> -<center>#@tocband_scroll</center> -</td></tr> -</table> -<br /> -#{@vz.paragraph_txt} -  <center> -    #{@vz.credits_splash} -    #{@vz.credits_sisu} -  </center> -#{@vz.margin_num} -#{@vz.table_close} -<a name="bottom id="finish"></a> -<a name="down" id="down"></a> -<a name="end" id="end"></a> -<a name="finish" id="finish"></a> -<a name="stop" id="stop"></a> -<a name="credits" id="credits"></a> -<font color="white" size="0"> -  #{@md.title*10} -</font> -</body> -</html>} +<a name="credits"></a> +</div> +</div> +</div> +}      end    end    class Head_seg < Head_information -    def initialize(md) +    def initialize(md) #(md='')        super(md)      end      def head @@ -803,7 +729,8 @@ WOK        scroll=seg=''        wgt=Widget.new(@md)        #dir=SiSU_Env::Info_env.new(@md.fns) -      %{ +      x=if @md.concord_make +        %{  <table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0">  <tr>    #{wgt.seg(@vz.nav_txt_toc_link)} @@ -815,70 +742,36 @@ WOK    #{wgt.search}    #{wgt.home}  </tr></table>} -    end -    def toc_pre_next3 #used with seg_doc_types in seg_nav_band #with pdf & other doc types #knxjs -      %{<table summary="segment navigation pre/next" border="0" cellpadding="3" cellspacing="0"> -<tr><td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#{@seg_name_html[@seg_name_html_tracker-1]}#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_prev}> -    #{@vz.png_nav_previous} -  </a> -</td> -<td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#@index#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_toc}> -    #{@vz.png_nav_toc} -  </a> -</td> -<td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_next}> -    #{@vz.png_nav_next} -  </a> -#{@vz.table_close}} -    end -    def toc_next3 #used with seg_doc_types in seg_nav_band #with pdf & other doc types #knxjs -      %{<table summary="segment navigation next" border="0" cellpadding="3" cellspacing="0"> +      else +        %{ +<table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0">  <tr> -<td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#@index#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_toc}> -    #{@vz.png_nav_toc} -  </a> -</td> -<td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_next}> -    #{@vz.png_nav_next} -  </a> -#{@vz.table_close}} -    end -    def toc_pre3 #used with seg_doc_types in seg_nav_band #with pdf and other doc types #knxjs -    # note endnotes is now two back, with insertion between end of text and metadata, but what happens where no endnote? -      %{<table summary="segment navigation pre" border="0" cellpadding="3" cellspacing="0"> -<tr><td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#{@seg_name_html[@seg_name_html_tracker-2]}#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_prev}> -    #{@vz.png_nav_previous} -  </a></td> -<td align="center" bgcolor=#{@vz.color_band1}> -  <a href="#{@md.fnl[:pre]}#@index#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}" target="_top" #{@vz.js_toc}> -    #{@vz.png_nav_toc} -  </a> -#{@vz.table_close}} -    end -    def toc_endnote +  #{wgt.seg(@vz.nav_txt_toc_link)} +  #{wgt.scroll(@vz.nav_txt_doc_link)} +  #{wgt.pdf}#{wgt.odf} +<td align="center" bgcolor=#{@vz.color_band2}> +  #{wgt.manifest} +  #{wgt.search} +  #{wgt.home} +</tr></table>} +      end      end      def title_endnote(title,subtitle,creator,table_top_control) -      %{#{@vz.banner_instrument_cover_band_seg} -  <h1 class="banner"> -    #{title} -  </h1> -  <h1 class="subbanner"> -   #{subtitle} -  </h1> -  <h1 class="subbanner"> -    #{creator} -  </h1> -  <h4 class="banner"> -    Endnotes -  </h4> -#{@vz.table_close} -<h1>Endnotes</h1>} +#      %{#{@vz.banner_instrument_cover_band_seg} +#  <h1 class="banner"> +#    #{title} +#  </h1> +#  <h1 class="subbanner"> +#   #{subtitle} +#  </h1> +#  <h1 class="subbanner"> +#    #{creator} +#  </h1> +#  <h4 class="banner"> +#    Endnotes +#  </h4> +##{@vz.table_close} +#<h1>Endnotes</h1>}      end      def navigation_table        %{<table summary="navigation segment table" width=#{@vz.table_width_1} border="0" bgcolor="white" cellpadding="0"> @@ -934,7 +827,8 @@ WOK  </center>}      end      def credit -      %{<br/> +      %{ +<div class="main_column">  #{@vz.credits_splash}  #{@vz.credits_sisu}  <a name="bottom" id="bottom"></a> @@ -942,10 +836,12 @@ WOK  <a name="end" id="end"></a>  <a name="finish" id="finish"></a>  <a name="stop" id="stop"></a> -<a name="credits" id="credits"></a>} +<a name="credits" id="credits"></a> +</div></div> +}      end -    def navigation_band(segtocband,seg_table_top_control) -      %{<table summary="segment navigation band" bgcolor=#{@vz.color_band1} width="100%"><tr> +    def navigation_band(segtocband,seg_table_top_control) #change name to navigaion_band_banner +      %{<table summary="segment navigation band with banner" bgcolor=#{@vz.color_band1} width="100%"><tr>  <td width="20%" align="left">  #{@vz.banner_band}  </td> @@ -958,140 +854,575 @@ WOK  </table>  #{seg_table_top_control}}      end +    def navigation_band_bottom(segtocband,seg_table_top_control) #change name to navigaion_band_bannerless +      %{ +<div class="main_column"> +  <table summary="segment navigation band" bgcolor=#{@vz.color_band1} width="100%"><tr> +  <td width="70%" align="center"> +    #{doc_types} +  </td> +  <td width="30%" align="right"> +    #{segtocband} +  </td></tr> +  </table> +  #{seg_table_top_control} +</div> +} +    end      def endnote_mark -%{<p class="center" id="endnotes"> -<a href="#top"><hr width=90% /></a> -</p>} #revisit +%{ +<p class="center" id="endnotes"> +  <hr class="endnote" /> +</p>} +    end +    def endnote_section_open +%{ +<div class="endnote"> +} +    end +    def endnote_section_close +%{ +</div> +} #revisit +    end +    def head +      %{#{doc_type} +<head> +  <title> +    #{@seg_name_html[@seg_name_html_tracker]} - +    #{@md.html_title} +  </title> +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +#{@rdf.rdfseg} +#{@rdf.metatag_html} +#{@css.html} +</head> +#{@vz.color_body} +<a name="top" id="top"></a> +<a name="up" id="up"></a> +<a name="start" id="start"></a> +#{@vz.js_top}} +    end +    def toc_metadata +      @metalink=%{./#{@md.fn[:meatadata]}} +      toc_metadata +    end +    def title_banner(title,subtitle,creator) +      %{ +<div class="summary"> +  <p class="tiny"> +    #{title} +  </p> +  <p class="tiny"> +    #{subtitle} +  </p> +  <p class="tiny"> +    #{creator} +  </p> +  <p class="tiny"> +    copy @ +    <a href="#{@vz.url_home}"> +      #{@vz.txt_home} +    </a> +  </p> +</div> +} +    end +  end +  class Head_scroll < Head_toc +    def initialize(md) #(md='') +      super(md) +    end +    def toc_owner_details +      %{#{@vz.margin_txt_3} +#{@vz.paragraph_font_small} +  <a href="#owner.details"> +    Owner Details +    <font size="1" color="#777777"> +          +    </font> +  </a> +  </font> +#{@vz.table_close}} +    end +    def table +      %{<table summary="scroll table" width=#{@vz.table_width_1} border="0" bgcolor="white" cellpadding="0"> +<tr><th width=#{@@indent['level_1']} align="right"> +</th> +<td valign="top"> +#{@vz.paragraph_txt}} +    end +    def table1 +      %{<table summary="scroll table1" width=#{@vz.table_width_1} border="0" cellpadding=#{@vz.table_cellpad_box} #{@vz.color_color_table1} align="justify"> +<tr><td valign="top"> +#{@vz.paragraph_txt}} +    end +    def table2 +      %{<table summary="scroll table2" width=#{@vz.table_width_1} border="0" cellpadding=#{@vz.table_cellpad_box} #{@vz.color_color_table2} align="justify"> +<tr><td valign="top"> +#{@vz.paragraph_txt}} +    end +##     def toc_endnote +##       %{#{@vz.margin_txt_3} +## #{@vz.paragraph_font_small} +##   <a href="#endnotes"> +##     Endnotes +##   </a> +## #{@vz.table_close}} +##     end +#    def toc_endnote +#      %{#{@vz.margin_css} +#  <h4 class="toc"> +#    <a href="#endnotes"> +#      Endnotes +#    </a> +#  </h4> +##{@vz.table_close}} +#    end +    def title_endnote #revisit +#      %{#{@vz.margin_txt_0} +#  #{@vz.paragraph_txt} +#  <a name="endnotes" id="endnotes"></a> +##{@vz.margin_num} +#    +##{@vz.table_close}}      end    end    class Format_text_object      @vz=SiSU_Env::Get_init.instance.skin      @@dp=nil -    attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped -    def initialize(md='',*txt) -      @md,@one,@two,@three=md,txt[0],txt[1],txt[2] -      rgx=/^#{Mx[:lv_o]}\d:\S*?#{Mx[:lv_c]}/ -      @one_stripped=@one.gsub(rgx,'') if @one =~rgx -      @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern -      rgx=/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/ #problem introduced -      @one_stripped=@one.gsub(rgx,'\1') if @one =~rgx #problem introduced -      @link,@linkname=txt[0],txt[1] -      @format,parablock=txt[0],txt[1] -      @parablock=parablock -      ##performance hit does not justify action: -      #@parablock=if parablock=~/\S+/ and parablock !~/<!Th?¡ /um -      #  wrap=SiSU_text_utils::Wrap.new(parablock,70,4) -      #  wrap.line_wrap -      #else parablock -      #end -      if txt[2]=~/\d+/ -        @paranum=txt[2][/(\d+)/m,1] # unless paranum =~/#/ -        @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,@paranum) -        @para_id=Paragraph_id_ocn.new(@md,@paranum) #used by table version +    attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt            =t_o[:txt]            || nil +        @ocn            =t_o[:ocn]            || nil +        @ocn_display    =t_o[:ocn_display]    || nil +        @headname       =t_o[:headname]       || nil +        @trailer        =t_o[:trailer]        || nil +        @endnote_part_a =t_o[:endnote_part_a] || nil +        @endnote_part_b =t_o[:endnote_part_b] || nil +        @lnk_url        =t_o[:lnk_url]        || nil +        @lnk_txt        =t_o[:lnk_txt]        || nil +        @format         =t_o[:format]         || nil +        @target         =t_o[:target]         || nil #occasionally passed but not used +      else +        if @md.cmd =~/M/ +          p t_o.class +          p caller +        end        end -      @headname='' -      if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ -        headname=$1 #format[/\d~(\S+)/m,1] -        @headname=if headname =~/^[a-zA-Z]/; %{<a name="#{headname}" id="#{headname}"></a>} #consider: h_#{headname} -        else %{<a name="h#{headname}" id="h#{headname}"></a>} +      if @txt and not @txt.empty? +        @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') +      end +      if @ocn and @ocn=~/\d+/ #WATCH FIX +        @p_num=Paragraph_number.new(@md,@ocn) +      end +      if @format and not @format.empty? +        if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ +          headname=$1 #format[/\d~(\S+)/m,1] +          @headname=if headname =~/^[a-zA-Z]/; %{<a name="#{headname}" id="#{headname}"></a>} #consider: h_#{headname} +          else %{<a name="h#{headname}" id="h#{headname}"></a>} +          end          end        end        @vz=SiSU_Env::Get_init.instance.skin      end -    def para_form(tag,attrib)                                                        # regular paragraphs shaped here +    def endnote_body +      %{ +<p class="endnote"> +  #{@txt} +</p> +} +    end +    def endnote_body_indent +      %{ +  <p class="endnote_indent"> +    #{@txt} +  </p> +} +    end +    def no_paranum +      %{ +<div class="substance"> +  <label class="ocn"> </label> +  <p class="norm"> +    #{@txt} +  </p> +</div> +} +    end +    def para_form_css(tag,attrib)                                                    # regular paragraphs shaped here        ul=ulc=''        ul,ulc="<ul>\n  ","\n  </ul>" if @tag =~/li/ -      %{#{@vz.margin_css} -  #{ul}<#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} -    #@parablock -  </#{tag}>#{ulc} -#{@vz.margin_num_css} +      %{ +<div class="substance">    #{@p_num.ocn_display} -#{@vz.table_close} +  #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> +    #{@txt} +  </#{tag}>#{ulc} +</div>  }      end      def para -      para_form('p','norm') +      para_form_css('p','norm')      end      def code -      para_form('p','code') +      para_form_css('p','code')      end      def center -      para_form('p','center') +      para_form_css('p','center')      end      def bold -      para_form('p','bold') +      para_form_css('p','bold')      end      def bullet -      para_form('li','bullet') +      para_form_css('li','bullet') +    end +    def format(tag,attrib) +      para_form_css(tag,attrib) +    end + +    def header_normal(tag,attrib) +      %{ +<div class="substance"> +  #{@p_num.ocn_display} +  <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} +    #{@headname}#{@txt} +  </#{tag}> +</div> +}      end -    def format(tag,atrib) -      para_form(tag,atrib) +    def heading_body +      header_normal('p','norm')      end -    def dl -      "<dl><b>#@one</b> #@two</dl>" +    def heading_body1 +      header_normal('h1','norm')      end -    def table_end                                                                #<!TZ!> -      %{</table> -  #{@vz.margin_num_css.strip} -    #{@p_num.ocn_display} -  #{@vz.table_close}} +    def heading_body2 +      header_normal('h2','norm')      end -    def no_paranum -      %{#{@vz.margin_css} -#{@vz.paragraph_txt} -  #@one #@two -#{@vz.margin_num} -#{@vz.table_close}} +    def heading_body3 +      header_normal('h3','norm') +    end +    def heading_body4 +      header_normal('h4','norm') +    end +    def heading_body5 +      header_normal('h5','norm') +    end +    def heading_body6 +      header_normal('h6','norm') +    end +    def title_header(tag,attrib) +      %{ +<div class="content"> +<#{tag} class="#{attrib}"> +    #{@txt} +  </#{tag}> +</div> +} +    end +    def title_header1 +      title_header('h1','tiny') +    end +    def title_header2 +      title_header('h2','tiny') +    end +    def title_header3 +      title_header('h3','tiny') +    end +    def title_header4 +      '' +    end +    def title_header4_old +      %{ +<div class="substance"> +  <label class="ocn"> </label> +  <h4 class="banner"> +    #{@txt} +  </h4> +</div> +} +    end +    def dl #check :trailer +      "<dl><b>#{@txt}</b> #{@trailer}</dl>" +    end +    def table_css_end      #<!TZ!> +      '</table> +    </p> +  </div>'      end      def gsub_body -      case @one +      case @txt        when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ -        @one.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') -        @one.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>') +        @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>') +        @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>')        when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/ -        @one.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') -        @one.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>') +        @txt.gsub!(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>') +        @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</b>')        when /^\s*\d{1,3}\.\s/ -        @one.gsub!(/^\s*(\d+\.)/,'<b>\1</b>') +        @txt.gsub!(/^\s*(\d+\.)/,'<b>\1</b>')        when /^\s*[A-Z]\.\s/ -        @one.gsub!(/^\s*([A-Z]\.)/,'<b>\1</b>') +        @txt.gsub!(/^\s*([A-Z]\.)/,'<b>\1</b>')        end      end      def bold_para        %{#{@vz.margin_txt_0}    <p class="bold"> -    #@one +    #{@txt}    </p>  #{@vz.margin_num_css}         #{@vz.table_close}}      end      def bold_header -      @one.gsub!(/[1-9]~(\S+)/,'<a name="\1"></a>') -      @one.gsub!(/[1-9]~/,'') -      @one.gsub!(/#{Mx[:id_o]}~0;[um]\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}\s*$/i,'') #watch & do differently +      @txt.gsub!(/[1-9]~(\S+)/,'<a name="\1"></a>') +      @txt.gsub!(/[1-9]~/,'') +      @txt.gsub!(/#{Mx[:id_o]}~0;[um]\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}\s*$/i,'') #watch & do differently        %{<p class="bold"> -    #@one +    #{@txt}    </p>  #{@vz.margin_num_css}         #{@vz.table_close}}      end      def toc_head_copy_at -      %{<p class="center">#@one</p>\n} +      %{<p class="center">#{@txt}</p>\n}      end      def center -      %{<p class="center">#@one</p>\n} +      %{<p class="center">#{@txt}</p>\n}      end      def bold -      %{<p class="bold">#@one</p>\n} +      %{<p class="bold">#{@txt}</p>\n}      end      def center_bold -      %{<p class="centerbold">#@one</p>\n} +      %{<p class="centerbold">#{@txt}</p>\n}      end    end -  class XML +  class Format_scroll < Format_text_object +    def initialize(md,txt) +      super(md,txt) +      @vz=SiSU_Env::Get_init.instance.skin +    end +  end +  class Format_seg < Format_text_object +    def initialize(md,txt) +      super(md,txt) +    end +    def navigation_toc_lev1_advert +      %{#{@banner.home_button}\n +<center> +#{@txt} +#@two +</a></center><p />} +    end +    def navigation_toc_lev1 +      %{#{@banner.nav_toc}} +    end +    def navigation_toc_lev2                                                      #change bold use css +      %{<p /> +<table summary="navigation segment level 2"> +<tr><td width ="20"> +</td> +<td> +  <font size="3" #{@vz.font_face}> +    <b>#{@txt}</b> +  </font> +  </p> +#{@vz.table_close}} +    end +    def navigation_toc_lev3                                                      #change bold use css +      %{<p /> +<table summary="navigation segment level 3"> +<tr><td width ="20"> +</td> +<td> +  <font size="3" #{@vz.font_face}> +    <b>#{@txt}</b> +  </font> +  </p> +#{@vz.table_close}} +    end +    def navigation_toc_lev4 +      %{<table summary="navigation segment level 4"> +<tr><td width ="80"> +</td> +<td> +<p> +  #{@txt} +</p> +#{@vz.table_close}} +    end +    def navigation_toc_lev5 +    end +    def navigation_toc_lev6 +    end +    def endnote_seg_body(fn='')  #FIX                                                #url construction keep within single line... BUG WATCH 200408 +      fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info +      %{ +  <p class="endnote"> +    #{@endnote_part_a}#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#{@endnote_part_b} +  </p> +} +    end +    def subtoc_lev(tag,attrib) +      txt=if @txt \ +      and @txt =~/<\/?i>|<a\s+name="\S+?">/mi +        @txt.gsub(/<\/?i>|<a\s+name="\S+?">/mi,'') #removes name markers from subtoc, go directly to substantive text +      else @txt +      end +      note='' +      if txt =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream +        note=$1 +        note.gsub!(/[\n\s]+/m,' ') +        txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') +        txt.gsub!(/<a[\n\s]+name="-\d+"[\n\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'') +      end +      %{<#{tag} class="#{attrib}"> +    <a href="##{@ocn}"><i>#{txt}</i></a> #{note} +  </#{tag}>} +    end +    def subtoc_lev5 +      subtoc_lev('h5','subtoc') if @txt +    end +    def subtoc_lev6 +      subtoc_lev('h6','subtoc') if @txt +    end +    #% para sisu +    def header_sub(tag,attrib) +      @txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') +      %{ +<div class="substance"> +  #{@p_num.ocn_display} +  <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headname} +    #{@txt} +  </#{tag}> +</div> +} +    end +    def header5 +      header_sub('p','bold') +    end +    def header6 +      header_sub('p','bold') +    end +    def header4 +      %{ +<div class="substance"> +  #{@p_num.ocn_display} +  <h1 class="norm" #{@p_num.id}>#{@p_num.name} +    #{@t_o[:format]} +    #{@txt} +  </h1> +</div> +} +    end +    def navigation_header4 +      %{<table summary="navigation segment header 4" width=100% bgcolor="#08163f" border="0"> +<tr><td align="center"> +<p class="bold"> +  #{@txt} +</p> +#{@vz.table_close}} +    end +    def navigation_header5 +      %{<p class="bold"> +  #{@txt} +</p>} +    end +    def navigation_header6 +      %{<p class="bold"> +  #{@txt} +</p>} +    end +    def navigation_center +      "<center>#{@txt}</center>" +    end +  end +  class Format_toc < Format_text_object +    def initialize(md,txt) +      super(md,txt) +    end +    def links_guide +      %{  <li class="doc"> +    <a href="#{@lnk_url}" target="_top"> +      #{@lnk_txt} +    </a> +  </li> +} +    end +    def lev(tag,attrib) +      if @txt +        %{<#{tag} class="#{attrib}"> +    #{@txt} +  </#{tag}> +} +      else '' +      end +    end +    def lev1 +      lev('h1','toc') +    end +    def lev2 +      lev('h2','toc') +    end +    def lev3 +      lev('h3','toc') +    end +    def lev4 +      lev('h4','toc') +    end +    def lev5 +      lev('h5','toc') +    end +    def lev6 +      lev('h6','toc') +    end +    def lev0 #docinfo +      lev('h0','toc') +    end +    def mini_lev1 +      lev('h1','minitoc') +    end +    def mini_lev2 +      lev('h2','minitoc') +    end +    def mini_lev3 +      lev('h3','minitoc') +    end +    def mini_lev4 +      lev('h4','minitoc') +    end +    def mini_lev5 +      lev('h5','minitoc') +    end +    def mini_lev6 +      lev('h6','minitoc') +    end +    def mini_lev0 #docinfo +      lev('h0','minitoc') +    end +    def mini_tail +#  <h0 class="minitoc"> +#    <a href="metadata.html">Document Information (metadata)</a> +#  </h0> +  %{ +  <h4 class="minitoc"> +    <a href="sisu_manifest.html">Manifest (alternative outputs)</a> +  </h4> +} +    end +    def mini_concord_tail +  %{ +  <h4 class="minitoc"> +    <a href="concordance.html">Concordance (wordlist)</a> +  </h4> +  <h4 class="minitoc"> +    <a href="sisu_manifest.html">Manifest (alternative outputs)</a> +  </h4> +} +    end    end  end  __END__ diff --git a/lib/sisu/v0/html_format_css.rb b/lib/sisu/v0/html_format_css.rb deleted file mode 100644 index ace6983b..00000000 --- a/lib/sisu/v0/html_format_css.rb +++ /dev/null @@ -1,480 +0,0 @@ -# coding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -   2007, 2008 Ralph Amissah All Rights Reserved. - - * License: GPL 3 or later: - -   SiSU, a framework for document structuring, publishing and search - -   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -   2007, 2008 Ralph Amissah - -   This program is free software: you can redistribute it and/or modify it -   under the terms of the GNU General Public License as published by the Free -   Software Foundation, either version 3 of the License, or (at your option) -   any later version. - -   This program is distributed in the hope that it will be useful, but WITHOUT -   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for -   more details. - -   You should have received a copy of the GNU General Public License along with -   this program. If not, see <http://www.gnu.org/licenses/>. - -   If you have Internet connection, the latest version of the GPL should be -   available at these locations: -   <http://www.fsf.org/licensing/licenses/gpl.html> -   <http://www.gnu.org/licenses/gpl.html> - -   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> -   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> -   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> - - * SiSU uses: -   * Standard SiSU markup syntax, -   * Standard SiSU meta-markup syntax, and the -   * Standard SiSU object citation numbering and system - - * Hompages: -   <http://www.jus.uio.no/sisu> -   <http://www.sisudoc.org> - - * Download: -   <http://www.jus.uio.no/sisu/SiSU/download.html> - - * Ralph Amissah -   <ralph@amissah.com> -   <ralph.amissah@gmail.com> - - ** Description: html formating, css template - -=end -module SiSU_HTML_Format_type -  require "#{SiSU_lib}/html_format" -  include SiSU_Viz -  include SiSU_HTML_Format -  class Head_toc < SiSU_HTML_Format::Head_toc -    def initialize(md='') -      super(md) -    end -    def head -      %{#{doc_type} -<head> -  <title> -    #{@md.html_title} -  </title> -<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> -#{@rdf.rdftoc} -#{@rdf.metatag_html} -#{@css.html} -</head> -#{@vz.color_body} -<a name="top" id="top"></a> -<a name="up" id="up"></a> -<a name="start" id="start"></a> -#{@vz.js_top}} -    end -    def concordance -      if @md.concord_make -      %{#{@vz.margin_css} -  <h4 class="toc"> -    <a href="./#{@md.fn[:concordance]}" #{@vz.js_concordance}> -      <i>Concordance</i> -    </a> -  </h4> -#{@vz.table_close}} -      else -      %{#{@vz.margin_css} -#{@vz.table_close}} -      end -    end -    def metadata -      %{#{@vz.margin_css} -  <h4 class="toc"> -    <a href="#@metalink" #{@vz.js_metalink}> -      <i>MetaData</i> -    </a> -  </h4> -#{@vz.table_close}} -    end -  end -  class Head_seg < SiSU_HTML_Format::Head_seg -    def initialize(md='') -      super(md) -    end -    def head -      %{#{doc_type} -<head> -  <title> -    #{@seg_name_html[@seg_name_html_tracker]} - -    #{@md.html_title} -  </title> -<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> -#{@rdf.rdfseg} -#{@rdf.metatag_html} -#{@css.html} -</head> -#{@vz.color_body} -<a name="top" id="top"></a> -<a name="up" id="up"></a> -<a name="start" id="start"></a> -#{@vz.js_top}} -    end -    def toc_metadata -      @metalink=%{./#{@md.fn[:meatadata]}} -      toc_metadata -    end -    def title_banner(title,subtitle,creator) -      %{<p class="tiny"> -    #{title} -  </p> -  <p class="tiny"> -    #{subtitle} -  </p> -  <p class="tiny"> -    #{creator} -  </p> -  <p class="tiny"> -    copy @ -    <a href="#{@vz.url_home}"> -      #{@vz.txt_home} -    </a> -  </p>} -    end -  end -  class Head_scroll < SiSU_HTML_Format::Head_scroll -    def initialize(md='') -      super(md) -    end -    def toc_endnote -      %{#{@vz.margin_css} -  <h4 class="toc"> -    <a href="#endnotes"> -      Endnotes -    </a> -  </h4> -#{@vz.table_close}} -    end -  end -  class Format_scroll < SiSU_HTML_Format::Format_text_object -    def initialize(md='',*txt) -      super(md,*txt) -      @vz=SiSU_Env::Get_init.instance.skin -    end -    def indent_one_no_paranum -      %{#{@vz.margin_txt_1} -#{@paragraph.txt} -  #@one -#{@vz.margin_num} -#{@vz.table_close}} -    end -    def indent_two_no_paranum -      %{#{@vz.margin_txt_1} -#{@paragraph.txt} -  #@one -#{@vz.margin_num} -#{@vz.table_close}} -    end -    def endnote_body -      %{#{@vz.margin_css} -  <p class="endnote"> -    #@one -  </p> -#{@vz.margin_num_css} -    -#{@vz.table_close}} -    end -    def header_normal -      %{#{@vz.margin_css} -  <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} -    #@headname -    #@parablock -  </#@tag> -#{@vz.margin_num_css} -  #{@p_num.ocn_display} -#{@vz.table_close}} -    end -    def heading_body -      @tag,@class='p','norm' -      header_normal -    end -    def heading_body1 -      @tag,@class='h1','norm' -      header_normal -    end -    def heading_body2 -      @tag,@class='h2','norm' -      header_normal -    end -    def heading_body3 -      @tag,@class='h3','norm' -      header_normal -    end -    def heading_body4 -      @tag,@class='h4','norm' -      header_normal -    end -    def heading_body5 -      @tag,@class='h5','norm' -      header_normal -    end -    def heading_body6 -      @tag,@class='h6','norm' -      header_normal -    end -  end -  class Format_seg < SiSU_HTML_Format::Format_text_object -    def initialize(md='',*txt) -      super(md,*txt) -    end -    def navigation_para -      %{#{@vz.margin_css} -#{@paragraph.txt} -  #@one -</p> -#{@vz.table_close}} -    end -    def navigation_toc_lev1_advert -      %{#{@banner.home_button}\n -<center> -#@one -#@two -</a></center><p />} -    end -    def navigation_toc_lev1 -      %{#{@banner.nav_toc}} -    end -    def navigation_toc_lev2                                                      #change bold use css -      %{<p /> -<table summary="navigation segment level 2"> -<tr><td width ="20"> -</td> -<td> -  <font size="3" #{@vz.font_face}> -    <b>#@one</b> -  </font> -  </p> -#{@vz.table_close}} -    end -    def navigation_toc_lev3                                                      #change bold use css -      %{<p /> -<table summary="navigation segment level 3"> -<tr><td width ="20"> -</td> -<td> -  <font size="3" #{@vz.font_face}> -    <b>#@one</b> -  </font> -  </p> -#{@vz.table_close}} -    end -    def navigation_toc_lev4 -      %{<table summary="navigation segment level 4"> -<tr><td width ="80"> -</td> -<td> -<p> -  #@one -</p> -#{@vz.table_close}} -    end -    def navigation_toc_lev5 -    end -    def navigation_toc_lev6 -    end -    def endnote_body_seg_tail -      %{#{@vz.margin_css} -  <p class="endnote"> -    #@one -  </p> -#{@vz.margin_num_css}  -#{@vz.table_close}} -    end -    def endnote_body_seg_tail_indent -      %{#{@vz.margin_css} -  <p class="endnote_indent"> -    #@one -  </p> -#{@vz.margin_num_css}  -#{@vz.table_close}} -    end -    def endnote_seg_body(fn='')                                                  #url construction keep within single line... BUG WATCH 200408 -      fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info -      %{#{@vz.margin_css} -  <p class="endnote"> -    #@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three -  </p> -#{@vz.margin_num_css}  -#{@vz.table_close}} -    end -    def title_header -      %{#{@vz.margin_css} -  <#@tag class="#@class"> -    #@one -  </#@tag> -#{@vz.margin_num_css}  -#@two -#{@vz.table_close}} -    end -    def title_header1 -      @tag,@class='h1','banner' -      title_header -    end -    def title_header2 -      @tag,@class='h2','banner' -      title_header -    end -    def title_header3 -      @tag,@class='h3','banner' -      title_header -    end -    def title_header4 -      %{#{@vz.margin_css} -  <h4 class="banner"> -    #@one -  </h4> -#{@vz.margin_num_css}  -#{@vz.table_close}} -    end -    def subtoc_lev -      one=if @one \ -      and @one =~/<\/?i>|<a\s+name="\S+?">/mi -        @one.gsub(/<\/?i>|<a\s+name="\S+?">/mi,'') #removes name markers from subtoc, go directly to substantive text -      else @one -      end -      note='' -      if one =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream -        note=$1 -        note.gsub!(/[\n\s]+/m,' ') -        one.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') -        one.gsub!(/<a[\n\s]+name="-\d+"[\n\s]+href="#_\d+"> <sup>\d+<\/sup> /m,'') -      end -      %{<#@tag class="#@class"> -    <a href="##@two"> -      <i>#{one}</i> -    </a> #{note} -  </#@tag>} -    end -    def subtoc_lev5 -      @tag,@class='h5','subtoc' -      subtoc_lev if @one -    end -    def subtoc_lev6 -      @tag,@class='h6','subtoc' -      subtoc_lev if @one -    end -    #% para sisu -    def header4 -      %{#@format #{@vz.margin_css} -  <h1 class="norm" #{@p_num.id}>#{@p_num.name} -    #@format -    #@parablock -  </h1> -#{@vz.margin_num_css} -#{@p_num.ocn_display} -#{@vz.table_close}} -    end -    def header_sub -      @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') -      %{#{@vz.margin_css} -#{@headname} -  <#@tag class="#@class" #{@p_num.id}>#{@p_num.name} -    #{@parablock} -  </#@tag> -#{@vz.margin_num_css} -#{@p_num.ocn_display} -#{@vz.table_close}} -    end -    def header5 -      @tag,@class='p','bold' -      header_sub -    end -    def header6 -      @tag,@class='p','bold' -      header_sub -    end -    def navigation_header4 -      %{<table summary="navigation segment header 4" width=100% bgcolor="#08163f" border="0"> -<tr><td align="center"> -<p class="bold"> -  #@parablock -</p> -#{@vz.table_close}} -    end -    def navigation_header5 -      %{<p class="bold"> -  #@parablock -</p>} -    end -    def navigation_header6 -      %{<p class="bold"> -  #@parablock -</p>} -    end -    def navigation_indent1 -      %{#{@vz.margin_txt_00_1} -#{@paragraph.txt_00} -    #@parablock -  </font> -  </p> -#{@vz.margin_num_css}  -#{@vz.table_close}} -    end -    def navigation_indent2 -    end -    def navigation_center -      "<center>#@parablock</center>" -    end -  end -  class Format_toc < SiSU_HTML_Format::Format_text_object -    def initialize(md='',*txt) -      super(md,*txt) -    end -    def links_guide -      #@three distinguishes between _top and external, can be used e.g. for different colour scheme -      %{  <li class="doc"> -    <a href="#@link" target="_top"> -      #@linkname -    </a> -  </li> -} -    end -    def lev(tag,attrib) -  %{<#{tag} class="#{attrib}"> -    #@one -  </#{tag}> -} -    end -    def lev1 -      lev('h1','toc') -    end -    def lev2 -      lev('h2','toc') -    end -    def lev3 -      lev('h3','toc') -    end -    def lev4 -      lev('h4','toc') -    end -    def lev5 -      lev('h5','toc') -    end -    def lev6 -      lev('h6','toc') -    end -    def lev0 #docinfo -      lev('h0','toc') -    end -  end -end -__END__ diff --git a/lib/sisu/v0/html_minitoc.rb b/lib/sisu/v0/html_minitoc.rb new file mode 100644 index 00000000..44ed57d2 --- /dev/null +++ b/lib/sisu/v0/html_minitoc.rb @@ -0,0 +1,241 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search +   minitoc + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007, 2008 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + +   SiSU, a framework for document structuring, publishing and search + +   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, +   2007 Ralph Amissah + +   This program is free software: you can redistribute it and/or modify it +   under the terms of the GNU General Public License as published by the Free +   Software Foundation, either version 3 of the License, or (at your option) +   any later version. + +   This program is distributed in the hope that it will be useful, but WITHOUT +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +   more details. + +   You should have received a copy of the GNU General Public License along with +   this program. If not, see <http://www.gnu.org/licenses/>. + +   If you have Internet connection, the latest version of the GPL should be +   available at these locations: +   <http://www.fsf.org/licensing/licenses/gpl.html> +   <http://www.gnu.org/copyleft/gpl.html> + +   <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> +   <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> + + * SiSU uses: +   * Standard SiSU markup syntax, +   * Standard SiSU meta-markup syntax, and the +   * Standard SiSU object citation numbering and system + + * Hompages: +   <http://www.jus.uio.no/sisu> +   <http://www.sisudoc.org> + + * Download: +   <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah +   <ralph@amissah.com> +   <ralph.amissah@gmail.com> + + ** Description: system environment, resource control and configuration details + +=end +  module SiSU_HTML_minitoc +    require "#{SiSU_lib}/html_tune" +    include SiSU_Tune +    class Toc_mini +      @@seg_mini=nil +      @@seg_url='' +      @@dp,@@firstseg=nil,nil +      def initialize(md,data) +        @md,@data=md,data +        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern +        @pat_heading=/^#{Mx[:lv_o]}[1-6]:\S*?#{Mx[:lv_c]}\s*(.*)#{Mx[:id_o]}~(\d+);(?:[hm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +        @pat_strip_heading_name=/<a name="h?\d.*?">(.+?)<\/a>/ +        @tell=SiSU_Screen::Ansi.new(@md.cmd) if @md +      end +      def songsheet +        SiSU_Screen::Ansi.new(@md.cmd,'Toc').txt_grey unless @md.cmd =~/q/ +        toc=nil +        @toc=[] +        @data.each do |txt| +          if txt =~/^(?:#{Mx[:lv_o]}[1-6]:|4~!)/ +            txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,'') #remove endnotes from toc +            txt.gsub!(/<a name="-\d+" href="#_\d+"> <sup>\d+<\/sup> <\/a>/,'') +            txt.gsub!(@pat_strip_heading_name,'\1') +            txt.gsub(/(.*?)<a name="(\d+)"><\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect +            toc=case txt +            when /^\s*#{Mx[:lv_o]}1:\S*/; Toc_mini.new(@md,txt).level_1 +            when /^\s*#{Mx[:lv_o]}2:\S*/; Toc_mini.new(@md,txt).level_2 +            when /^\s*#{Mx[:lv_o]}3:\S*/; Toc_mini.new(@md,txt).level_3 +            when /^\s*#{Mx[:lv_o]}4:\S+/; Toc_mini.new(@md,txt).level_4 +            when /^\s*#{Mx[:lv_o]}5:\S*/; Toc_mini.new(@md,txt).level_5 +            when /^\s*#{Mx[:lv_o]}6:\S*/; Toc_mini.new(@md,txt).level_6 +            when /^\s*4~!/;      Toc.new(txt).level_crosslink +            else +            end +            @toc << toc +          end +        end +        @toc +      end +    protected +      def level_concordance +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) +        @@seg_mini << format_head_toc.mini_seg_concordance +      end +      def level_metadata +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) +        @@seg_mini << format_head_toc.mini_seg_metadata +      end +      def level_word_index +        format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c) +        @@seg_mini << format_head_toc.mini_concordance +      end +      def level_1 +        txt=@data +        unless txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +          txt.gsub!(@pat_strip_heading_name,'\1') +        end +        txt[@pat_heading] +        linkname,ocn=$1.strip,$2 if $& +          title=unless txt =~/Document Information/; linkname +        else +          link='metadata' +          %{<b><a href="#{@md.fnl[:pre]}#{link}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}">#{linkname}</a></b>} +        end +        toc={} +        txt_obj={:txt =>title} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) +        toc_mini=if txt =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ +          format_toc.mini_tail +        else format_toc.mini_lev1 +        end +        toc_mini +      end +      def level_2 +        txt=@data +        unless txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +          txt.gsub!(@pat_strip_heading_name,'\1') +        end +        txt[@pat_heading] +        linkname,ocn=$1.strip,$2 if $& +        txt_obj={:txt =>linkname} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) +        toc_mini=format_toc.mini_lev2 +        toc_mini +      end +      def level_3 +        txt=@data +        txt[@pat_heading] +        linkname,ocn=$1.strip,$2 if $& +        txt_obj={:txt =>linkname} +        format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) +        toc_mini=format_toc.mini_lev3 +        toc_mini +      end +      def level_4 +        txt=@data +        unless txt =~/~metadata/ +          unless txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +            txt.gsub!(@pat_strip_heading_name,'\1') +            txt[@pat_heading] +            linkname,ocn=$1.strip,$2 if $& +          end +          txt.gsub!(/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') +          if txt =~/^#{Mx[:lv_o]}4:/ +            seg_link=txt.gsub(/^\s*#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}\s*(.+?)$/, +              %{  <a href="#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}" target="_top"> +    \\2 +  </a> }) +            if seg_link =~/(#{Mx[:id_o]}\~\d+;(?:\w|[0-6]:\d+);\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})$/m +              m=/#{$1}/m +              seg_link.gsub!(m,'') +            end +            @@seg_url=txt[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?$/,1] +          elsif txt =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ +            seg_link=txt.gsub(/^\s*(#{@md.lv4}\s+)\s*(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/, +              %{<a href="#{@md.fnl[:pre]}\\2#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}" } + +              %{target="_top">\\1 \\2 \\3</a> }) +          end +          txt_obj={:txt =>seg_link} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) +          toc_mini=format_toc.mini_lev4 +          toc_mini +        end +      end +      def level_5 +        txt=@data +        if txt !~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +          txt.gsub!(@pat_strip_heading_name,'\1') +        end +        txt[@pat_heading] +        linkname,ocn=$1.strip,$2 if $& +        if ocn \ +        and ocn !~/#/ +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) +        end +        toc={} +        if txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +          m=/#{$1}/ +          txt.gsub!(m,'') +          title=linkname +        else +          lnk_n_txt=%{  <a href="#{@md.fnl[:pre]}#{@@seg_url}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}##{ocn}"> +    #{linkname} +  </a>} +          txt_obj={:txt =>lnk_n_txt} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) +          toc_mini=format_toc.mini_lev5 +        end +        toc_mini +      end +      def level_6 +        txt=@data +        if txt !~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +          txt.gsub!(@pat_strip_heading_name,'\1') +        end +        txt[@pat_heading] +        linkname,ocn=$1.strip,$2 if $& +        if ocn \ +        and ocn !~/#/ +          p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) +        end +        toc={} +        if txt =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +          m=/#{$1}/ +          txt.gsub!(m,'') +          title=linkname +        else +          lnk_n_txt=%{  <a href="#{@md.fnl[:pre]}#{@@seg_url}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}##{ocn}"> +    #{linkname} +  </a>} +          txt_obj={:txt =>lnk_n_txt} +          format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) +          toc_mini=format_toc.mini_lev6 +        end +        toc_mini +      end +    end +  end +__END__ + diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 0bbac4fa..3e72f855 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -87,6 +87,7 @@ module SiSU_HTML_scroll          #if para =~/^#{Mx[:lv_o]}\d:endnotes#{Mx[:lv_c]}\s*Endnotes/          ##  para.gsub!(/Endnotes.+/,'')          #end +        para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/          if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/            para.gsub!(/(Document Information(?: \(metadata\))?)/,'\1<a name="docinfo"></a>')          end @@ -97,17 +98,21 @@ module SiSU_HTML_scroll          and (para =~/^#{Mx[:lv_o]}:metadata#{Mx[:lv_c]}/ or para =~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}\s*Document Information/)            @rcdc=true          end +        para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>')          if para !~/(^#{Rx[:meta]}|#{Mx[:br_endnotes]}|#{Mx[:br_eof]})/            unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/; para.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ')            end            if para =~/.+?#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -            paranum=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] -            @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) +            ocn=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] +            @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn)            end            @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_scroll            m=/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/            if para =~m -            format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch +            if @sto.format =~/i[1-9]|ordinary/ #watch +              txt_obj={:txt =>@sto.text} +              format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) +            end              case @sto.format              when /^1:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body1              when /^2:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body2 @@ -126,7 +131,7 @@ module SiSU_HTML_scroll              when /^(?:b|bold)$/;           para=@sto.scroll_lev_para_ocn.bold              when /^(?:verse|group|alt)$/;  para=@sto.scroll_lev_para_ocn.para              when /^code$/;                 para=@sto.scroll_lev_para_ocn.code -            when /null/ # see whether u can improve +            when /ordinary/ # see whether u can improve                if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/                  format_txt_obj.gsub_body                  para=@sto.scroll_lev_para_ocn.para @@ -138,30 +143,33 @@ module SiSU_HTML_scroll              end            elsif para =~/^#{Mx[:lv_o]}[1-9]:/ \            and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_c]}#@dp:#@dp#{Mx[:id_c]}$/ -            format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,para) +            txt_obj={:txt =>para} +            format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj)              para=format_txt_obj.bold_header            elsif para =~/Endnotes?/ \            and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -            format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="notes">Note</a>') +            txt_obj={:txt =>'<br /><a name="notes">Note</a>'} +            format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj)              para=format_txt_obj.bold_para            elsif para =~/Owner Details/ \            and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -            format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'<br /><a name="owner.details">Owner Details</a>') +            txt_obj={:txt =>'<br /><a name="owner.details">Owner Details</a>'} +            format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj)              @scr[:owner_details]=format_txt_obj.bold_para              para=''            elsif para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ #watch -            one,two=$1,$2 -            format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) +            cont=if $2.empty? +              $1 +            else "#{$1} #{$2}" #watch, check desired where $2 is other than space +            end +            txt_obj={:txt =>cont} +            format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)              para=format_seg.no_paranum            end            if para =~/<a name="n\d+">/ \            and para =~/^(?:\^~\d+\s|<!e[:_]\d+!>)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though              para=''            end -          if para =~/<:center>/ #rules changed now a <p class="center" problems may arise 2005w11 ! -            one,two=/(.*)<:center>(.*)/.match(para).captures -            format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) -          end            para.gsub!(/^#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/^<:\S?>/,'')            para.gsub!(/#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/<:\S?>/,' '); para.gsub!(/<!.+!>/,' ')            para.strip! @@ -174,7 +182,7 @@ module SiSU_HTML_scroll      end      def tails        scr_tail=[] -      format_head_scroll=SiSU_HTML_Format_type::Head_toc.new(@md) +      format_head_scroll=SiSU_HTML_Format::Head_toc.new(@md)        ads=SiSU_HTML_promo::Ad.new(@md)        scr_tail << format_head_scroll.scroll_tail << ads.div.close << ads.display << format_head_scroll.html_close        scr_tail diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index a15c302e..a280a8c8 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -62,14 +62,53 @@ module SiSU_HTML_seg    require "#{SiSU_lib}/shared_html"    require "#{SiSU_lib}/html"    require "#{SiSU_lib}/html_promo" +  class Seg_output +    def initialize(md,outputfile,seg,minitoc,type='') +      @md,@output_seg_file,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type +    end +    def output #CONSIDER +      if @seg[:title] =~/\S/ +        filename_seg=[] +        filename_seg << @seg[:title] << @seg[:tocband_banner] +        if @type =~/endnote/ +          @seg[:headers]=[] +          format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) +          @seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator) +          txt_obj={:txt =>'Endnotes',:ocn_display =>''} +          format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) +          @seg[:headers] << format_seg.title_header1 +          filename_seg << @seg[:header_endnotes] << @minitoc << @seg[:headers] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>' # << '</div>' +        elsif @type =~/idx/ +          @seg[:headers]=[] +          format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) +          @seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator) +          txt_obj={:txt =>'Index',:ocn_display =>''} +          format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) +          @seg[:headers] << format_seg.title_header1 +          filename_seg << @seg[:header_idx] << @minitoc << @seg[:headers] << %{\n<div class="content">\n} << @seg[:idx] << '</div>' # << '</div>' +        else +          filename_seg << @minitoc <<  @seg[:headers] << @seg[:main] << "\n</div>\n" +        end +        filename_seg << @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits] +        filename_seg.flatten!.compact! +        filename_seg.each do |para| +          unless para =~/\A\s*\Z/ +            para.strip! +            @output_seg_file << para +          end +        end +        @output_seg_file.close +      end +    end +  end    class Seg      @@seg,@@seg_subtoc,@@seg_endnotes,@@seg_ad={},{},{},{} -    @@seg_name,@@seg_name_html,@@seg_name_php=[],[],[] -    @@filename_seg=@@filename_segphp=@@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn='' +    @@seg_name,@@seg_name_html=[],[] +    @@seg_url=@@fn=@@to_lev4=@@get_hash_to=@@get_hash_fn=''      @@loop_count=@@seg_total=@@tracker=0      @@is4=@@is3=@@is2=@@is1=0      @@header1=@@header2=@@header3=@@header4=0 -    @@seg[:tocband],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(9){[]} +    @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headers],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(11){[]}      @@seg[:header_endnotes]=''      @@tablehead,@@number_of_cols=0,0      @@flag_alt=false @@ -85,6 +124,7 @@ module SiSU_HTML_seg      end      def songsheet        begin +        @minitoc=SiSU_HTML::Source::Toc.new(@data,@md).minitoc          data=get_subtoc_endnotes(@data)          data=articles(data)          Seg.new.cleanup # (((( added )))) @@ -102,6 +142,13 @@ module SiSU_HTML_seg        @h_sfx='.php' if @md.file_type =~/php/        @h_sfx=@md.sfx if @md.file_type =~/html/        @h_sfx='.html' if @md.file_type =~/html/ #used in creating file, not to be omitted. +      idx_html=nil +      if @md.book_index +        my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns) +        idx_html=SiSU_Particulars::Combined_singleton.instance.get_html_idx(@md.opt).html_idx +        idx_html.each {|x| @@seg[:idx] << x } +        @@seg[:header_idx]='' +      end        data.each do |para|          if para =~/^#{Mx[:lv_o]}4:/            @@seg_name << para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/,1] @@ -140,7 +187,9 @@ module SiSU_HTML_seg            end          end          if @@is4 == 1 \ -        or para =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ +        or para =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ \ +        or para =~/^#{Mx[:mk_o]}4:metadata#{Mx[:mk_c]}/ +          m=para[/^#{Mx[:lv_o]}4:(metadata)#{Mx[:lv_c]}/]; @@get_hash_fn=$1 if m            if newfile == 1 \            or para =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/              newfile=0 @@ -150,20 +199,24 @@ module SiSU_HTML_seg                  mkdir_p(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!!                  Seg.new('',@md).tail                  segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" -                @@filename_seg=File.new(segfilename,'w') if @@seg_name_html[tracking-1] -                unless (@@seg_name_html[tracking-1] =~/endnotes/) -                  Seg.new.output -                else Seg.new.output('endnotes') +                @output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] +                if @@seg_name_html[tracking-1] !~/endnotes|idx/ +                  Seg_output.new(@md,@output_seg_file,@@seg,@minitoc).output +                elsif @@seg_name_html[tracking-1] =~/endnotes/ +                  Seg_output.new(@md,@output_seg_file,@@seg,@minitoc,'endnotes').output +                elsif @@seg_name_html[tracking-1] =~/idx/ +                  Seg_output.new(@md,@output_seg_file,@@seg,@minitoc,'idx').output +                else p 'check'                  end                  Seg.new.reinitialise                  header_art(para)                  head(para)                  if @@seg_name_html[tracking] =~/metadata/ # this is for metadata                    segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}" -                  @@filename_seg=File.new(segfilename,'w') -                  Seg.new.reinitialise +                  @output_seg_file=File.new(segfilename,'w') +                  Seg.new.reinitialise #BUG with items following endnote, and occurring before metadata, this becomes a bug ... work area for book index, FIX                    flagend="x" -                  @@filename_seg.close                                         #%(((( EOF )))) --> +                  @output_seg_file.close                                         #%(((( EOF )))) -->                  end                end                if  tracking == 0 @@ -192,9 +245,10 @@ module SiSU_HTML_seg            end          end        end +      data      end      def header_art(para) -      format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) +      format_head_seg=SiSU_HTML_Format::Head_seg.new(@md)        if para =~/^#{Mx[:lv_o]}[1-6]:/ #2004w27/5          if @@tracker < @@seg_total-1; @@seg[:dot_nav]=format_head_seg.dot_control_pre_next          else                          @@seg[:dot_nav]=format_head_seg.dot_control_pre @@ -205,7 +259,7 @@ module SiSU_HTML_seg      end      def head(para)        clean=/<!.*?!>|#{Mx[:gr_o]}:.*?#{Mx[:gr_c]}|<:.*?>|#{Mx[:id_o]}~\d+;(?:[ohum]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -      format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) +      format_head_seg=SiSU_HTML_Format::Head_seg.new(@md)        if @@tracker < @@seg_total-1          if @@tracker == 0; @@segtocband=format_head_seg.toc_next2 #if format_head_seg.toc_next2          else               @@segtocband=format_head_seg.toc_pre_next2 #if format_head_seg.toc_pre_next2 @@ -215,44 +269,53 @@ module SiSU_HTML_seg        @p_num ||= ''        if @@is1 == 1          @dc_creator=%{<b>#{@md.dc_creator}</b>\n} if @md.dc_creator.to_s =~/\S/ -        @@seg[:tocband] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) -        @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format_type::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug +        @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav]) +        conditional_div_close=if @@get_hash_fn =~/metadata/ #watch +          '</div>' +        else '' +        end +        @@seg[:tocband_bannerless] << conditional_div_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) +        @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug          @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') -        paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 +        ocn=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1          else ''          end -        @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) -        format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,@@header1,@p_num.ocn_display) +        @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) +        txt_obj={:txt =>@@header1,:ocn_display =>@p_num.ocn_display} +        format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)          @@seg[:headers] << format_seg.title_header1.gsub(clean,'')          @@header1.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'')        end        if @@is2 == 1          header2=@@header2 -        paranum=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 +        ocn=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1          else ''          end -        @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) -        format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,header2,@p_num.ocn_display) +        @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) +        txt_obj={:txt =>header2,:ocn_display =>@p_num.ocn_display} +        format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)          @@seg[:headers] << format_seg.title_header2.gsub(clean,'')          @@header2.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'')        end        if @@is3 == 1          header3=@@header3 -        paranum=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 +        ocn=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1          else ''          end -        @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) -        format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,header3,@p_num.ocn_display) +        @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) +        txt_obj={:txt =>header3,:ocn_display =>@p_num.ocn_display} +        format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)          @@seg[:headers] << format_seg.title_header3.gsub(clean,'')          @@header3.gsub!(/ <a name="-[\d*+]+" href="#_[\d*+]+"> <sup>[\d*+]+<\/sup> <\/a>/,'')        end        if @@is4 == 1          header4=@@header4 -        paranum=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 +        ocn=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1          else ''          end -        @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) -        format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,header4,@p_num.ocn_display) +        @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) +        txt_obj={:txt =>header4,:ocn_display =>@p_num.ocn_display} +        format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)          @@seg[:headers] << format_seg.title_header4.gsub(clean,'')        end        @@seg[:header_endnotes]=format_head_seg.title_endnote(@md.title,@md.subtitle,@dc_creator,@@seg[:dot_nav]) @@ -260,12 +323,13 @@ module SiSU_HTML_seg      end      def markup(para)        @debug=[] -      format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) +      para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'') +      format_head_seg=SiSU_HTML_Format::Head_seg.new(@md)        if para !~/^#{Rx[:meta]}/          m=para[/.+?#{Mx[:id_o]}~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]          if m -          paranum=m[1].to_s -          @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) +          ocn=m[1].to_s +          @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn)          end          if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/m \          or @@flag_alt==true @@ -288,14 +352,18 @@ module SiSU_HTML_seg          end          if para !~/^#{Mx[:lv_o]}[1-9]:|#{Rx[:meta]}/            if para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ -            one,two=$1,$2 -            format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) +            cont="#{$1} #{$2}" #check where $2 is other than space +            txt_obj={:txt =>cont} +            format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)              para=format_seg.no_paranum            end          end          if para[/#{Mx[:id_o]}~(\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp)#{Mx[:id_c]}$/]            @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_seg -          format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ #watch +          if @sto.format =~/i[1-9]|ordinary/ #watch +            txt_obj={:txt =>@sto.text} +            format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) +          end            para=case @sto.format # work area 2003w29 ||@|def lev_segname_para_ocn|            when /^4:/; @sto.seg_lev_para_ocn.header4 # work on see Split_text_object            when /^5:/; @sto.seg_lev_para_ocn.header5 @@ -312,7 +380,7 @@ module SiSU_HTML_seg              @sto.seg_lev_para_ocn.para            when /^code$/              @sto.seg_lev_para_ocn.code -          when /null/ +          when /ordinary/              if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \              and para !~/^#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/                format_txt_obj.gsub_body @@ -320,14 +388,16 @@ module SiSU_HTML_seg              elsif para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \              and para =~/^#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/                format_txt_obj.gsub_body -              @sto.seg_lev_para_ocn.table_end +              @sto.seg_lev_para_ocn.table_css_end              else para              end            else para            end          elsif para =~/#{Mx[:tc_p]}|#{Mx[:gr_o]}T[hZ]?/u +          @sto=nil            table=SiSU_HTML_shared::Table.new(para)            para=table.table +        else @sto=nil          end          if @md.flag_separate_endnotes            para.gsub!(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{@md.sfx}#_\\1">})       #endnote- twice #removed file type @@ -335,18 +405,19 @@ module SiSU_HTML_seg          if para !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/            if para[/(.*)#{Mx[:id_o]}~0;(?:u|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/] #% watch u & m?              one,two=$1,$2 -            format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) -#FIX --> not that undefined, rather is not needed, should not be visited, and remove -            #para=format_seg.seg_no_paranum                                   #% undefined +            txt_obj={:txt =>$1.strip,:trailing =>$2.strip} +            format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)            end            para.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'')                   #potentially dagerous - removes all paragraphs with <!e_!> #?? workpoint            if para =~/<a name="_\d+" href="#-\d+"> <sup>/                #endnote- note- -            format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,para) +            txt_obj={:txt =>para} +            format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)              para=format_seg.no_paranum            end          end -        if @sto.format=~/4:\S+/ +        if @sto and @sto.format=~/4:\S+/            para.gsub!(/^\s*4:\S+\s*|<:[-_\w\d]?(-.+?-)?>|4~!.+/m,'')              #sort seg headers +          @@seg[:main] <<  %{\n<div class="content">\n}            @@seg[:main] << para            @@seg[:main] << @@seg_subtoc[@@get_hash_fn]                       #% insertion of sub-toc          else @@ -356,37 +427,22 @@ module SiSU_HTML_seg        end      end      def tail -      format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md) -      if @md.flag_auto_endnotes -        @@seg[:tail] << format_head_seg.endnote_mark -        @@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| +      format_head_seg=SiSU_HTML_Format::Head_seg.new(@md) +      if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn] +        @@seg[:tail] <<  %{\n<div class="content">\n<div class="endnote">\n} +        if @@seg_endnotes[@@get_hash_fn].flatten.length > 0 +          @@seg[:tail] << format_head_seg.endnote_mark +          @@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| +        end +        @@seg[:tail] << '</div>' +        @@seg[:tail] << '</div>' #this div closes div class content        end -      @@seg[:tail] << '<table summary="whitespace"><tr><td> </td></tr></table>' +      #@@seg[:tail] << '</div><table summary="whitespace"><tr><td> </td></tr></table>'        ads=SiSU_HTML_promo::Ad.new(@md)        @@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close      end -    def output(type='') -      if @@seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or... -        filename_seg=[] -        filename_seg << @@seg[:title] << @@seg[:tocband] -        if type !~/endnote/ -          filename_seg << @@seg[:headers] << @@seg[:main] -        else -          filename_seg << @@seg[:header_endnotes] << @@seg[:endnote_all] -        end -        filename_seg << @@seg[:tail] << @@seg[:tocband] << @@seg[:credits] -        filename_seg.flatten!.compact! -        filename_seg.each do |para| -          unless para =~/\A\s*\Z/ -            para.strip! -            @@filename_seg << para -          end -        end -        @@filename_seg.close -      end -    end      def reinitialise -      @@seg[:title],@@seg[:dot_nav],@@seg[:tocband],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(7){[]} +      @@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]}        @@segtocband=nil      end      def cleanup @@ -407,11 +463,9 @@ module SiSU_HTML_seg              @@seg_endnotes_array=[] if para=~/^#{Mx[:lv_o]}4:/              @@fns_previous=@md.fns if para=~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}/            end -          if para =~/^#{Mx[:lv_o]}4:/                                              #% EXTRACTION OF SUB-TOCs +          if para =~/^#{Mx[:lv_o]}4:/                                              #%  EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs              @@seg_subtoc[@@fn]=@@seg_subtoc_array              @@seg_subtoc_array=[] -          end -          if para =~/^#{Mx[:lv_o]}4:/                                              #% SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs              if para !~/^#{Mx[:lv_o]}4:metadata#{Mx[:lv_c]}/                m=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?#{Mx[:id_o]}~(\d+);(?:[oh]|4:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]              end @@ -429,12 +483,12 @@ module SiSU_HTML_seg            para.gsub!(/ <\/a>/,' ')            case para # series changed 2002w42            when /^#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #remove [u]? req by pg texts, revist -            one,two=$1,$2 -            format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) +            txt_obj={:txt =>$1.strip,:ocn =>$2} +            format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)              para=format_seg.subtoc_lev5            when /^#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -            one,two=$1,$2 -            format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) +            txt_obj={:txt =>$1.strip,:ocn =>$2} +            format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)              para=format_seg.subtoc_lev6            end            @@seg_subtoc_array << para @@ -459,19 +513,22 @@ module SiSU_HTML_seg                e_n=note_match_seg[/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,1]                try=e_n.split(/<br \/>/)                try.each do |e| -                format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,e) +                txt_obj={:txt =>e} +                format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)                  note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ -                  format_seg.endnote_body_seg_tail_indent -                else format_seg.endnote_body_seg_tail +                  format_seg.endnote_body_indent +                else format_seg.endnote_body                  end                  @@seg_endnotes_array << note_match                end                try.join('<br \/>')                #% creation of separate end segment/page of all endnotes referenced back to reference segment                m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(#-[\d*+]+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi -              one=note_match_seg[m,1] #note~ [a name] -              two=note_match_seg[m,2] #note- -              format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) +              endnote_part_a=note_match_seg[m,1] +              endnote_part_b=note_match_seg[m,2] +              txt_obj={:endnote_part_a =>endnote_part_a,:endnote_part_b =>endnote_part_b} + +              format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)                note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408                @@seg[:endnote_all] << note_match_all_seg              end diff --git a/lib/sisu/v0/html_table.rb b/lib/sisu/v0/html_table.rb index 1aed4f5d..24721835 100644 --- a/lib/sisu/v0/html_table.rb +++ b/lib/sisu/v0/html_table.rb @@ -67,17 +67,18 @@ module SiSU_HTML_table        @one,@parablock,@vz=one,one,SiSU_Env::Get_init.instance.skin      end      def table_head(inf) -      %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center"> -  <tr> -    <td valign="top" align="justify"> -      <p class="norm" id="o#{inf}"><a name="#{inf}"></a></p> -    </td> -    <td> +      %{ +<div class="substance"> +<label class="ocn">#{inf}</label> +<p class="norm" id="o#{inf}"><a name="#{inf}"></a>  <table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}      end      def table_end(tablefoot='') -      %{</table>#{@vz.margin_num}#{@vz.margin_num} #{@vz.table_close} -#{tablefoot}} +      %{</p> +#{tablefoot} +</div> +<div class="substance"> +}      end      def table_row(inf,h=false)        bold=if h; '<b>' @@ -109,7 +110,7 @@ module SiSU_HTML_table          tablefoot=[]          @@tablefoot.each {|x| tablefoot << ''}          @@tablefoot=[] -        if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock=table_end +        if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock="</p>\n</div>" #table_end          end        end        if @@tablehead == 1 diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 11976af9..99f2d7f4 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -236,7 +236,6 @@ module SiSU_Tune          para.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;')          para.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')          para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') -        para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>') # else clean ''          para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>')          para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>')          para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') @@ -246,6 +245,7 @@ module SiSU_Tune          para.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>')          para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>')          para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>') +        para.gsub!(/#{Mx[:nbsp]}/,' ')          para.gsub!(/<(p|br)>/,'<\1 />')          para=SiSU_Tune::Clean_html.new(para).clean          @tuned_file << para @@ -254,10 +254,10 @@ module SiSU_Tune      def urls(data)        @words=[]        data.each do |word| -        @words << if word=~/\{(.+?)\}((?:https?|file|ftp)\S+|image)/ -          if word =~/\{.+?\}(?:(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)[;.,]?(?:\s|$)/ -            m,u,d=/\{(.+?)\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)([;.,]?(?:\s|$))/.match(word).captures -          else m,u=/\{(.+?)\}((?:https?|file|ftp)\S+|image)/.match(word).captures +        @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ +          if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)[;.,]?(?:\s|$)/ +            m,u,d=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)([;.,]?(?:\s|$))/.match(word).captures +          else m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/.match(word).captures              d=''            end            case m @@ -276,13 +276,13 @@ module SiSU_Tune                %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}}              else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}}              end -            word.gsub!(/\{.+?\}((?:https?|file|ftp)\S+|image)/,ins) +            word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/,ins)            else              link=m[/(.+)/m]              png=m.scan(/\S+/)[0].strip              link=link.strip              ins=%{<a href="#{u}">#{link}</a>#{d}} -            word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) +            word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp)\S+/,ins)            end            word          else word @@ -313,8 +313,8 @@ module SiSU_Tune              para.gsub!(/<:image\s+(\S+)\s+>/,                %{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">})            end -          if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ -            @word_mode=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u) +          if para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ +            @word_mode=para.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u)              words=urls(@word_mode)              para.gsub!(/.+/m,words)            end @@ -336,7 +336,7 @@ module SiSU_Tune                para.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<<a href="mailto:\1">\1</a>>')              end              para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration -            para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url +            para.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url              para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration              if para =~/..\/\S+/ \              and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ diff --git a/lib/sisu/v0/hub.rb b/lib/sisu/v0/hub.rb index b3815828..58ea4c4f 100644 --- a/lib/sisu/v0/hub.rb +++ b/lib/sisu/v0/hub.rb @@ -134,6 +134,7 @@ module SiSU                    #when /^air$/;             SiSU_Air::Source.new(@opt).read             # -A                    when /^plaintext$/;       SiSU_Plaintext::Source.new(@opt).read       # -a                    when /^wikispeak$/;       SiSU_Wikispeak::Source.new(@opt).read       # -g +                  #when /^wikispeak$/;       SiSU_Wikispeak::Source.new(@opt).read       # -g                    when /^odf$/;             SiSU_ODF::Source.new(@opt).read             # -o                    when /^xml_md_oai_pmh_dc$/; SiSU_XML_metadata::OAI_PMH.new(@opt).read # -O                    when /^texpdf$/;          SiSU_TeX::Source.new(@opt).read             # -p @@ -278,7 +279,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/        if @opt.mod.inspect =~/--convert|--to|--from/          require "#{SiSU_lib}/sst_convert_markup"        end -      if @opt.cmd =~/([AabCcDdFfgGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ \ +      if @opt.cmd =~/([AabCcDdFfGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ \        and @opt.cmd =~/^-/ \        and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \        or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ #and @@ -425,6 +426,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/          end          if @opt.cmd =~/g/; op('wikispeak','wikispeak')         #% -g wiki          end +        #if @opt.cmd =~/g/; op('wikispeak','wikispeak')         #% -g wiki +        #end          if @opt.cmd =~/o/; op('odf','OpenDocument')            #% -o opendocument          end          if @opt.cmd =~/x/; op('xml','xml sax')                 #% -x xml sax type diff --git a/lib/sisu/v0/i18n.rb b/lib/sisu/v0/i18n.rb index 8ac3ffc8..286ba65d 100644 --- a/lib/sisu/v0/i18n.rb +++ b/lib/sisu/v0/i18n.rb @@ -105,6 +105,9 @@ module SiSU_Translate      def metadata        @lang_class.metadata      end +    def filetype_description +      @lang_class.filetype_description +    end      def file_size        @lang_class.file_size      end @@ -258,6 +261,9 @@ module SiSU_Translate      def language        @lang_class.language      end +    def manifest_description +      @lang_class.manifest_description +    end      def manifest_description_output        @lang_class.manifest_description_output      end @@ -314,6 +320,9 @@ module SiSU_Translate      def description        'description'      end +    def filetype_description +      'filetype description' +    end      def metadata        'metadata'      end @@ -464,11 +473,14 @@ module SiSU_Translate      def language_version_list        'Document Language Versions, manifests'      end +    def manifest_description +      'SiSU manifest of document filetypes and metadata' +    end      def manifest_description_output -      'SiSU manifest' +      'Available document filetypes'      end      def manifest_description_metadata -      'SiSU manifest of document metadata' +      'Document Metadata'      end      def language_list_translated        lang=case @trans_str @@ -513,6 +525,9 @@ module SiSU_Translate      def description        'description'      end +    def filetype_description +      description +    end      def metadata        'metadonnées'      end @@ -663,6 +678,9 @@ module SiSU_Translate      def language_version_list        'Versions des langues du document, manifestes'      end +    def manifest_description +      'SiSU manifest of document filetypes and metadata' +    end      def manifest_description_output        'Manifeste SiSU du document généré'      end @@ -712,6 +730,9 @@ module SiSU_Translate      def description        'Beschreibung'      end +    def filetype_description +      description +    end      def metadata        'Metadata'      end @@ -862,6 +883,9 @@ module SiSU_Translate      def language_version_list        'verfügbare Sprachen'      end +    def manifest_description +      'SiSU manifest of document filetypes and metadata' +    end      def manifest_description_output        'SiSU Zusammenfassung des Dokumentes'      end @@ -907,10 +931,13 @@ module SiSU_Translate      end      def filename       'nombre del fichero' -   end -   def description -     'descripción' -   end +    end +    def description +      'descripción' +    end +    def filetype_description +      description +    end     def metadata       'metadatos'     end @@ -1061,6 +1088,9 @@ module SiSU_Translate     def language_version_list       'Document Language Versions, manifests'     end +    def manifest_description +      'SiSU manifest of document filetypes and metadata' +    end     def manifest_description_output       'Manifiesto SiSU de salida generada'     end @@ -1110,6 +1140,9 @@ module SiSU_Translate      def description        'descrizione'      end +    def filetype_description +      description +    end      def metadata        'metadati'      end @@ -1260,6 +1293,9 @@ module SiSU_Translate      def language_version_list        'Traduzioni disponibili'      end +    def manifest_description +      'SiSU manifest of document filetypes and metadata' +    end      def manifest_description_output        'Inventario SiSU dell\'output generato'      end @@ -1309,6 +1345,9 @@ module SiSU_Translate      def description        'kuvaus'      end +    def filetype_description +      description +    end      def metadata        'metadata'      end @@ -1459,6 +1498,9 @@ module SiSU_Translate      def language_version_list        'Dokumentin kieliversiot, manifestit'      end +    def manifest_description +      'SiSU manifest of document filetypes and metadata' +    end      def manifest_description_output        'Tuotetun tuloksen SISU-manifesti'      end diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index 6bdfdae4..78045e80 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -60,13 +60,22 @@  =end  module SiSU_Manifest    require "#{SiSU_lib}/sysenv" -  require "#{SiSU_lib}/i18n"    include SiSU_Env +  require "#{SiSU_lib}/i18n" +  require "#{SiSU_lib}/particulars" +  include SiSU_Particulars +  require "#{SiSU_lib}/html_minitoc" +  #require "#{SiSU_lib}/html_format" +  require "#{SiSU_lib}/html" +  include SiSU_HTML_Format +  require "#{SiSU_lib}/param"    include SiSU_Param    include SiSU_Viz    class Source      def initialize(opt)        @opt=opt +      @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) +      @data=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions        l=SiSU_Env::Standardise_language.new.file_to_language(@opt.fns)        @doc_language=l[:l]      end @@ -83,16 +92,16 @@ module SiSU_Manifest          tell.green_hi_blue unless @opt.cmd =~/q/          tell=SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}")          tell.grey_tab if @opt.cmd =~/v/i -        Output_Info.new(@md).check_output +        Output_Info.new(@md,@data).check_output        rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error        ensure        end      end      private      class Output_Info <Source -      def initialize(md) +      def initialize(md,data)          @manifest={ :txt=>[],:html=>[] } -        @md,@fns=md +        @md,@fns,@data=md,md.fns,data          @env=SiSU_Env::Info_env.new(@md.fns)          @fnb=@md.fnb          @base_url,@base_url_src,@base_url_pod="#{@env.url.root}/#@fnb","#{@env.url.src_txt}","#{@env.url.src_pod}" @@ -111,7 +120,7 @@ module SiSU_Manifest            manifest << x          end        end -      def summarize(id,file,img='') +      def summarize(id,file,img='● ')          size=(File.size("#{@base_path}/#{file}")/1024.00).to_s          kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]          @manifest[:txt] << "#{file} #{id} #{kb}\n" @@ -169,7 +178,7 @@ module SiSU_Manifest          elsif url =~/^\.\.\//;   url.gsub(/^\.(\.)?/,@env.url.root)          else                     url          end -        @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{url}">#{lnk}</a></p><p class="tiny">  #{@url_brace.xml_open}<a href="#{static}">#{static}</a>#{@url_brace.xml_close}</p></th></tr>\n} +        @manifest[:html] << %{<tr><th class="right" width=5%><p class="norm">●</p></th><td class="left"><p class="norm"><a href="#{url}">#{lnk}</a></p><p class="tiny">  #{@url_brace.xml_open}<a href="#{static}">#{static}</a>#{@url_brace.xml_close}</p></td></tr>\n}        end        def output_tests          if FileTest.file?("#@base_path/#{@md.fn[:toc]}")==true @@ -523,6 +532,7 @@ module SiSU_Manifest        end        def check_output          begin +          minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,@data).songsheet            id,file='',''            vz=SiSU_Env::Get_init.instance.skin            banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \ @@ -555,16 +565,30 @@ SiSU manifest: #{@md.title}  </head>  <body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en">  #{banner_table} -<h1 class="small">#{@md.dc_title}</h1> +<div class="toc"> +#{minitoc.to_s} +</div> +<div class="content"> +<h1 class="small">#{@translate.manifest_description}</h1> +<h2 class="small">#{@md.dc_title}</h2>  <p class="bold">#{@md.dc_creator}</p> +<p class="small"> +  <a href="#output">Document, Available Filetypes</a> +</p> +<p class="small"> +  <a href="#metadata">Document Metadata</a> +</p> +<p class="tiny"> +      <a href="#links">(metadata suggested links (if any)</a> +</p>  <table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">  WOK            published_versions            @manifest[:html] << '</table>'            @manifest[:html] <<<<WOK  <h2 class="small"><a name="output">#{@translate.manifest_description_output}</a></h2> -<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center"> -<tr> <th class="left"><p class="bold">#{@translate.description}</p></th><th class="left"><p class="bold">#{@translate.filename}</p></th><th class="right"><p class="right"><b>#{@translate.file_size}</b></p><p class="tiny_right">(kB)</p></th></tr> +<table summary="available output/filetypes" width="100%" border="0" bgcolor="white" cellpadding="2" align="center"> +<tr> <th class="left"><p class="bold">#{@translate.filetype_description}</p></th><th class="left"><p class="bold">#{@translate.filename}</p></th><th class="right"><p class="right"><b>#{@translate.file_size}</b></p><p class="tiny_right">(kB)</p></th></tr>  WOK            output_tests @@ -576,7 +600,7 @@ WOK            @manifest[:html] << '</table>'            @manifest[:html] <<<<WOK  <h2 class="small"><a name="metadata">#{@translate.manifest_description_metadata}</a></h2> -<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center"> +<table summary="document metadata" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">  <tr> <th class="left"><p class="bold">#{@translate.metadata}</p></th><th class="left"><p class="bold">#{@translate.description}</p></th></tr>  WOK            metadata_tests @@ -584,8 +608,8 @@ WOK  </table>  WOK            @manifest[:html] <<<<WOK -<table summary="normal text css" width="90%" border="0" bgcolor="white" cellpadding="2" align="center"> -<tr><th class="left"><p class="bold"><a name="links">#{@translate.suggested_links}:</a></p></th></tr> +<p class="bold"><a name="links">#{@translate.suggested_links}:</a></p> +<table summary="suggested links" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">  WOK            links_tests            @manifest[:html] <<<<WOK @@ -593,15 +617,17 @@ WOK  WOK            @manifest[:html] <<<<WOK  <h2 class="small"><a name="languages">#{@translate.language_version_list}</a></h2> -<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center"> +<table summary="language versions" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">  <tr> <th class="left"><p class="bold">#{@translate.filename}</p></th><th class="left"><p class="bold">#{@translate.description}</p></th><th class="right"><p class="right"> </p></th></tr>  WOK            language_versions            @manifest[:html] <<<<WOK  </table> -#{vz.credits_splash} +</div> +<div class="main_column">  #{vz.credits_sisu} +</div>  </body>  </html>  WOK diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index 06878094..ef9f6bab 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -66,7 +66,7 @@ module SiSU_manpage    include SiSU_Param    include SiSU_Viz    require "#{SiSU_lib}/manpage_format" -  include Format +  include SiSU_Manpage_format    require "#{SiSU_lib}/shared_txt"    require "#{SiSU_lib}/shared_structure"    pwd=Dir.pwd @@ -144,7 +144,7 @@ module SiSU_manpage            end            wrap=util.line_wrap            if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m -            wrap.gsub!(/(^| |\s|\*)\\\*/,'\1\\\\\*') #man page requires +            wrap.gsub!(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*') #man page requires              wrap.gsub!(/\s\.(\S+)/,' \\.\1')              wrap.gsub!(/(["''])/,"\\\\\\1")                                     # quotation marks need escape              wrap.gsub!(/^\s*([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB @@ -266,6 +266,7 @@ WOK          table_message='[table omitted, see other document formats]'          fix=[]          data.each do |para| +          para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove            para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}")            para.gsub!(/.+?<-#>/,'')                                           # remove dummy headings (used by html) #check            para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ')                                          # bullet markup, marked down @@ -277,7 +278,7 @@ WOK            para.gsub!(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,"#{Mx[:br_line]}.B \\1#{Mx[:br_line]}")            para.gsub!(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,"#{Mx[:br_line]}.I \\1#{Mx[:br_line]}")            unless para =~/#{Mx[:gr_o]}code#{Mx[:gr_c]}/ -            para.gsub!(/(?:^|\s)\{(.+?)\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1 #{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") +            para.gsub!(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1 #{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3")              para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1#{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3")              @manpage[:endnotes]=extract_endnotes(para)              para.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]') # endnote marker marked up @@ -295,7 +296,7 @@ WOK              para.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~')              para.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©')            end -          para.gsub!(/(^| |\s|\*)\\\*/,'\1\\\\\*') #man page requires +          para.gsub!(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*') #man page requires            para.gsub!(/\s\.(\S+)/,' \\.\1')            para.gsub!(/(\n\.)(\S\S\S+)/m,'\1\\.\2')            para.gsub!(/-/,'\-') #manpages use this @@ -330,10 +331,10 @@ WOK            para.gsub!(/(^|#{Mx[:gl_c]}|\s)[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3')            para.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1')            para.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'')                                     # remove name links -          para.gsub!(/ /,' ')                                          # decide on +          para.gsub!(/ |#{Mx[:nbsp]}/,' ')                                          # decide on            para.gsub!(/(["''])/,"\\\\\\1")                                   # quotation marks need escape -          para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") -          para.gsub!(/^(?:^|[^_\\])\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') +          para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") +          para.gsub!(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]')            wordlist=para.scan(/\S+/)            if para =~/^#{Rx[:meta]}\s*(.+?)\Z/m # for headers              d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta @@ -343,9 +344,9 @@ WOK            if para !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/              if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change                paranum=para[@regx,3] -              @p_num=Format::Paragraph_number.new(paranum) +              @p_num=SiSU_Manpage_format::Paragraph_number.new(paranum)              end -            @sto=SiSU_Structure::Split_text_object.new(@md,para).txt +            @sto=SiSU_Structure::Split_text_object.new(@md,para).manpage              ### problem in scroll, it appears tables are getting paragraph numbers              m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/              if para =~m \ @@ -369,25 +370,6 @@ WOK                when /^(6):(\S*)/                  manpage_structure(para,$1,@sto.ocn,$2)                  @sto.lev_para_ocn.heading_body6 -              #when /^(i1)$/ -              #  #formatMono.gsubBody -              #  #para=@sto[:lev_para_ocn].scrIndent1 -              #when /^(i2)$/ -              #  formatMono.gsubBody -              #  para=@sto[:lev_para_ocn].scrIndent2 -              #when /^(center)$/ -              #  para.gsub!(/(.+)/, -              #    %{<center>(\\1)</center>}) -              #  para=@sto[:lev_para_ocn].scrPara -              #when /^(b|bold)$/ -              #  para.gsub!(/(.+)/, -              #    %{<b>(\\1)</b>}) -              #  para=@sto[:lev_para_ocn].scrPara -              #when /null/ # see whether u can improve -              #    if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) -              #      #formatMono.gsubBody -              #      #para=@sto[:lev_para_ocn].scrPara -              #    end                else                  manpage_structure(para,nil,nil,nil) #watch may be problematic                  para @@ -406,10 +388,6 @@ WOK                #@@manpage[:owner_details]=formatMono.bold_para                #para=''              elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! -            elsif para =~/(.*)<!#!>(.*)/ -              one,two=$1,$2 -              format_text=Format_text_object.new(one,two) -              para=format_text.seg_no_paranum              end              if (para =~/<a name="n\d+">/ \              and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote @@ -418,18 +396,14 @@ WOK              case para              when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/                if para =~/.*<:#>.*$/m -                format_text=Format_text_object.new(para,'') +                txt_obj={:txt =>para} +                format_text=Format_text_object.new(txt_obj)                  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 -            if para =~/<:center>/ -              one,two=/(.*)<:center>(.*)/.match(para)[1,2] -              format_text=Format_text_object.new(one,two) -              para=format_text.center -            end              para.gsub!(/\s(\[)/m,' \ \1') if para #manpages use this              para.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})/,"\n\n") if para              para.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') if para #manpages use this diff --git a/lib/sisu/v0/manpage_format.rb b/lib/sisu/v0/manpage_format.rb index 02fbf216..28756455 100644 --- a/lib/sisu/v0/manpage_format.rb +++ b/lib/sisu/v0/manpage_format.rb @@ -58,7 +58,7 @@   ** Description: manpage formatting template  =end -module Format +module SiSU_Manpage_format    require "#{SiSU_lib}/param"    include SiSU_Param    include SiSU_Viz @@ -78,19 +78,28 @@ module Format    end    class Format_text_object      @@dp=nil -    def initialize(one,two,three) -      one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ -      @one,@two,@three=one,two,three +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if @t_o.class == Hash +        @txt =@t_o[:txt]            || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end +      #@txt.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/        rgx=/^#{Mx[:lv_o]}[1-6-]:/ -      @one.gsub!(rgx,'') if @one =~rgx +      @txt.gsub!(rgx,'') if @txt =~rgx        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ -      @one.gsub!(rgx,'\1') if @one =~rgx -      @link,@linkname=one,two +      @txt.gsub!(rgx,'\1') if @txt =~rgx        @vz=SiSU_Env::Get_init.instance.skin      end      def scr_endnote_body -      "<endnote>#@one</endnote> " +      "<endnote>#{@txt}</endnote> "      end      def heading_body1      end diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 09c67ff6..05a6272c 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -128,7 +128,7 @@ module SiSU_ODF        end        # Used for extraction of endnotes from paragraphs        def extract_endnotes(para='') -        notes=para.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)\s*#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/) +        notes=para.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)\s*#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/)[1]          @n=[]          notes.each do |n| #high cost to deal with <br> appropriately within odf, consider            n=n.dup.to_s @@ -222,13 +222,13 @@ module SiSU_ODF        end        def image(para)          para.gsub!(@serial,'') -        m=para.scan(/(\{\s*(.+?)\}((?:https?|file|ftp)\S+|image))/) +        m=para.scan(/(#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image))/)          if m; m.each do |i|              cont,url=i[1],i[2]              cont.gsub!(/([)(\]\[])/,"\\\\\\1")              cont.gsub!(/([+?])/,"\\\\\\1") # incorrect handling of +              url.gsub!(/([+?])/,"\\\\\\1") -            para.sub!(/\{\s*#{cont}\}#{url}/m,image_odf(i)) #watch +            para.sub!(/#{Mx[:lnk_o]}\s*#{cont}\s*#{Mx[:lnk_c]}#{url}/m,image_odf(i)) #watch              para.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix            end            m=nil @@ -242,14 +242,14 @@ module SiSU_ODF        end        def text_link(para)          para.gsub!(@serial,'') -        m=para.scan(/(\{([^}]+?)\}((?:https?|file|ftp)\S+?))([;.,]?(?=\s|$))/) #sort +        m=para.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+?))([;.,]?(?=\s|$))/) #sort          if m            m.each do |i|              txt,url,trail=i[1],i[2]              txt.gsub!(/([)(\]\[])/,"\\\\\\1") -            txt.gsub!(/([+?])/,"\\\\\\1") # problems with + +            txt.gsub!(/([+?*])/,"\\\\\\1") # problems with +              url.gsub!(/([+?])/,"\\\\\\1") # problems with + -            para.gsub!(/\{\s*#{txt}\}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url +            para.gsub!(/#{Mx[:lnk_o]}\s*#{txt}#{Mx[:lnk_c]}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url              para.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix            end            m=nil @@ -260,14 +260,14 @@ module SiSU_ODF          para.gsub!(@serial,'')          para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,            '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>\2') #http ftp matches escaped, no decoration -        para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, +        para.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,            '\1<text:a xlink:type="simple" xlink:href="\2">\2</text:a>\3') #special case \{ e.g. \}http://url          para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,            %{\\1#{@url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\2">\\2</text:a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration          #para.gsub!(/\b((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, also works            #%{#{@url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@url_brace.xml_close}\\2}) #http ftp matches with decoration          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}}) +          %{#{@url_brace.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@url_brace.xml_close}}) if para !~/http:\/\// # improve upon, document crash where url contains '@' symbol          para=case para          when /^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/m            m=$1 @@ -283,31 +283,31 @@ module SiSU_ODF        end        def footnote(para)          @astx||=10000 -        para.gsub!(/#{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_a_c]}|#{Mx[:en_a_c]})/,'\1') +        para.gsub!(/#{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1')          #para.gsub!(/<br \/><:i[1-9]>/,'<br />') -       if para =~/#{Mx[:en_a_o]}\d+\s+/ +        if para =~/#{Mx[:en_a_o]}\d+\s+/            para=para.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'<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 -        if para=~/#{Mx[:en_b_o]}[*+]\d+\s/ #editor notes, squre bracket series -          asterisk=para.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/) +        if para=~/#{Mx[:en_a_o]}[*+]+\s/ +          asterisk=para.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/)            asterisk.each do |x|              a=x[0].gsub(/([*+])/,"\\\\\\1") -            para=para.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\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>}) +            para=para.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\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>})              @astx+=1            end          end -        if para=~/#{Mx[:en_a_o]}[*+]+\s/ -          asterisk=para.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/) +        if para=~/#{Mx[:en_b_o]}[*+]\d+\s/ +          asterisk=para.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/)            asterisk.each do |x|              a=x[0].gsub(/([*+])/,"\\\\\\1") -            para=para.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\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>}) +            para=para.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\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>})              @astx+=1            end          end          para        end        def group_clean(para) -        para.gsub!(/&nbsp;| /,' ') +        para.gsub!(/&nbsp;| |#{Mx[:nbsp]}/,' ')          para.gsub!(/</,'<'); para.gsub!(/>/,'>')          para.gsub!(/<(text:span text:style-name="T[1-5]"|\/text:span)>/,'<\1>') #works, not ideal          para.gsub!(/#{Mx[:br_line]}/,'<br />') @@ -358,18 +358,36 @@ module SiSU_ODF        end        def table(para)                                                            #          if para =~/#{Mx[:gr_o]}Th?.+/ # tables come as single block -          table=SiSU_ODF_format::Table.new(@md,para) +          txt_obj={:table =>para} +          table=SiSU_ODF_format::Table.new(@md,txt_obj)            para=table.table_split          end        end -      def odf_structure(para='',lv='',ocn='',hname='') #% Used to extract the structure of a document +      def odf_structure(md,t_o) +        @md,@t_o=md,t_o +        @md,@t_o=md,t_o +        if t_o.class == Hash +          para =t_o[:txt]            || nil +          lv =t_o[:lv]               || nil +          ocn =t_o[:ocn]             || nil +          hname =t_o[:h_name]        || nil +          #@h_name =t_o[:h_name]      || nil +        #elsif t_o.class == Array +        #  @txt =txt[0] +        #elsif t_o.class == String +        #  @txt =txt +        else +          #@one,@two,@three=one,two,three +          p t_o.class +          p caller +        end          lv=lv.to_i          n=lv - 1          n3=lv + 2          lv=nil if lv == 0          para=unless para=~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/ -          para=if para =~/\{\s*\S+?\.(?:png|jpg|gif)\s.+?\}(?:(?:https?|file|ftp):\S+|image)/; image(para) -          elsif para =~/\{.+?\}(?:(?:https?|file|ftp):\S+|image)/; text_link(para) +          para=if para =~/#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/; image(para) +          elsif para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)/; text_link(para)            else para            end          else para @@ -421,15 +439,15 @@ module SiSU_ODF          bullet=image_src('bullet_09.png')          cp("#{bullet}/bullet_09.png","#{@env.path.odf}/Pictures/.") #if image_src('bullet_09.png')          data.each do |para| +          para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove            #p para if para =~safe_characters and @md.cmd =~/V/ #KEEP            #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') +          para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/            para_array=[] +          para.gsub!(/</,'<'); para.gsub!(/>/,'>')            word=para.scan(/\S+|\n/)            if word              word.each do |w| # _ - / # | : ! ^ ~ -              unless w =~/#{Mx[:id_o]}~\S+?;\S+?;\S+?#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|#{Mx[:gr_o]}.+?#{Mx[:gr_c]}|<[:!][^<>]+?>/ -                w.gsub!(/^<([^<>][^<>][^<>][^<>]+?)>$/,'<\1>') #refix -              end                unless para =~/^(?:#{Rx[:meta]}|%+ )/m                  w.gsub!(/&#(?:126|152);/,'~') #126 usual                  if w !~/&\S{1,7};/ \ @@ -468,10 +486,10 @@ module SiSU_ODF            para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<text:span text:style-name="T3">\1</text:span>')            para.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<text:span text:style-name="T4">\1</text:span>')            para.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<text:span text:style-name="T5">\1</text:span>') -          para.gsub!(/`/,"'")            para.gsub!(//u,'-') +          para.gsub!(/ /u, ' ')       # space identify +          para.gsub!(/ /u, ' ')       # space identify            para.gsub!(/·/u,'*') -          para.gsub!(/[“”]/u,'""')            para.gsub!(/[–—]/u,'-')   #— – chk            para.gsub!(/ < /i,'<')            para.gsub!(/\\copy(?:right)?\b/,'©') @@ -485,7 +503,7 @@ module SiSU_ODF            para.gsub!(/^\s*#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'') # remove empty lines            para.gsub!(/<a href=".+?">(.+?)<\/a>/,'\1')            para.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'')                                       # remove name links -#          para.gsub!(/<a href=".+?">(.+?)<\/a>/im,'\1') +          #para.gsub!(/<a href=".+?">(.+?)<\/a>/im,'\1')            #para.gsub!(/ /,' ')                                            # decide on            #para.gsub!(/\{(\S+?\.(?:png|jpg)) .+?\}(?:http:\/\/\S+|image)/,"    [ \\1 ]") #"[ #{@env.url.images_local}\/\\1 ]")            #para.gsub!(/<!TZ.+/,'') @@ -515,51 +533,35 @@ module SiSU_ODF                and para=~/\S+/                  para=case @sto.format                  when /^(1):(\S*)/ -                  odf_structure(para,$1,@sto.ocn,$2) +                  txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                  odf_structure(@md,txt_obj)                    para                  when /^(2):(\S*)/ -                  odf_structure(para,$1,@sto.ocn,$2) +                  txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                  odf_structure(@md,txt_obj)                    para                  when /^(3):(\S*)/ -                  odf_structure(para,$1,@sto.ocn,$2) +                  txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                  odf_structure(@md,txt_obj)                    para                  when /^(4):(\S+)/ # work on see Split_text_object -                  odf_structure(para,$1,@sto.ocn,$2) +                  txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                  odf_structure(@md,txt_obj)                    # work on see SiSU_text_parts::Split_text_object                    para                  when /^(5):(\S*)/ -                  odf_structure(para,$1,@sto.ocn,$2) +                  txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                  odf_structure(@md,txt_obj)                    para                  when /^(6):(\S*)/ -                  odf_structure(para,$1,@sto.ocn,$2) +                  txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                  odf_structure(@md,txt_obj)                    para -                  #@sto.lev_para_ocn.heading_body6 -                #when /^(i1)$/ -                #  #formatMono.gsubBody -                #  #para=@sto[:lev_para_ocn].scrIndent1 -                #when /^(i2)$/ -                #  formatMono.gsubBody -                #  para=@sto[:lev_para_ocn].scrIndent2 -                #when /^(center)$/ -                #  para.gsub!(/(.+)/, -                #    %{<center>(\\1)</center>}) -                #  para=@sto[:lev_para_ocn].scrPara -                #when /^(b|bold)$/ -                #  para.gsub!(/(.+)/, -                #    %{<b>(\\1)</b>}) -                #  para=@sto[:lev_para_ocn].scrPara -                #when /null/ # see whether u can improve -                #    if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) -                #      #formatMono.gsubBody -                #      #para=@sto[:lev_para_ocn].scrPara -                #    end -                else odf_structure(para,nil,nil,nil) #watch may be problematic +                else +                  txt_obj={:txt =>para} +                  odf_structure(@md,txt_obj) #watch may be problematic                    para                  end -              elsif para =~/(.*)<!#!>(.*)/ -                one,two=$1,$2 -                format_text=SiSU_ODF_format::Format_text_object.new(one,two) -                para=format_text.seg_no_paranum                end                if para =~/<a name="n\d+">/ \                and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote @@ -568,17 +570,14 @@ module SiSU_ODF                if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/)                  # i don't get the condition for no paranum                end -              if para =~/<:center>/ -                one,two=/(.*)<:center>(.*)/.match(para)[1,2] -                format_text=SiSU_ODF_format::Format_text_object.new(one,two) -                para=format_text.center -              end              else                if para =~ /^(4)~(\S+)/ -                odf_structure(para,$1,@sto.ocn,$2) +                txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} +                odf_structure(@md,txt_obj)                  para                elsif para =~/#{Mx[:id_o]}~(\d+);m\d+;[mdv]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -                odf_structure(para,nil,nil,nil) #watch may be problematic +                txt_obj={:txt =>para} +                odf_structure(@md,txt_obj) #watch may be problematic                  para                end              end diff --git a/lib/sisu/v0/odf_format.rb b/lib/sisu/v0/odf_format.rb index 05e4a918..fe94bf5b 100644 --- a/lib/sisu/v0/odf_format.rb +++ b/lib/sisu/v0/odf_format.rb @@ -78,19 +78,28 @@ module SiSU_ODF_format    end    class Format_text_object      @@dp=nil -    def initialize(one,two,three) -      one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ -      @one,@two,@three=one,two,three +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        #@one,@two,@three=one,two,three +        p t_o.class +        p caller +      end        rgx=/^#{Mx[:lv_o]}[1-6-]:/ -      @one.gsub!(rgx,'') if @one =~rgx +      @txt.gsub!(rgx,'') if @txt =~rgx        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ -      @one.gsub!(rgx,'\1') if @one =~rgx -      @link,@linkname=one,two +      @txt.gsub!(rgx,'\1') if @txt =~rgx        @vz=SiSU_Env::Get_init.instance.skin      end      def scr_endnote_body -      "<endnote>#@one</endnote> " +      "<endnote>#@txt</endnote> "      end      def heading_body1        #%{<text:h text:style-name="Heading_20_1" text:outline-level="1">#@two</text:h>} @@ -116,8 +125,21 @@ module SiSU_ODF_format      @@tablefoot=[] #watch      @@fns=''      @@dp=nil -    def initialize(md,one) -      @md,@one,@parablock,@vz=md,one,one,SiSU_Env::Get_init.instance.skin +    def initialize(md,t_o) +      @md,@t_o,@vz=md,t_o,SiSU_Env::Get_init.instance.skin +      if t_o.class == Hash +        @txt   =t_o[:txt]   || nil +        @table =t_o[:table] || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        if @md.cmd =~/M/ +          p t_o.class +          p caller +        end +      end        if @md.fns != @@fns          @@table_counter=0          @@fns=@md.fns @@ -177,58 +199,60 @@ module SiSU_ODF_format        %{</table:table-row>#@br}      end      def table -      @parablock='' if @parablock =~/^<!$/ -      @parablock.gsub!(/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'') -      m=@parablock[/<!f(.+?)!>/,1] +      @txt='' if @txt =~/^<!$/ +      @txt.gsub!(/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'') +      m=@txt[/<!f(.+?)!>/,1]        @@tablefoot << m if m -      @parablock.gsub!(/<!f.+?!>/,'') -      @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u -      @@table_counter+=1  if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u -      if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1,true) -      elsif @parablock =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1) +      @txt.gsub!(/<!f.+?!>/,'') +      @@tablehead=1 if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u +      @@table_counter+=1  if @txt =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u +      if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1,true) +      elsif @txt =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1)        end -      if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/          tablefoot=[]          @@tablefoot.each {|x| tablefoot << ''}          @@tablefoot=[] -        if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock=table_end +        if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @txt=table_end          end        end        if @@tablehead == 1 -        if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u -          if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u -            @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) +        if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u +          if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u +            @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true))            end -          if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u -            @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) +          if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u +            @txt.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true))            end -          if @parablock =~/#{Mx[:tc_c]}/ -            @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) +          if @txt =~/#{Mx[:tc_c]}/ +            @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close(true))            end            @@tablehead=0          end -        @parablock +        @txt        else -        if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u -          @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) +        if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u +          @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1))          end -        if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u -          @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) +        if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u +          @txt.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1))          end -        if @parablock =~/#{Mx[:tc_c]}/ -          @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close) +        if @txt =~/#{Mx[:tc_c]}/ +          @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close)          end -        @parablock +        @txt        end -      @parablock +      @txt      end      def table_split        @new_content=[] -      @one.split(/\s*#{Mx[:tc_o]}/).each do |parablock| +      @table.split(/\s*#{Mx[:tc_o]}/).each do |parablock|          table=if parablock =~/#{Mx[:gr_o]}/ -          Table.new(@md,"#{parablock}") +          txt_obj={:txt =>parablock} +          Table.new(@md,txt_obj)          else -          Table.new(@md,"#{Mx[:tc_o]}#{parablock}") +          txt_obj={:txt =>"#{Mx[:tc_o]}#{parablock}"} +          Table.new(@md,txt_obj)          end          @new_content << table.table        end diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 43b2d862..7994487d 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -119,13 +119,13 @@ module SiSU_Param        @doc={ :lv=>[] }        @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','',''        @@publisher='SiSU scribe' -      attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec,:opt,:sem_tag +      attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec,:opt,:sem_tag,:book_index        def initialize(fns_array,opt)          @env=@fn=@fns=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@sfx=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@site_skin=@sisu=@sisu_version=@ruby_version=@title=@dc_title=@html_title=@subtitle=@subtitle_tex=@creator_home=@dc_creator=@translator=@illustrator=@prepared_by=@digitized_by=@dc_subject=@dc_description=@dc_publisher=@dc_contributor=@dc_date=@dc_date_created=@dc_date_issued=@dc_date_available=@dc_date_valid=@dc_date_modified=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@dc_type=@dc_format=@dc_identifier=@dc_source=@dc_language=@language_original=@dc_relation=@dc_coverage=@dc_rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@num_top=@toc_lev_limit=@flag_auto_heading_num=@make_bold=@make_italic=@flag_tables=@vocabulary=@doc_skin=@doc_css=@yaml=@lnk=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@file_size=@firstseg=@programs=@creator_copymark=@lang=@en=@dgst=@dgst_skin=@generated=@heading_seg_first=@base_program=@man_synopsis=nil          @man_section=1          @man_name='man page "name/whatis" information not provided, set in header @man: name=[whatis information]'          @data,@fns,@cmd,@mod,@opt=fns_array,opt.fns,opt.cmd,opt.mod,opt #@data used as data -        @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo=false,false,false,false,false,false +        @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_index=false,false,false,false,false,false,false          @seg_autoname_safe=true          @sem_tag=false          @markup_instruction,@markup_declared,@image='','','' #check which other values should be set to empty rather than nil @@ -195,7 +195,7 @@ module SiSU_Param          end          @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general          @sfx_src=@fns[m,2] -        @sfx=nil +        @sfx='.html' # #@sfx=nil watch          @flag_auto_heading_num=false          if @fns =~ /(?:-|ssm\.)?sst$/ #watch            @env_out_root=@env.path.output @@ -368,32 +368,32 @@ module SiSU_Param                  @dc_date_modified=date                  @date_modified_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/                end -            when /^(?:0~type|@type:)\s+(.+?)$/m;             @dc_type=$1                            #% metainfo DC -            when /^(?:0~format|@format:)\s+(.+?)$/m;         @dc_format=$1                          #% metainfo DC -            #when /^(?:0~identifier|@identifier:)\s+(.+?)$/m; @dc_identifier=$1                      #% metainfo DC -            when /^(?:0~source|@source:)\s+(.+?)$/m;         @dc_source=$1                          #% metainfo DC -            when /^(?:0~language(?:\.document)?|@language(?:\.document)?:)\s+(.+?)$/m               #% metainfo DC +            when /^(?:0~type|@type:)\s+(.+?)$/m;             @dc_type=$1                                                 #% metainfo DC +            when /^(?:0~format|@format:)\s+(.+?)$/m;         @dc_format=$1                                               #% metainfo DC +            #when /^(?:0~identifier|@identifier:)\s+(.+?)$/m; @dc_identifier=$1                                           #% metainfo DC +            when /^(?:0~source|@source:)\s+(.+?)$/m;         @dc_source=$1                                               #% metainfo DC +            when /^(?:0~language(?:\.document)?|@language(?:\.document)?:)\s+(.+?)$/m                                    #% metainfo DC                x=$1.strip                lang=SiSU_Env::Standardise_language.new(x.dup)                @dc_language[:code]=lang.code                @dc_language[:name]=lang.title -            when /^(?:0~language\.original|@language\.original:)\s+(.+?)$/m                         #% metainfo DC +            when /^(?:0~language\.original|@language\.original:)\s+(.+?)$/m                                              #% metainfo DC                x=$1.strip                lang=SiSU_Env::Standardise_language.new(x.dup)                @language_original[:name]=lang.title -            when /^(?:0~relation|@relation:)\s+(.+?)$/m;     @dc_relation=$1                        #% metainfo DC -            when /^(?:0~coverage|@coverage:)\s+(.+?)$/m;     @dc_coverage=$1                        #% metainfo DC -            when /^(?:0~rights|@rights:)\s+(.+?)$/m;         @dc_rights=$1                          #% metainfo DC copyright, public domain, copyleft, creative commons, etc. -            when /^(?:0~papersize|@papersize:)\s+(.+?)$/m                                           #% metainfo DC +            when /^(?:0~relation|@relation:)\s+(.+?)$/m;     @dc_relation=$1                                             #% metainfo DC +            when /^(?:0~coverage|@coverage:)\s+(.+?)$/m;     @dc_coverage=$1                                             #% metainfo DC +            when /^(?:0~rights|@rights:)\s+(.+?)$/m;         @dc_rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. +            when /^(?:0~papersize|@papersize:)\s+(.+?)$/m                                                                #% metainfo DC                l=$1                if @mod.inspect !~/--papersize[=-]\S+/                  l=determine_papersize(l.dup)                  @papersize=l                end -            when /^(?:0~keywords?|@keywords?:?)\s+(.+?)$/m;  @keywords=$1                           #% metainfo DC -            when /^(?:0~comments?|@comments?:?)\s+(.+?)$/m;  @comments=$1                           #% metainfo DC -            when /^(?:0~abstract|@abstract)\s+(.+?)$/m;      @abstract=$1                           #% metainfo DC -            when /^(?:0~tags?|@tags?:)\s+\S/m                                                       #% metainfo +            when /^(?:0~keywords?|@keywords?:?)\s+(.+?)$/m;  @keywords=$1                                                #% metainfo DC +            when /^(?:0~comments?|@comments?:?)\s+(.+?)$/m;  @comments=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line])  #% metainfo DC +            when /^(?:0~abstract|@abstract)\s+(.+?)$/m;      @abstract=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line])  #% metainfo DC +            when /^(?:0~tags?|@tags?:)\s+\S/m                                                                            #% metainfo                tags=para.match(/^(?:0~tags?|@tags?:)\s+(.+)\Z/m)[1]                tags.split(/,|$/).each do |tag|                  tag.strip! @@ -403,18 +403,18 @@ module SiSU_Param                  tag_a=tag_a.split(/:/).join('][')                  @tag_a << tag_a                end -            when /^(?:0~catalogue|@catalogue:)\s+(.+)?$/m                                           #% metainfo +            when /^(?:0~catalogue|@catalogue:)\s+(.+)?$/m                                                                #% metainfo                m=$1                @cls_pg=m.match(/pg=(\S+)/)[1] if m =~/pg=/                @cls_isbn=m.match(/isbn=(\S+)/)[1] if m =~/isbn=/                @cls_dewey=m.match(/dewey=(\S+)/)[1] if m =~/dewey=/                @cls_loc=m.match(/loc=(\S+)/)[1] if m =~/loc=/ -            when /^(?:0~class(?:ify)?_loc|@class(?:ify)?_loc:)\s+(.+?)$/m;             @cls_loc=$1  #% metainfo -            when /^(?:0~class(?:ify)?_dewey|@class(?:ify)?_dewey:)\s+(.+?)$/m;         @cls_dewey=$1 #% metainfo -            when /^(?:0~class(?:ify)?_pg|@class(?:ify)?_pg)\s+(.+?)$/m;                @cls_pg=$1   #% metainfo -            when /^(?:0~(?:class(?:ify)?_)?isbn|@(?:class(?:ify)?_)?isbn)\s+(\S+?)$/m; @cls_isbn=$1 #% metainfo -            when /^(?:0~images?|@images?:)\s+(.+?)$/m;                                 @image=$1    #% processing -            when /^(?:0~(?:toc|structure)|@(?:toc|structure):)\s+(.+?)\Z/m                           #% processing +            when /^(?:0~class(?:ify)?_loc|@class(?:ify)?_loc:)\s+(.+?)$/m;             @cls_loc=$1                       #% metainfo +            when /^(?:0~class(?:ify)?_dewey|@class(?:ify)?_dewey:)\s+(.+?)$/m;         @cls_dewey=$1                      #% metainfo +            when /^(?:0~class(?:ify)?_pg|@class(?:ify)?_pg)\s+(.+?)$/m;                @cls_pg=$1                        #% metainfo +            when /^(?:0~(?:class(?:ify)?_)?isbn|@(?:class(?:ify)?_)?isbn)\s+(\S+?)$/m; @cls_isbn=$1                      #% metainfo +            when /^(?:0~images?|@images?:)\s+(.+?)$/m;                                 @image=$1                         #% processing +            when /^(?:0~(?:toc|structure)|@(?:toc|structure):)\s+(.+?)\Z/m                                                 #% processing                doc_toc_str=$1                @toc=doc_toc_str.split(/;\s*/)                @toc=[ @toc ] if @toc == String @@ -576,6 +576,9 @@ module SiSU_Param                  end                end              end +            if not @book_index and para =~/^=\{(.+?)\}\s*$/  +              @book_index=true +            end              unless @code_flag                case para                when /~\{\s+.+?\}~/m                                                                    #% processing diff --git a/lib/sisu/v0/particulars.rb b/lib/sisu/v0/particulars.rb index 8ae4f66e..59b8956b 100644 --- a/lib/sisu/v0/particulars.rb +++ b/lib/sisu/v0/particulars.rb @@ -92,7 +92,11 @@ module SiSU_Particulars        set_env        set_md      end -    attr_accessor :opt,:md +    def get_html_idx(opt) +      @opt=opt +      set_html_idx +    end +    attr_accessor :opt,:md,:html_idx      def set_md        begin          @md=SiSU_Param::Parameters.new(@opt).get @@ -116,6 +120,13 @@ module SiSU_Particulars        rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error        end      end +    def set_html_idx +      begin +        @html_idx=SiSU_DAL::Source.new(@md).get_idx_html +        self +      rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error +      end +    end    end  end  __END__ diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index b89a6252..754e366d 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -66,7 +66,7 @@ module SiSU_Plaintext    include SiSU_Param    include SiSU_Viz    require "#{SiSU_lib}/plaintext_format" -  include Format +  include SiSU_Plaintext_format    require "#{SiSU_lib}/shared_txt"    require "#{SiSU_lib}/shared_structure"    pwd=Dir.pwd @@ -275,6 +275,7 @@ WOK          table_message='[table omitted, see other document formats]'          fix=[]          data.each do |para| +          para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove            para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}")            para.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'')                                           # remove dummy headings (used by html) #check            para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ')                                          # bullet markup, marked down @@ -287,7 +288,7 @@ WOK            para.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"')            para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-\1-')            unless para =~/#{Mx[:gr_o]}code#{Mx[:gr_c]}/ -            para.gsub!(/\{(.+?)\}((?:https?|file|ftp):\/\/\S+|image)/,'\1 [link:] \2') +            para.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+|image)/,'\1 [link:] \2')              para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1#{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3")              para.gsub!(/_((?:https?|file|ftp):\/\/\S+)/,'\1')              extract_endnotes(para) @@ -321,8 +322,8 @@ WOK            para.gsub!(/(^|#{Mx[:gl_c]}|\s)[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3')            para.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1')            para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'')                                       # remove name links -          para.gsub!(/ /,' ')                                            # decide on -          para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") +          para.gsub!(/ |#{Mx[:nbsp]}/,' ')                                            # decide on +          para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]")            para.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')            #para.gsub!(/^\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')            wordlist=para.scan(/\S+/) @@ -334,7 +335,7 @@ WOK            if para !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/              if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change                paranum=para[@regx,3] -              @p_num=Format::Paragraph_number.new(paranum) +              @p_num=SiSU_Plaintext_format::Paragraph_number.new(paranum)              end              @sto=SiSU_Structure::Split_text_object.new(@md,para).txt              ### problem in scroll, it appears tables are getting paragraph numbers @@ -360,25 +361,6 @@ WOK                when /^(6):(\S*?)/                  plaintext_structure(para,$1,@sto.ocn,$2)                  @sto.lev_para_ocn.heading_body6 -              #when /^(i1)$/ -              #  #formatMono.gsubBody -              #  #para=@sto[:lev_para_ocn].scrIndent1 -              #when /^(i2)$/ -              #  formatMono.gsubBody -              #  para=@sto[:lev_para_ocn].scrIndent2 -              #when /^(center)$/ -              #  para.gsub!(/(.+)/, -              #    %{<center>(\\1)</center>}) -              #  para=@sto[:lev_para_ocn].scrPara -              #when /^(b|bold)$/ -              #  para.gsub!(/(.+)/, -              #    %{<b>(\\1)</b>}) -              #  para=@sto[:lev_para_ocn].scrPara -              #when /null/ # see whether u can improve -              #    if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) -              #      #formatMono.gsubBody -              #      #para=@sto[:lev_para_ocn].scrPara -              #    end                else                  plaintext_structure(para,nil,nil,nil) #watch may be problematic                  para @@ -397,28 +379,25 @@ WOK                #@plaintext[:owner_details]=formatMono.bold_para                #para=''              elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! check -            elsif para =~/(.*)<!#!>(.*)/ -              one,two=$1,$2 -              format_text=Format_text_object.new(one,two) -              para=format_text.seg_no_paranum              end              para='' if (para =~/<a name="n\d+">/ \              and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote              case para              when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/                if para =~/.*<:#>.*$/m -                format_text=Format_text_object.new(para,'') +                txt_obj={:txt =>para} +                format_text=Format_text_object.new(@md,txt_obj)                  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 -            if para =~/<:center>/ -              one,two=/(.*)<:center>(.*)/.match(para)[1,2] -              format_text=Format_text_object.new(one,two) -              para=format_text.center -            end +            #if para =~/<:center>/ +            #  one,two=/(.*)<:center>(.*)/.match(para)[1,2] +            #  format_text=Format_text_object.new(one,two) +            #  para=format_text.center +            #end              para.gsub!(/#{Mx[:id_o]}.+?#{Mx[:id_c]}/,' ') if para ## Clean Prepared Text              para.gsub!(/<!.+!>/,' ') if para ## Clean Prepared Text              para.gsub!(/<:\S+>/,' ') if para ## Clean Prepared Text diff --git a/lib/sisu/v0/plaintext_format.rb b/lib/sisu/v0/plaintext_format.rb index e957d3a3..cada3425 100644 --- a/lib/sisu/v0/plaintext_format.rb +++ b/lib/sisu/v0/plaintext_format.rb @@ -58,7 +58,7 @@   ** Description: plaintext formatting template  =end -module Format +module SiSU_Plaintext_format    require "#{SiSU_lib}/param"    include SiSU_Param    include SiSU_Viz @@ -78,19 +78,30 @@ module Format    end    class Format_text_object      @@dp=nil -    def initialize(one,two,three) -      one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ -      @one,@two,@three=one,two,three +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        @lnk_url =t_o[:lnk_url]    || nil +        @lnk_txt =t_o[:lnk_txt]    || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        #@one,@two,@three=one,two,three +        p t_o.class +        p caller +      end        rgx=/^#{Rx[:lv]}/ -      @one.gsub!(rgx,'') if @one =~rgx +      @txt.gsub!(rgx,'') if @txt =~rgx        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ -      @one.gsub!(rgx,'\1') if @one =~rgx -      @link,@linkname=one,two +      @txt.gsub!(rgx,'\1') if @txt =~rgx        @vz=SiSU_Env::Get_init.instance.skin      end      def scr_endnote_body -      "<endnote>#@one</endnote> " +      "<endnote>#{@txt}</endnote> "      end      def heading_body1      end @@ -109,4 +120,3 @@ module Format    end  end  __END__ - diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index a930821e..7a23be0b 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -65,20 +65,34 @@ module SiSU_Format_Shared    class CSS_Format      require "#{SiSU_lib}/defaults"      @@fns=nil -    def initialize(md,content=nil,col=nil,en=nil) -      content.gsub!(/<:i[12]>/,'') -      @md,@content=md,content -      @id=@ocn=col[:id] -      @ocnd,@ocns=col[:ocnd],col[:ocns] -      @notenumber=en -      @lv=col[:lev].to_s +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            #|| nil #s/@content/@txt/ +        @col =t_o[:col]            #|| nil +        @notenumber =t_o[:endnote_nr]      || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        #content.gsub!(/<:i[1-9]>/,'') +        #@md,@content=md,content +        p t_o.class +        p caller +      end + +      @txt.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/,'') +      @id=@ocn=@col[:id] +      @ocnd,@ocns=@col[:ocnd],@col[:ocns] +      @lv=@col[:lev].to_s        @@hname=if @md.fns != @@fns          @@fns=@md.fns          ''        end -      @hname=if col[:seg] \ -      and not col[:seg].to_s.empty? -        @@hname=col[:seg].to_s +      @hname=if @col[:seg] \ +      and not @col[:seg].to_s.empty? +        @@hname=@col[:seg].to_s        else @@hname        end        @tab="\t" @@ -87,15 +101,15 @@ module SiSU_Format_Shared        @@tablehead,@@tablefoot=[],[]        @vz=SiSU_Env::Get_init.instance.skin        @env=SiSU_Env::Info_env.new(@md.fns) -      @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" +      @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html"      end      def urls(data)        @words=[]        data.each do |word| -        @words << if word=~/\{(.+?)\}((?:https?|file|ftp)\S+|image)/ -          if word =~/\{(.+?)\}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/ -            m,u,d=/\{(.+?)\}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/.match(word).captures -          else m,u=/\{(.+?)\}((?:https?|file|ftp)\S+|image)/.match(word).captures +        @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ +          if word =~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/ +            m,u,d=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)([;.,](?:\s|$))/.match(word).captures +          else m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/.match(word).captures              d=''            end            word=case m @@ -114,14 +128,14 @@ module SiSU_Format_Shared                %{<a href="#{u}">[#{png}]</a>#{caption}}              else %{[#{png}] #{caption}}              end -            word.gsub!(/\{.+?\}((?:https?|file|ftp)\S+|image)/,ins) +            word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/,ins)            else              link=m[/(.+)/m]              png=m.scan(/\S+/)[0].strip              link=link.strip              ins=%{<a href="#{u}">#{link}</a>#{d}}              #ins=%{#{link} <a href="#{u}">[link]</a>#{d}} -            word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) +            word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp)\S+/,ins)            end          else word          end @@ -131,14 +145,14 @@ module SiSU_Format_Shared      end      def markup(para)        if para !~/^#{Mx[:gr_o]}:code#{Mx[:gr_c]}/ -        if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ -          wm=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|\S+/) +        if para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ +          wm=para.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp)\S+|image)|\S+/)            words=urls(wm)            para.gsub!(/.+/m,words)          end          para.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/m,'')          para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration -        para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url +        para.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url          para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration        else          para.gsub!(/(^|[^}])_</m,'\1<'); para.gsub!(/(^|[^}])_>/m,'\1>') #code-block: angle brackets special characters @@ -147,48 +161,48 @@ module SiSU_Format_Shared        para      end      def paragraph -      %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive" header="#@hname">\n#{@tab*2}#@content\n#{@tab*1}</p>\n}  << "\n" +      %{#{@tab*1}<p class="h#{@lv}" id="#{@ocn}" type="substantive" header="#{@hname}">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}  << "\n"      end      def endnote #used only by db -      @content=markup(@content) +      @txt=markup(@txt)        <<GSUB -#{@tab*1}<p class="endnote" name="note_#@notenumber" from="#@ocn"> -#{@tab*2}<a href="#@base_url#-#@notenumber" name="_#@notenumber">#@notenumber.</a> <note>#@content</note> +#{@tab*1}<p class="endnote" name="note_#{@notenumber}" from="#{@ocn}"> +#{@tab*2}<a href="#{@base_url}#-#{@notenumber}" name="_#{@notenumber}">#{@notenumber}.</a> <note>#{@txt}</note>  #{@tab*1}</p>  GSUB      end      def lev_toc_hname -      %{#{@tab*1}<p class="toc#@lv" header="#@hname"><a href="##@ocn">\n#{@tab*2}#@content\n#{@tab*1}</a></p>\n}  << "\n" +      %{#{@tab*1}<p class="toc#{@lv}" header="#{@hname}"><a href="##{@ocn}">\n#{@tab*2}#{@txt}\n#{@tab*1}</a></p>\n}  << "\n"      end      def lev_toc -      %{#{@tab*1}<p class="toc#@lv"><a href="##@ocn">\n#{@tab*2}#@content\n#{@tab*1}</a></p>\n}  << "\n" +      %{#{@tab*1}<p class="toc#{@lv}"><a href="##{@ocn}">\n#{@tab*2}#{@txt}\n#{@tab*1}</a></p>\n}  << "\n"      end      def lev4_plus -      %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive" header="#@hname">\n#{@tab*2}#@content\n#{@tab*1}</p>\n}  << "\n" +      %{#{@tab*1}<p class="h#{@lv}" id="#{@ocn}" type="substantive" header="#{@hname}">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}  << "\n"      end      def lev4_minus -      %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n}  << "\n" +      %{#{@tab*1}<p class="h#{@lv}" id="#{@ocn}" type="substantive">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}  << "\n"      end      def norm_comment -      %{#{@tab*1}<p class="norm" id="none" type="comment">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} +      %{#{@tab*1}<p class="norm" id="none" type="comment">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}      end      def norm -      @content=markup(@content) -      %{#{@tab*1}<p class="norm" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} +      @txt=markup(@txt) +      %{#{@tab*1}<p class="norm" id="#{@ocn}" type="substantive">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}      end      def indent(t) -      @content=markup(@content) -      %{#{@tab*1}<p class="indent#{t}" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} +      @txt=markup(@txt) +      %{#{@tab*1}<p class="indent#{t}" id="#{@ocn}" type="substantive">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}      end      def para_table        %{<p class="norm" align="left"><font #{@vz.font_small} #{@vz.font_color} #{@vz.font_face}>}      end      def ocn -      %{#{@tab*1}<p class="ocn">#@ocn</p>} << "\n" +      %{#{@tab*1}<label class="ocn">#{@ocn}</label>} << "\n"      end     def html_table # get rid of use html_table        @new_content=[] -      @content.split(/\n/).each do |parablock| +      @txt.split(/\n/).each do |parablock|          m=parablock[/<!f(.+?)!>/,1]          @@tablefoot<<m if m          parablock.gsub!(/<!f.+?!>/,'') @@ -233,27 +247,27 @@ GSUB        @new_content.join      end    end -  class CSS_Format_generic #does CSS_Format in one definition, needs to be told about class, despite brevity of generic, easier to see structure with CSS_Format -    def initialize(css_class='',content='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) +  class CSS_Format_generic #does CSS_Format in one definition, needs to be told about attrib, despite brevity of generic, easier to see structure with CSS_Format +    def initialize(attrib='',txt='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil)        @tab="\t" -      @class=css_class -      @content=content +      @attrib=attrib +      @txt=txt        @lv=@notenumber=lv.to_s -      #@ocn=ocn.to_s +      #{@ocn}=ocn.to_s        @hname=hname.to_s        @id=@ocn=id      end      def paragraph -      css_class=%{class="#@class" } +      attrib=%{class="#{@attrib}" }        if @ocn -        id=%{id="#@ocn" } +        id=%{id="#{@ocn}" }          type=%{type="substantive" }        else          id=%{id="none" }          type=%{type="comment" }        end -      header=%{header="#@hname" } if @hname -      %{#{@tab*1}<p #{css_class}#{id}#{type}#{header}>\n#{@tab*2}#@content\n#{@tab*1}</p>\n}  << "\n" +      header=%{header="#{@hname}" } if @hname +      %{#{@tab*1}<p #{attrib}#{id}#{type}#{header}>\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n}  << "\n"      end      def para        paragraph @@ -261,4 +275,3 @@ GSUB    end  end  __END__ - diff --git a/lib/sisu/v0/shared_structure.rb b/lib/sisu/v0/shared_structure.rb index f7b78e0e..47b8ff0d 100644 --- a/lib/sisu/v0/shared_structure.rb +++ b/lib/sisu/v0/shared_structure.rb @@ -9,8 +9,7 @@   * Author: Ralph Amissah   * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -   2007, -   2008 Ralph Amissah All Rights Reserved. +   2007, 2008 Ralph Amissah All Rights Reserved.   * License: GPL 3 or later: @@ -63,14 +62,15 @@  module SiSU_Structure    class Split_text_object      include SiSU_Viz -    #include SiSU_HTML_Format_type +    #include SiSU_HTML_Format      @@dp=nil      attr_reader :format,:text,:ocn,:scroll_lev_para_ocn,:seg_lev_para_ocn,:lev_para_ocn      def initialize(md,para)        @md,@para=md,para -      @format,@ocn='null','null' +      @format,@ocn='ordinary','ordinary'        #@format,@ocn=nil,nil        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern +      @id_block="#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}"      end      def lev_segname_para_ocn        if @para =~/^#{Mx[:lv_o]}\d:.+?#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -95,7 +95,7 @@ module SiSU_Structure          if @para !~/#{Mx[:id_o]}~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$|^$/ #added 2002w06            @text=@para[/(.+?)/m,1]          end -        if @para[/^#{Mx[:lv_o]}(\d):\S*?#{Mx[:lv_c]}\s+(.+)/m] +        if @para[/^#{Mx[:lv_o]}(\d):\S*?#{Mx[:lv_c]}\s*(.+)/m]            @format,@text=$1,$2          end        end @@ -105,14 +105,16 @@ module SiSU_Structure      def html_seg        lev_segname_para_ocn        @seg_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] -        SiSU_HTML_Format_type::Format_seg.new(@md,@format,@text,@ocn) +        txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} +        SiSU_HTML_Format::Format_seg.new(@md,txt_obj)        end        self      end      def html_scroll        lev_segname_para_ocn        @scroll_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] -        SiSU_HTML_Format_type::Format_scroll.new(@md,@format,@text,@ocn) +        txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} +        SiSU_HTML_Format::Format_scroll.new(@md,txt_obj)        end        self      end @@ -120,18 +122,24 @@ module SiSU_Structure        require "#{SiSU_lib}/shared_xml"        lev_segname_para_ocn        @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -        SiSU_XML_format::Format_scroll.new(@md,@format,@text,"x#@ocn") +        txt_obj={:txt =>@text,:format =>@format,:ocn =>"x#@ocn"} +        SiSU_XML_format::Format_scroll.new(@md,txt_obj)        else -        SiSU_XML_format::Format_scroll.new(@md,@format,@text,"#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") +        id_block="#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" +        txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} +        SiSU_XML_format::Format_scroll.new(@md,txt_obj)        end        self      end      def odt        lev_segname_para_ocn        @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -        SiSU_ODF_format::Format_text_object.new(format,@text,@ocn) +        txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} +        SiSU_ODF_format::Format_text_object.new(@md,txt_obj)        else -        SiSU_ODF_format::Format_text_object.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") +        id_block="#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" +        txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} +        SiSU_ODF_format::Format_text_object.new(@md,txt_obj)        end        self @@ -140,9 +148,25 @@ module SiSU_Structure        lev_segname_para_ocn        #format=@format.dup        @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -        Format::Format_text_object.new(@format,@text,@ocn) +        txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} +        SiSU_Plaintext_format::Format_text_object.new(@md,txt_obj)        else -        Format::Format_text_object.new(@format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") +        id_block="#{Mx[:id_o]}~\d+;[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" +        txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} +        SiSU_Plaintext_format::Format_text_object.new(@md,txt_obj) +      end +      self +    end +    def manpage #check +      lev_segname_para_ocn +      #format=@format.dup +      @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ +        txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} +        SiSU_Manpage_format::Format_text_object.new(@md,txt_obj) +      else +        id_block="#{Mx[:id_o]}~\d+;[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" +        txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} +        SiSU_Manpage_format::Format_text_object.new(@md,txt_obj)        end        self      end diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb index 484a5f05..198b8ce8 100644 --- a/lib/sisu/v0/shared_txt.rb +++ b/lib/sisu/v0/shared_txt.rb @@ -222,51 +222,4 @@ module SiSU_text_utils      end    end  end -module SiSU_text_parts_flatfile -  class Split_text_object -    @@dl=nil -    attr_reader :format,:text,:ocn,:lev_para_ocn -    def initialize(md,para) -      @md,@para=md,para -      @format,@ocn='null','null' -      #@format,@ocn=nil,nil -      @@dl ||=SiSU_Env::Info_env.new.digest.length -    end -    def lev_segname_para_ocn -      if @para =~/^(?:#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}|<:.+?>).+?#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}.*/ -        if /^(#{Mx[:lv_o]}([1-6]):(\S+?)#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) -          @format,segname,@text,@ocn=$1,$2,$3,$4 -          @format="#@format~#{segname}" # -        elsif  /^(#{Mx[:lv_o]}([1-6]):#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) -          @format,@text,@ocn=$1,$2,$3 -        elsif /<:(.+?)>\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) -          @format,@text,@ocn=$1,$2,$3 -        elsif /^(#{Mx[:lv_o]}([1-6]):(\S+?)#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(0);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) -          @@alt_id_count+=1 -          @format,segname,@text,@ocn=$1,$2,$3,"x#{@@alt_id_count}" -          @format="#@format~#{segname}" # -        elsif /^(#{Mx[:lv_o]}([1-6]):#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(0);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) -          @@alt_id_count+=1 -          @format,@text,@ocn=$1,$2,"x#{@@alt_id_count}" -        end -      else -        if /(.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) -          @text,@ocn=$1,$2 -        end -        if @para !~/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}|^$/ #added 2002w06 -          @text=/(.+?)/m.match(@para)[1] -        end -        if /^(#{Mx[:lv_o]}([1-9]):\S*?#{Mx[:lv_c]})\s*(.+)/m.match(@para) -          @format,@text=$1,$2 -        end -      end -      @lev_para_ocn=if @para =~/.+<~\d+>/ #hmmm, watch -        Format::ParaSiSU.new(@md,@format,@text,@ocn) -      else Format::ParaSiSU.new(@md,@format,@text,'<~0>') -      end -      self -    end -  end -end  __END__ - diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 3c34e67f..41e8c393 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -166,6 +166,8 @@ module SiSU_XML_munge            #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷            ##para.gsub!(//, '&#;')            ##para.gsub!(//, '&;') +          para.gsub!(/</u, '<') # '<'   # < +          para.gsub!(/>/u, '>') # '>'   # >            para.gsub!(/¢/u, '¢') # '¢'   # ¢            para.gsub!(/£/u, '£') # '£'  # £            para.gsub!(/¥/u, '¥') # '¥'    # ¥ @@ -250,10 +252,25 @@ module SiSU_XML_munge            para.gsub!(/ü/u, 'ý') # 'ü'   # ý            para.gsub!(/þ/u, 'þ') # 'þ'  # þ            para.gsub!(/ÿ/u, 'ÿ') # 'ÿ'   # ÿ +          para.gsub!(/‘/u, '‘') # '‘' # ‘ +          para.gsub!(/’/u, '’') # '’' # ’ +          para.gsub!(/“/u, '“') # “   # “ +          para.gsub!(/”/u, '”') # ”   # ” +          para.gsub!(/–/u, '–') # –   # – +          para.gsub!(/—/u, '—') # —   # — +          para.gsub!(/∝/u, '∝') # ∝    # ∝ +          para.gsub!(/∞/u, '∞') # ∞   # ∞ +          para.gsub!(/™/u, '™') # ™   # ™ +          para.gsub!(/✠/u, '✠') # ✗  # ✠ +          para.gsub!(/ /u, ' ')       # space identify +          para.gsub!(/ /u, ' ')       # space identify          end        end        def html(para='')          if @sys.locale =~/utf-?8/i # instead ucs for utf8 #require 'iconv' ? Iñtërnâtiônàlizætiøn +          para.gsub!(/ /u, ' ')           # space identify +          para.gsub!(/ /u, ' ')           # space identify +        else            para.gsub!(/¢/u, '¢')      # ¢            para.gsub!(/£/u, '£')     # £            para.gsub!(/¥/u, '¥')       # ¥ @@ -338,17 +355,32 @@ module SiSU_XML_munge            para.gsub!(/ü/u, 'ü')      # ý            para.gsub!(/þ/u, 'þ')     # þ            para.gsub!(/ÿ/u, 'ÿ')      # ÿ +          para.gsub!(/‘/u, '&#lsquo;')    # ‘  # ‘ +          para.gsub!(/’/u, '&#rsquo;')    # ’  # ’ +          para.gsub!(/“/u, '“')     # “   # “ +          para.gsub!(/”/u, '”')     # ”   # ” +          para.gsub!(/–/u, '–')     # –  # – +          para.gsub!(/—/u, '—')     # —  # — +          para.gsub!(/∝/u, '∝')      # ∝   # ∝ +          para.gsub!(/∞/u, '∞')     # ∞  # ∞ +          para.gsub!(/™/u, '™')     # ™  # ™ +          para.gsub!(/✠/u, '✠')    # ✠ +          #para.gsub!(/✠/u, '†')    # † # † incorrect replacement † +          para.gsub!(/ /u, ' ')           # space identify +          para.gsub!(/ /u, ' ')           # space identify          end        end        self      end      def tidywords(wordlist)        wordlist.each do |x| +        #imperfect solution will not catch all possible cases          x.gsub!(/&/,'&') unless x =~/&\S+;/ +        x.gsub!(/&([A-Z])/,'&\1')        end      end      def markup(para='') -      wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 +      wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17        para=tidywords(wordlist).join(' ').strip        para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />')        para.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') @@ -377,23 +409,25 @@ module SiSU_XML_munge          para.gsub!(/#{Mx[:br_page]}\s*/,'')          para.gsub!(/#{Mx[:br_page_new]}\s*/,'')          para.gsub!(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''); para.gsub!(/<[-~]#>/,'') -        para.gsub!(/(?:^|[^_\\])\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/, -	  %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1" width="\\2" height="\\3" />[\\1] \\4}) -        para.gsub!(/(?:^|[^_\\])\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/, -	  %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1"/>\\1}) -        para.gsub!(/(^|#{Mx[:gl_c]}|\s)\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/, +        para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}(https?:\/\/\S+)/, +          %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1" width="\\2" height="\\3" />[\\1] \\4}) +        para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?#{Mx[:lnk_c]}(https?:\/\/\S+)/, +          %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1"/>\\1}) +        para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, +          %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1" width="\\2" height="\\3" />[\\1] \\4}) +        para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?#{Mx[:lnk_c]}image/, +          %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1"/>\\1}) +        para.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/,            '\1<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\3">\2</link>\4') #watch, compare html_tune          para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,            %{\\1#{@url_brace.xml_open}<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\\2">\\2</link>#{@url_brace.xml_close}\\3})          para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, -	  '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\1">\1</link>\2') #escaped urls not linked, deal with later -        para.gsub!(/ /,' ') -        #para.gsub!(/ /,' ') #clean +          '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\1">\1</link>\2') #escaped urls not linked, deal with later        else          para.gsub!(/(^|[^}])_</m,'\1<'); para.gsub!(/(^|[^}])_>/m,'\1>') #code-block: angle brackets special characters          para.gsub!(/(^|[^}])_</m,'\1<'); para.gsub!(/(^|[^}])_>/m,'\1>') -        para.gsub!(/ /,' ')        end +      para.gsub!(/ |#{Mx[:nbsp]}/m,' ')        para      end      def markup_light(para='') @@ -406,11 +440,11 @@ module SiSU_XML_munge        para.gsub!(/<[-~]#>/,'')        para.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort        para.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax -      para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, +      para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,          "<image.path>#{@dir.url.images_local}\/\\1</image.path>") -      para.gsub!(/ /,' ') +      para.gsub!(/ |#{Mx[:nbsp]}/,' ')        #para.gsub!(/ /,' ') #clean -      wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 +      wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17        para=tidywords(wordlist).join(' ').strip        para      end @@ -429,11 +463,11 @@ module SiSU_XML_munge        para.gsub!(/<[-~]#>/,'')        para.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort        para.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax -      para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, +      para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,          "<image.path>#{@dir.url.images_local}\/\\1</image.path>") -      para.gsub!(/ /,' ') +      para.gsub!(/ |#{Mx[:nbsp]}/,' ')        #para.gsub!(/ /,' ') #clean -      wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 +      wordlist=para.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17        para=tidywords(wordlist).join(' ').strip        para      end diff --git a/lib/sisu/v0/spell.rb b/lib/sisu/v0/spell.rb index 477a472f..8f89c470 100644 --- a/lib/sisu/v0/spell.rb +++ b/lib/sisu/v0/spell.rb @@ -72,7 +72,8 @@ module Utility      end      def check        @input.each do |data| -        data.gsub!(/(https?|www|ftp|gopher|png|jpg|gif|html|htm| )\S+/i,' ') +        data.gsub!(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' ') +        data.gsub!(/( |#{Mx[:nbsp]})/i,' ')          data.gsub!(/<\/?(table|tr|td|b|p|href).*?>/i,' ')          data.gsub!(/(<==.+|<:\S+>|<!.+?!>|^0~.+|\{\{\{|~)/,' ')          data.gsub!(/(["|<>)(\n'`'.;&_-]|\=)/,' ') diff --git a/lib/sisu/v0/sst_do_inline_footnotes.rb b/lib/sisu/v0/sst_do_inline_footnotes.rb index 5cfd38da..514eb2c8 100644 --- a/lib/sisu/v0/sst_do_inline_footnotes.rb +++ b/lib/sisu/v0/sst_do_inline_footnotes.rb @@ -473,8 +473,9 @@ module SiSU_Convert_footnotes                                                                                 #% same as db clean -->        s=s.gsub(/<del>(.+?)<\/del>/,'DELETED(\1)')                           # deletions        s=s.gsub(/<sup>(\d+)<\/sup>/,'[\1]') -      s=s.gsub(/(?: \\;)+/,' ') +      s=s.gsub(/(?: \\;|#{Mx[:nbsp]})+/,' ')  #checking source Mx not necessary        s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ')             # else image names found in search +      s=s.gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp)\\\:\S+ /,' [image] ')             # else image names found in search        s=s.gsub(/\s\s+/,' ')        s=s.strip      end diff --git a/lib/sisu/v0/sst_to_s_xml_dom.rb b/lib/sisu/v0/sst_to_s_xml_dom.rb index 23143ed8..30dc370a 100644 --- a/lib/sisu/v0/sst_to_s_xml_dom.rb +++ b/lib/sisu/v0/sst_to_s_xml_dom.rb @@ -365,7 +365,9 @@ WOK            para.gsub!(/<:pb>\s*/,'')            para.gsub!(/\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,              "<image.path>#{dir.url.images_local}/\\1</image.path>") -          para.gsub!(/ /,' ') +          para.gsub!(/#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/, +            "<image.path>#{dir.url.images_local}/\\1</image.path>") +          para.gsub!(/ |#{Mx[:nbsp]}/,' ')  # checking source Mx not necessary            para=SiSU_document_structure::Structure.new(@md,para).structure            @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8            para.gsub!(/^0~(\S+)/,"#{Mx[:lv_o]}@\\1#{Mx[:lv_c]}") @@ -384,7 +386,7 @@ WOK              @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para              unless @rcdc                if para !~/^(?:%\s|0~|@\S+?:)/ -                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ +                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|ordinary/                  case @sto.format                  when /^(1):(\S*)/                    xml_clean(para) @@ -410,25 +412,6 @@ WOK                    xml_clean(para)                    xml_structure($1,para,$2)                    para=@sto.lev_para_ocn.heading_body6 -                #when /^(i1)$/i -                #  #format_scroll.gsubBody -                #  #para=@sto.lev_para_ocn.scrIndent1 -                #when /^(i2)$/i -                #  format_scroll.gsubBody -                #  para=@sto.lev_para_ocn.scrIndent2 -                #when /^(center)$/i -                #  para.gsub!(/(.+)/, -                #    %{<center>(\\1)</center>}) -                #  para=@sto.lev_para_ocn.scrPara -                #when /^(b|bold)$/i -                #  para.gsub!(/(.+)/, -                #    %{<b>(\\1)</b>}) -                #  para=@sto.lev_para_ocn.scrPara -                #when /null/ # see whether u can improve -                #    if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) -                #      #format_scroll.gsubBody -                #      #para=@sto.lev_para_ocn.scrPara -                #    end                  else                    if para =~ /<:verse>/                      para=poem_structure(para) diff --git a/lib/sisu/v0/sst_to_s_xml_node.rb b/lib/sisu/v0/sst_to_s_xml_node.rb index ed7f4b10..d9451149 100644 --- a/lib/sisu/v0/sst_to_s_xml_node.rb +++ b/lib/sisu/v0/sst_to_s_xml_node.rb @@ -440,54 +440,6 @@ WOK              end            end          end -        #obj.each do |o| -        #  para=o.txt unless o.txt =~/^%% / #comments are lost, consider -        #  if para -        #    para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') -        #    para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') -        #    para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') -        #    para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') -        #    para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_paragraph]}/,'<br />') -        #    if @rcdc==false \ -        #    and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) -        #      if para !~/(^0~|^@\S+?:|^\s*$|<ENDNOTES>|<EOF>)/ -        #        @rcdc=true -        #      end -        #      @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para -        #      unless @rcdc -        #        format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ -        #        case @sto.format -        #        when /^(1):(\S*)/ -        #          node_structure(o,para,$1,$2) -        #        when /^(2):(\S*)/ -        #          node_structure(o,para,$1,$2) -        #        when /^(3):(\S*)/ -        #          node_structure(o,para,$1,$2) -        #        when /^(4):(\S*)/ # work on see Split_text_object -        #          node_structure(o,para,$1,$2) -        #        when /^(5):(\S*)/ -        #          node_structure(o,para,$1,$2) -        #        when /^(6):(\S*)/ -        #          node_structure(o,para,$1,$2) -        #        else -        #          if para =~ /<:verse>/ -        #            node_structure(o,para) -        #          elsif para =~ /<:group>/ -        #            node_structure(o,para) -        #          elsif para =~ /<:code>/ -        #            node_structure(o,para) -        #          elsif para =~/<!Th?.+/ # tables come as single block #work area 2005w13 -        #          #elsif para =~/#{Mx[:gr_o]}Th?.+/ # tables come as single block #work area 2005w13 -        #            table=SiSU_Tables::Table_xml.new(para) -        #            para=table.table_split -        #            node_structure(o,para) -        #          else node_structure(o,para,nil,nil) -        #          end -        #        end -        #      end -        #    end -        #  end -        #end          obj.each do |o|            para=o.txt unless o.txt =~/^%% / #comments are lost, consider            if para @@ -504,7 +456,7 @@ WOK              if para !~/(^0~|^@\S+?:|^\s*$|<ENDNOTES>|<EOF>)/                @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para                unless @rcdc -                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ +                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|ordinary/                  case @sto.format                  when /^(1):(\S*)/                    xml_clean(para) diff --git a/lib/sisu/v0/sst_to_s_xml_sax.rb b/lib/sisu/v0/sst_to_s_xml_sax.rb index 4b3ca7c8..e6864405 100644 --- a/lib/sisu/v0/sst_to_s_xml_sax.rb +++ b/lib/sisu/v0/sst_to_s_xml_sax.rb @@ -293,7 +293,7 @@ WOK            if para !~/(^0~|^@\S+?:|^\s*$|<ENDNOTES>|<EOF>)/              @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para              unless @rcdc -              format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ +              format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/                case @sto.format                when /^(1):(\S*)/                  xml_clean(para) @@ -319,25 +319,6 @@ WOK                  xml_clean(para)                  xml_structure(para,$1,$2)                  para=@sto.lev_para_ocn.heading_body6 -              #when /^(i1)$/i -              #  #format_scroll.gsubBody -              #  #para=@sto[:lev_para_ocn].scrIndent1 -              #when /^(i2)$/i -              #  format_scroll.gsubBody -              #  para=@sto[:lev_para_ocn].scrIndent2 -              #when /^(center)$/i -              #  para.gsub!(/(.+)/, -              #    %{<center>(\\1)</center>}) -              #  para=@sto[:lev_para_ocn].scrPara -              #when /^(b|bold)$/i -              #  para.gsub!(/(.+)/, -              #    %{<b>(\\1)</b>}) -              #  para=@sto[:lev_para_ocn].scrPara -              #when /null/ # see whether u can improve -              #    if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/) -              #      #format_scroll.gsubBody -              #      #para=@sto[:lev_para_ocn].scrPara -              #    end                else                  if para =~ /<:verse>/                    para=poem_structure(para) diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index a259d991..25cf90ec 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -518,7 +518,8 @@ module SiSU_Env          :sxs             => filename(code,@fnb,'.sxs.xml'),          :sxd             => filename(code,@fnb,'.sxd.xml'),          :sxn             => filename(code,@fnb,'.sxn.xml'), -        :sisupod         => filename(nil,@fnz,'') +        :sisupod         => filename(nil,@fnz,''), +        :book_index      => filename(code,'book_index','.html'),        }        @fn      end @@ -712,6 +713,7 @@ module SiSU_Env      end      def scp        program='scp' +      puts "scp -Cr #@input #@output" if @cmd =~/[vVM]/        if program_found?(program); system("scp -Cr #@input #@output")        else                        puts "\tWARN: #{program} not found"        end @@ -725,6 +727,7 @@ module SiSU_Env          end          msg=''          msg=" && echo 'OK: #@input -> #@output'" unless @cmd =~/q/ +        puts "rsync -az#{vb} #{action} #@input #@output" if @cmd =~/[vVM]/          system("rsync -az#{vb} #{action} #@input #@output #{msg}")        else puts "\tWARN: #{program} not found"        end @@ -2469,7 +2472,8 @@ WOK          and remote_gen !~/\/\//) \          and @@flag_remote==true \          and @opt.cmd !~/U/ -          System_call.new(local_gen,remote_gen,@opt.cmd).rsync('--delete-after') +          delete_extra_files='--delete' # '--delete-after' +          System_call.new(local_gen,remote_gen,@opt.cmd).rsync(delete_extra_files)            if FileTest.file?("#{local_src}/#{src_txt}")              System_call.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync              if defined? @md.ec[:image] and not @md.ec[:image].empty? @@ -2569,10 +2573,11 @@ WOK          and @rc['permission_set']['remote_base_site'] \          and @@flag_remote==true \          and @opt.cmd !~/U/ +          delete_extra_files='--delete' # '--delete-after'            puts "begin rsync_base_sync: #{local} -> #{remote}" -          System_call.new("#{local}/_sisu/image_sys/",remote).rsync('--delete-after') -          System_call.new("#{local}/_sisu/image/",remote).rsync('--delete-after') -          System_call.new("#{local}/#{@env.path.style}/",remote).rsync('--delete-after') +          System_call.new("#{local}/_sisu/image_sys/",remote).rsync(delete_extra_files) +          System_call.new("#{local}/_sisu/image/",remote).rsync(delete_extra_files) +          System_call.new("#{local}/#{@env.path.style}/",remote).rsync(delete_extra_files)          elsif @opt.cmd =~/U/            puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/            puts "rsync_base_sync: #{local} -> #{remote}" @@ -2589,7 +2594,8 @@ WOK          remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/."          if @@flag_remote          #if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] #and @@flag_remote==true and @opt.cmd !~/U/ -          System_call.new(local,remote).rsync('--delete-after') +          delete_extra_files='--delete' # '--delete-after' +          System_call.new(local,remote).rsync(delete_extra_files)          elsif @opt.cmd =~/U/            puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/            puts "rsync_sitemaps: #{local} -> #{remote}" @@ -3027,12 +3033,18 @@ WOK      def file_meta        File.new("#{@env.path.dal}/#@fns.meta",'w+')      end +    def file_meta_idx_html +      File.new("#{@env.path.dal}/#@fns.idx.html",'w+') +    end      def file_note        File.new("#{Dir.pwd}/#@fns.fn",'w+')      end      def marshal_meta        "#{@env.path.dal}/#@fns.meta.rbm"      end +    def marshal_meta_idx_html +      "#{@env.path.dal}/#@fns.idx_html.rbm" +    end      def meta        "#{@env.path.dal}/#@fns.meta"      end diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index adcba123..3ff5652c 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -65,7 +65,7 @@ module SiSU_TexInfo    include SiSU_Viz    #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags)    require "#{SiSU_lib}/texinfo_format" -  include TexInfoFormat +  include SiSU_Texinfo_format    @tex_file=[]    @@tex_backslash="\\\\"    @@tabular="{tabular}" @@ -82,7 +82,6 @@ module SiSU_TexInfo        @opt=opt        @env=SiSU_Env::Info_env.new(@opt.fns)        @st={ 'tex'=>{} } -      @tex=TexInfoFormat::Texinfo.new        @vz=SiSU_Env::Get_init.instance.skin      end      def directories @@ -129,7 +128,7 @@ module SiSU_TexInfo    end    class Texinfo_make      include SiSU_Param -    include TexInfoFormat +    include SiSU_Texinfo_format      @@tex_1='(?:.+?)+~' #?? debug      @@tabular="{tabular}"      @@tex_pattern_margin_number="\\\\marginpar.+?\s+" @@ -138,7 +137,7 @@ module SiSU_TexInfo        @data,@md=data,md #fns        @env=SiSU_Env::Info_env.new(@md.fns)        @st={ 'tex'=>{} } -      #@tex=TexInfoFormat::Texinfo.new +      #@tex=SiSU_Texinfo_format::Texinfo.new        @vz=SiSU_Env::Get_init.instance.skin        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern      end @@ -165,7 +164,8 @@ module SiSU_TexInfo          end          para.gsub!(/<:p[bn]>/,'')          para.gsub!(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') -        do_mono=TexInfoFormat::Texinfo.new(para,@md) +        txt_obj={:txt =>para} +        do_mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)          @tex_file << do_mono.spec_char        end        data=@tex_file.delete_if {|x| x =~ /^0(?:\\)+~/m} @@ -244,7 +244,8 @@ module SiSU_TexInfo        @@tableheader=0        data.each do |para|          if para =~ /#{Mx[:tc_p]}|#{Mx[:gr_o]}T/ui -          do_mono=TexInfoFormat::Texinfo.new(para,@md) +          txt_obj={:txt =>para} +          do_mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)            para=do_mono.longtable # using longtable latex package          end          @tex_file << para @@ -256,19 +257,24 @@ module SiSU_TexInfo        @row_break='\\\\\\'        @break_page="#@row_break\n#@row_break \n"        md={} -      @tex_file << TexInfoFormat::Texinfo.new('',@md).head -      mono=TexInfoFormat::Texinfo.new(@md.title,@md) +      txt_obj={:txt =>''} +      @tex_file << SiSU_Texinfo_format::Texinfo.new(@md,txt_obj).head +      txt_obj={:txt =>@md.title} +      mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)        @tex_file << mono.topnode        texinfo_menu=[]        n_menu,n_submenu=0,0        @submenu,@subsubmenu={},{}        data.each do |para|          para.gsub!(/\s*<:name#example>\s*/,' ') +        para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove          if para =~ /^#{Mx[:lv_o]}[1-3]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ -          toc=TexInfoFormat::Texinfo.new($1,@md) +          txt_obj={:txt =>$1} +          toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)            texinfo_menu << toc.menu          elsif para =~ /^#{Mx[:lv_o]}[4-6]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ -          toc=TexInfoFormat::Texinfo.new($1,@md) +          txt_obj={:txt =>$1} +          toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)            texinfo_menu << toc.menu            case para            when /^#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.+?)\s*$/ @@ -297,7 +303,8 @@ module SiSU_TexInfo        n_menu,n_submenu=0,0        @@do_submenu,@@do_subsubmenu=1,1        data.each do |para| -        mono=TexInfoFormat::Texinfo.new(para,@md) +        txt_obj={:txt =>para} +        mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)          case para          when /^#{Mx[:lv_o]}1:/; mono.level1          when /^#{Mx[:lv_o]}2:/; mono.level2 @@ -310,14 +317,16 @@ module SiSU_TexInfo            n_submenu+=1            @@do_subsubmenu=1            if @@do_submenu==1 -            menu=TexInfoFormat::Texinfo.new(@submenu[n_menu],@md) +            txt_obj={:txt =>@submenu[n_menu]} +            menu=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)              para="#{menu.submenu}#{mono.level5}"              @@do_submenu=0            else mono.level5            end          when /^#{Mx[:lv_o]}6:/;            if @@do_submenu==1 -            menu=TexInfoFormat::Texinfo.new(@subsubmenu[n_menu],@md) +            txt_obj={:txt =>@submenu[n_menu]} +            menu=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)              para="#{menu.subsubmenu}#{mono.level6}"              @@do_subsubmenu=0            else @@ -391,7 +400,7 @@ module SiSU_TexInfo          if para =~/#{Mx[:id_o]}\\~(\d+);\w\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/ \          and para !~ /#{Mx[:br_eof]}/            parablock,paranum=/(.+?)#{Mx[:id_o]}\\~(\d+);\w\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/im.match(para)[1,2] -          do_duo=TexInfoFormat::DuoTex.new(parablock,paranum) ###is BUG +          do_duo=SiSU_Texinfo_format::DuoTex.new(parablock,paranum) ###is BUG            para=do_duo.paraNum if parablock          end          @tex_file << para @@ -400,7 +409,8 @@ module SiSU_TexInfo      end      def tail        data=@data -      tex=TexInfoFormat::Texinfo.new('',@md) +      txt_obj={:txt =>''} +      tex=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)        data << tex.dublincore        data << tex.tail      end @@ -428,4 +438,3 @@ module SiSU_TexInfo    end  end  __END__ - diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index 42d62960..22fd7a84 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -58,7 +58,7 @@   ** Description: texinfo formatting template  =end -module TexInfoFormat +module SiSU_Texinfo_format    @@table_pg_break_counter=1    require "#{SiSU_lib}/param"    include SiSU_Param @@ -69,9 +69,19 @@ module TexInfoFormat      @@tabular="{tabular}"      @@tex_pattern_margin_number="\\\\marginpar.+?\s+"      @@dp=nil -    def initialize(data=nil,md=nil,three=nil) -      @para=@one=data -      @md=md +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        #@h_name =t_o[:h_name]      || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end        @vz=SiSU_Env::Get_init.instance.skin        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern      end @@ -79,12 +89,12 @@ module TexInfoFormat        t=Time.now        year=t.year        filename=%{#{@md.fns}}[/(.+?)\.\w\w\d\d$/,1] -      title=Texinfo.new(@md.title).spec_char +      title=spec_char_string(@md.title)        title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ")        title.gsub!(/\$/,"\\$")        title.gsub!(/[,]\s*/,' - ')        if @md.subtitle -        subtitle=Texinfo.new(@md.subtitle).spec_char +        subtitle=spec_char_string(@md.subtitle)          subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ")          subtitle.gsub!(/\$/,"\\$")          subtitle.gsub!(/[,]\s*/,' - ') @@ -150,42 +160,42 @@ WOK        "#{head}#{titlepage}"      end      def topnode -      @one=Texinfo.new(@one).spec_char -      @one=@one.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") -      @one.gsub!(/\$/,"\\$") -      @one.gsub!(/[,]\s*/,' - ') +      txt=spec_char_string(@txt) +      txt=txt.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") +      txt.gsub!(/\$/,"\\$") +      txt.gsub!(/[,]\s*/,' - ')        "@c %% 4\n" +          "@ifnottex\n" +          "@node Top\n" + -        "@top #@one\n\n" + +        "@top #{txt}\n\n" +          "@insertcopying\n" +          "@end ifnottex\n\n" +          "@menu\n"      end      def dublincore -      title=Texinfo.new(@md.title).spec_char if @md.title -      subtitle=Texinfo.new(@md.subtitle).spec_char if @md.subtitle +      title=spec_char_string(@md.title) if @md.title +      subtitle=spec_char_string(@md.subtitle) if @md.subtitle        dc_title="#{title} - #{subtitle}" -      dc_creator=Texinfo.new(@md.dc_creator).spec_char if @md.dc_creator -      dc_subject=Texinfo.new(@md.dc_subject).spec_char if @md.dc_subject -      dc_description=Texinfo.new(@md.dc_description).spec_char if @md.dc_description -      dc_publisher=Texinfo.new(@md.dc_publisher).spec_char if @md.dc_publisher -      dc_contributor=Texinfo.new(@md.dc_contributor).spec_char if @md.dc_contributor -      dc_date=Texinfo.new(@md.dc_date).spec_char if @md.dc_date -      dc_date_created=Texinfo.new(@md.dc_date_created).spec_char if @md.dc_date_created -      dc_date_issued=Texinfo.new(@md.dc_date_issued).spec_char if @md.dc_date_issued -      dc_date_available=Texinfo.new(@md.dc_date_available).spec_char if @md.dc_date_available -      dc_date_valid=Texinfo.new(@md.dc_date_valid).spec_char if @md.dc_date_valid -      dc_date_modified=Texinfo.new(@md.dc_date_modified).spec_char if @md.dc_date_modified -      dc_type=Texinfo.new(@md.dc_type).spec_char if @md.dc_type -      dc_format=Texinfo.new(@md.dc_format).spec_char if @md.dc_format -      dc_identifier=Texinfo.new(@md.dc_identifier).spec_char if @md.dc_identifier -      dc_source=Texinfo.new(@md.dc_source).spec_char if @md.dc_source -      dc_language=Texinfo.new(@md.dc_language[:name]).spec_char if @md.dc_language[:name] -      #language_original=Texinfo.new(@md.language_original[:name]).spec_char if @md.language_original[:name] -      dc_relation=Texinfo.new(@md.dc_relation).spec_char if @md.dc_relation -      dc_coverage=Texinfo.new(@md.dc_coverage).spec_char if @md.dc_coverage -      dc_rights=Texinfo.new(@md.dc_rights).spec_char if @md.dc_rights +      dc_creator=spec_char_string(@md.dc_creator) if @md.dc_creator +      dc_subject=spec_char_string(@md.dc_subject) if @md.dc_subject +      dc_description=spec_char_string(@md.dc_description) if @md.dc_description +      dc_publisher=spec_char_string(@md.dc_publisher) if @md.dc_publisher +      dc_contributor=spec_char_string(@md.dc_contributor) if @md.dc_contributor +      dc_date=spec_char_string(@md.dc_date) if @md.dc_date +      dc_date_created=spec_char_string(@md.dc_date_created) if @md.dc_date_created +      dc_date_issued=spec_char_string(@md.dc_date_issued) if @md.dc_date_issued +      dc_date_available=spec_char_string(@md.dc_date_available) if @md.dc_date_available +      dc_date_valid=spec_char_string(@md.dc_date_valid) if @md.dc_date_valid +      dc_date_modified=spec_char_string(@md.dc_date_modified) if @md.dc_date_modified +      dc_type=spec_char_string(@md.dc_type) if @md.dc_type +      dc_format=spec_char_string(@md.dc_format) if @md.dc_format +      dc_identifier=spec_char_string(@md.dc_identifier) if @md.dc_identifier +      dc_source=spec_char_string(@md.dc_source) if @md.dc_source +      dc_language=spec_char_string(@md.dc_language[:name]) if @md.dc_language[:name] +      #language_original=spec_char_string(@md.language_original[:name]) if @md.language_original[:name] +      dc_relation=spec_char_string(@md.dc_relation) if @md.dc_relation +      dc_coverage=spec_char_string(@md.dc_coverage) if @md.dc_coverage +      dc_rights=spec_char_string(@md.dc_rights) if @md.dc_rights        dc_title="Title: #{dc_title}\n\n" if dc_title        dc_creator="Creator: #{dc_creator}\n\n" if dc_creator        dc_subject="Subject: #{dc_subject}\n\n" if dc_subject @@ -244,140 +254,143 @@ WOK        para      end      def menu -      para=clean(@para) +      para=clean(@txt)        para=para.gsub(/@footnote\{.+?\}\s+/,'')        "* #{para}::"      end      def level1 -      @para.gsub!(/#{Mx[:lv_o]}1:\S*?#{Mx[:lv_c]}\s*/,'') -      para=clean(@para) +      @txt.gsub!(/#{Mx[:lv_o]}1:\S*?#{Mx[:lv_c]}\s*/,'') +      para=clean(@txt)        nd=para.gsub(/@footnote\{.+?\}\s+/,'')        para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" -      @para.gsub!(/.+/,"#{para}") +      @txt.gsub!(/.+/,"#{para}")      end      def level2 -      @para.gsub!(/#{Mx[:lv_o]}2:\S*?#{Mx[:lv_c]}\s*/,'') -      para=clean(@para) +      @txt.gsub!(/#{Mx[:lv_o]}2:\S*?#{Mx[:lv_c]}\s*/,'') +      para=clean(@txt)        nd=para.gsub(/@footnote\{.+?\}\s+/,'')        para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" -      @para.gsub!(/.+/,"#{para}") +      @txt.gsub!(/.+/,"#{para}")      end      def level3 -      @para.gsub!(/#{Mx[:lv_o]}3:\S*?#{Mx[:lv_c]}\s*/,'') -      para=clean(@para) +      @txt.gsub!(/#{Mx[:lv_o]}3:\S*?#{Mx[:lv_c]}\s*/,'') +      para=clean(@txt)        nd=para.gsub(/@footnote\{.+?\}\s+/,'')        #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,"\\1 \\3\n\\2")        #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,'\1 \3 \2')        para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" -      @para.gsub!(/.+/,"#{para}") +      @txt.gsub!(/.+/,"#{para}")      end      def level4 -      @para.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') -      para=clean(@para) +      @txt.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') +      para=clean(@txt)        nd=para.gsub(/@footnote\{.+?\}\s+/,'')        para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" -      @para.gsub!(/.+/,"#{para}") +      @txt.gsub!(/.+/,"#{para}")      end      def level5 -      @para.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') -      para=clean(@para) +      @txt.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') +      para=clean(@txt)        nd=para.gsub(/@footnote\{.+?\}\s+/,'')        para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" -      @para.gsub!(/.+/,"#{para}") +      @txt.gsub!(/.+/,"#{para}")      end      def level6 -      @para.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') -      para=clean(@para) +      @txt.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') +      para=clean(@txt)        nd=para.gsub(/@footnote\{.+?\}\s+/,'')        para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" -      @para.gsub!(/.+/,"#{para}") +      @txt.gsub!(/.+/,"#{para}")      end      def submenu -      @para=@para.join("\n") -      @para.gsub!(/[5]\\+~\S+/,'') -      para=clean(@para) +      @txt=@txt.join("\n") +      @txt.gsub!(/[5]\\+~\S+/,'') +      para=clean(@txt)        para="@menu\n#{para}\n@end menu\n\n" -      @para.gsub!(/.+/m,"#{para}") +      @txt.gsub!(/.+/m,"#{para}")      end      def subsubmenu -      @para=@para.join("\n") -      @para.gsub!(/[6]\\+~\S+/,'') -      para=clean(@para) +      @txt=@txt.join("\n") +      @txt.gsub!(/[6]\\+~\S+/,'') +      para=clean(@txt)        para="@menu\n#{para}\n@end menu\n\n" -      @para.gsub!(/.+/m,"#{para}") +      @txt.gsub!(/.+/m,"#{para}")      end      def indent1 -      @para.gsub!(/<:i1>(.*)/,'\1') +      @txt.gsub!(/<:i1>(.*)/,'\1')      end      def indent2 -      @para.gsub!(/<:i2>(.*)/,'\1') +      @txt.gsub!(/<:i2>(.*)/,'\1') +    end +    def spec_char_string(txt) # special characters +      txt_obj={:txt =>txt} +      SiSU_Texinfo_format::Texinfo.new(@md,txt_obj).spec_char      end      def spec_char # special characters -      @para.gsub!(/#{Mx[:br_eof]}/i,'') -      @para.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') -      @para.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); @para.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') -      @para.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); @para.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') -      @para.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') -      @para.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') -      @para.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') -      @para.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') -      @para.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') -      @para.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') -      @para.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') -      @para.gsub!(/\\/,'\\backslash ') -      @para.gsub!(/<:pb>/,'\\newpage') -      @para.gsub!(/\\backslash copyright/,'\\copyright ') -      @para.gsub!(/\^/,'\\wedge ') -      @para.gsub!(/(\$)/,"\\$") -      @para.gsub!(/\~/,'\\~') -      @para.gsub!(/%/,"\\%") -      #if @para !~ /^\s*<:image|\}:image\s/ -      #  @para.gsub!(/_/,'\_') +      @txt.gsub!(/#{Mx[:br_eof]}/i,'') +      @txt.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') +      @txt.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); @txt.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') +      @txt.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); @txt.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') +      @txt.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') +      @txt.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') +      @txt.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') +      @txt.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') +      @txt.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') +      @txt.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') +      @txt.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') +      @txt.gsub!(/\\/,'\\backslash ') +      @txt.gsub!(/<:pb>/,'\\newpage') +      @txt.gsub!(/\\backslash copyright/,'\\copyright ') +      @txt.gsub!(/\^/,'\\wedge ') +      @txt.gsub!(/(\$)/,"\\$") +      @txt.gsub!(/\~/,'\\~') +      @txt.gsub!(/%/,"\\%") +      #if @txt !~ /^\s*<:image|\}:image\s/ +      #  @txt.gsub!(/_/,'\_')        #end -      @para.gsub!(/_(https?:\/\/)/,'\1') -      @para.gsub!(/§/i,'\S') -      @para.gsub!(/£/i,'\pounds') -      @para.gsub!(/å/i,'\aa') -      @para.gsub!(/æ/i,'\ae') -      @para.gsub!(/ø/i,'\o') -      @para.gsub!(/Å/i,'\AA') -      @para.gsub!(/Æ/i,'\AE') -      @para.gsub!(/Ø/i,'\O') -      @para.gsub!(/<a href=".+?">/i,' ') -      @para.gsub!(/<\/a>/i,' ') -      @para.gsub!(/<:ee>/i,'') -      @para.gsub!(/<!>/i,' ') -      @para.gsub!(/<b>(.+?)<\/b>/,'\*\1\*') -      @para.gsub!(/<i>(.+?)<\/i>/,'\/\1\/') -      @para.gsub!(/<u>(.+?)<\/u>/,'\_\1\_') -      @para.gsub!(/@/i,'@@') -      @para.gsub!(/\{/,'@{'); @para.gsub!(/\}/,'@}') -      #@para.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @para.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') -      @para.gsub!(/  /,' ')  # ~ character for hardspace -      @para.gsub!(/ /,' ')        # ~ character for hardspace -      @para.gsub!(/&(\S+?);/,' ') -      @para.gsub!(/&/,'<=and>') -      @para.gsub!(/(\s+&\s+)/,' and ') -      @para.gsub!(/(\&)/,"\\&") -      @para.gsub!(/"(.+?)"/,"`\\1'")                                        # open & close " -      @para.gsub!(/\s+"/," `")                                              # open " -      @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`')       # open " -      @para.gsub!(/"(\s|\.|,|:|;)/,"'\\1")                                  # close " -      @para.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1")       # close " -      @para.gsub!(/"(\.|,)/,"'")                                            # close " -      @para.gsub!(/\s+'/," `")                                              # open ' -      @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`')       # open ' -      @para.gsub!(/(<font.*?>|<\/font>)/,'') -      @para.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') -      @para.gsub!(/(<sup>|<\/sup>)/,'') -      @para +      @txt.gsub!(/_(https?:\/\/)/,'\1') +      @txt.gsub!(/§/i,'\S') +      @txt.gsub!(/£/i,'\pounds') +      @txt.gsub!(/å/i,'\aa') +      @txt.gsub!(/æ/i,'\ae') +      @txt.gsub!(/ø/i,'\o') +      @txt.gsub!(/Å/i,'\AA') +      @txt.gsub!(/Æ/i,'\AE') +      @txt.gsub!(/Ø/i,'\O') +      @txt.gsub!(/<a href=".+?">/i,' ') +      @txt.gsub!(/<\/a>/i,' ') +      @txt.gsub!(/<:ee>/i,'') +      @txt.gsub!(/<!>/i,' ') +      @txt.gsub!(/<b>(.+?)<\/b>/,'\*\1\*') +      @txt.gsub!(/<i>(.+?)<\/i>/,'\/\1\/') +      @txt.gsub!(/<u>(.+?)<\/u>/,'\_\1\_') +      @txt.gsub!(/@/i,'@@') +      @txt.gsub!(/\{/,'@{'); @txt.gsub!(/\}/,'@}') +      #@txt.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @txt.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') +      @txt.gsub!(/(?: |#{Mx[:nbsp]})+/,' ')        # ~ character for hardspace +      @txt.gsub!(/&(\S+?);/,' ') +      @txt.gsub!(/&/,'<=and>') +      @txt.gsub!(/(\s+&\s+)/,' and ') +      @txt.gsub!(/(\&)/,"\\&") +      @txt.gsub!(/"(.+?)"/,"`\\1'")                                        # open & close " +      @txt.gsub!(/\s+"/," `")                                              # open " +      @txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`')       # open " +      @txt.gsub!(/"(\s|\.|,|:|;)/,"'\\1")                                  # close " +      @txt.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1")       # close " +      @txt.gsub!(/"(\.|,)/,"'")                                            # close " +      @txt.gsub!(/\s+'/," `")                                              # open ' +      @txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`')       # open ' +      @txt.gsub!(/(<font.*?>|<\/font>)/,'') +      @txt.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') +      @txt.gsub!(/(<sup>|<\/sup>)/,'') +      @txt      end      def longtable        @end_table="\\end{longtable}"        @row_break='\\\\\\' -      if @para[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] #CHECK !> closure +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] #CHECK !> closure          no_of_cols,cols_width=$1,$2 -        @@tableheader=1 if @para =~ /#{Mx[:gr_o]}Th/i +        @@tableheader=1 if @txt =~ /#{Mx[:gr_o]}Th/i          @w=cols_width.split(/;\s+/)          @@number_of_cols=no_of_cols          @colW=[] @@ -390,31 +403,31 @@ WOK          @colW=@colW.join          @@start_table="\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +            "\\begin{longtable}[hb]#@colW\n" -        @para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}")        end -      if @para =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @para.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table")        end -      @para.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +      @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')        if @@tableheader==1 -        if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u            tablefoot=para[/\<!f(.+?)!\>/,1] -          @para.gsub!(/\<!f(.+?)!\>/,'') -          @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, +          @txt.gsub!(/\<!f(.+?)!\>/,'') +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,            "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&") -          @para.gsub!(/&>\s*$/, +          @txt.gsub!(/&>\s*$/,            " #@row_break \\hline\\endhead #@row_break") -          @para="#@para \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot +          @txt="#{@txt} \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot            @@tableheader=0            @@number_of_cols=0          end        else -        if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u -          @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") -          @para.gsub!(/&>\s*$/," #@row_break") +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") +          @txt.gsub!(/&>\s*$/," #@row_break")          end        end -      @para +      @txt      end      def scopedtable        # some features related to headers have been incorporated in longtable @@ -423,7 +436,7 @@ WOK        @end_table="\\end{tabular}"        @row_break='\\\\\\\\'        @break_page="#@row_break\n#@row_break \n" -      if @para[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui]          no_of_cols,cols_width=$1,$2          @w=cols_width.split(/;\s+/)          @colW=[] @@ -432,59 +445,59 @@ WOK            @colW << "p{#{col_w}cm}" if col_w          end          @@start_table="\\begin{tabular}{#@colW}\n" -        @para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}")        end -      if @para =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @para.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table")          @@table_pg_break_counter=1        end -      if @para =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u +      if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u          if @@table_pg_break_counter==28 # taken from 34 ideal for portrait to 28 which suits landscape -          @para = +          @txt =              "\n\n#@end_table \n" +              "#@break_page" +              "#{@@start_table}\n"            @@table_pg_break_counter=1          else -          @para.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +          @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')            @@table_pg_break_counter+=1 -          tablefoot=@para[/\<!f(.+?)!\>/] -          @para.gsub!(/\<!f(.+?)!\>/,'') +          tablefoot=@txt[/\<!f(.+?)!\>/] +          @txt.gsub!(/\<!f(.+?)!\>/,'')          end        end -      if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u -      @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") -      @para.gsub!(/&>\s*$/,"#@row_break") +      if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u +      @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") +      @txt.gsub!(/&>\s*$/,"#@row_break")        end -      @para +      @txt      end      def graphics        dir=SiSU_Env::Info_env.new(@md.fns) -      @para.gsub!(/<::\s+(\S+?)\s+>/i, #watch +      @txt.gsub!(/<::\s+(\S+?)\s+>/i, #watch          "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}")      end      def image        dir=SiSU_Env::Info_env.new(@md.fns)        width="100" -      width=@para[/<:image.+?width=``(\d+)''.+?>/im,1] +      width=@txt[/<:image.+?width=``(\d+)''.+?>/im,1]        width=width.to_i*0.4 -      @para.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, +      @txt.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i,          "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\2}}") -      @para.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, +      @txt.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i,          "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\1}")      end      def png        # very messy clean up ! - work area, testing -      z=@para[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! +      z=@txt[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile !        image,w,x,y=z.scan(/\S+/)        image.gsub!(/\\/,'') -      @para.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"<image #{image} not available>")  # fragile match operator\\ fragile ! +      @txt.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"<image #{image} not available>")  # fragile match operator\\ fragile !      end      def http        # very messy clean up ! - work area, testing -      z=@para[/\\\{(.+?)\}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! -      url=@para[/((?:https?|file|ftp):\S+)/im,1] -      if @para =~/\.(png|jpg|gif)/ +      z=@txt[/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! +      url=@txt[/((?:https?|file|ftp):\S+)/im,1] +      if @txt =~/\.(png|jpg|gif)/          image,w,x,y=z.scan(/\S+/)          image.gsub!(/\\/,'')          width=200 @@ -496,11 +509,11 @@ WOK        end        if image          dir=SiSU_Env::Info_env.new(@md.fns) -        @para.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! +        @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile !            "\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}")        else          link=z[/(.+?)\\/im,1] -        @para.gsub!(/\{.+?\}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}")  # fragile match operator\\ fragile ! +        @txt.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}")  # fragile match operator\\ fragile !        end      end    end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index 8d951dfb..885643cf 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -72,7 +72,7 @@ module SiSU_TeX    @@tabular="{tabular}"    @@column_instruct=@@squigle_close=@@tex_line_mode=@@tex_word_mode=@@line_mode=''    @@tex_debug_counter=@@table_pagebreak_counter=@@tex_footnote_call_counter=@@tex_table_flag=@@tex_counter=@@tex_column=@@tex_columns=@@tex_columns=@@counting=0 -  @@tex_pattern_margin_number=/\\\\begin\\\{tiny\\\}~\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+/ +  @@tex_pattern_margin_number=/\\\\begin\\\{tiny\\\}\\\\hspace\\\{0mm\\\}\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+/    #@@tex_pattern_margin_number="\\\\marginpar.+?\s+"    @@n=@@tableheader=@@rights=nil    @@date ||=SiSU_Env::Info_date.new @@ -344,6 +344,7 @@ module SiSU_TeX            # DEBUG 2003w16 this is a kludge, because i could not get parameters            # from param, Sort out ... revert to more elegant solution            # even more of a kludge as had to insert newlines where code is used not satisfactory, think about +          para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/            para=if para =~/#{Mx[:br_nl]}|\n/; para.split(/#{Mx[:br_nl]}|\n/)            else para            end @@ -382,8 +383,10 @@ module SiSU_TeX          @md.papersize_array.each do |ps|            @@tableheader={ ps => { :p => 0, :l => 0 }}            para,para_p=@para.dup,@para.dup #visit -          format_l=SiSU_TeX_Pdf::Format_text_object.new(md,para,ps) -          format_p=SiSU_TeX_Pdf::Format_text_object.new(md,para_p,ps) +          txt_obj={:txt =>para,:paper_size =>ps} +          format_l=SiSU_TeX_Pdf::Format_text_object.new(md,txt_obj) +          txt_obj={:txt =>para_p,:paper_size =>ps} +          format_p=SiSU_TeX_Pdf::Format_text_object.new(md,txt_obj)            @block[ps]={              :l => format_l.longtable_landscape,              :p => format_p.longtable_portrait @@ -411,7 +414,8 @@ module SiSU_TeX        end        def markup_common(para)          tex_f=nil -        mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) +        txt_obj={:txt =>para} +        mono=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj)          if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/ \          or @@flag_alt            if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/ @@ -435,8 +439,9 @@ module SiSU_TeX              end            elsif x =~/code/; @@flag_alt,@@flag_code=true,true            elsif @@flag_alt -            if para =~ /\}(?:https?|file|ftp)/m -              para=SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http +            if para =~ /(?:https?|file|ftp)/m +              txt_obj={:txt =>para,:paper_size =>'a4'} +              para=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http              end              @group_collect << para #<< "\n\n"            end @@ -485,7 +490,7 @@ module SiSU_TeX            when /^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/; mono.indent($1)            when /<:=/;                                mono.symbol_graphic #watch            when /^\s*<:image\s+/;                     mono.image -          when /\}image/;                            mono.png +          when /#{Mx[:lnk_c]}image/;                 mono.png            else              para.strip!              para=enclose(para) unless para =~/^$/ @@ -499,13 +504,15 @@ module SiSU_TeX            end            para          end -        if para =~ /\}(?:https?|file|ftp)/ +        if para =~ /(?:https?|file|ftp)/            para=if para !~/\.(?:png|jpg|gif)/ -            SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http +            txt_obj={:txt =>para,:paper_size =>'a4'} +            SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http            else              @block={}              @md.papersize_array.each do |ps| -              image=SiSU_TeX_Pdf::Format_text_object.new(@md,para,ps).http +              txt_obj={:txt =>para,:paper_size =>ps} +              image=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http                @block[ps]={                  :l => image,                  :p => image @@ -524,16 +531,21 @@ module SiSU_TeX          title=@md.title.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex          subtitle=@md.subtitle.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') if @md.subtitle #no line splitting in heading neither html nor latex          @md.papersize_array.each do |ps| -          orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,ps,'portrait',"#{home}: - #{title} #{subtitle}") -          orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,ps,'landscape',"#{home}: - #{title} #{subtitle}") +          txt_obj={:txt =>"#{home}: - #{title} #{subtitle}",:paper_size =>ps,:orientation =>'portrait'} +          orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) +          txt_obj={:txt =>"#{home}: - #{title} #{subtitle}",:paper_size =>ps,:orientation =>'landscape'} +          orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj)            @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation            @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation          end          @tex_file <<<<WOK  #{@tex.header}#{@tex.footer} -\\tolerance=500 +\\tolerance=300 +\\clubpenalty=300 +\\widowpenalty=300  \\makeatother  \\makeatother +% \\sloppy  \\begin{document}  WOK          sisu_rc_footnote=if @md.sc_info; @tex.doc_sc_info_footnote_full @@ -544,8 +556,9 @@ WOK          #end          @copymark='' #check and remove as now is superflous          x={} -        x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_landscape -        x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_portrait +        txt_obj={:title =>@md.title,:subtitle =>@md.subtitle} +        x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_landscape +        x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_portrait          @tex_file << x          x=nil          if @md.dc_creator @@ -640,12 +653,12 @@ WOK                s_lnk.gsub!(/\s*(#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]})\s*/,' \\\\\\\\ ')                s_lnk.gsub!(/(?:\\)*([$&~%_#}{^])/,"\\\\\\1")                       #latex special chars                if url !~/^\.(\.)?\// -                s_lnk_url=%<\\begin{scriptsize}\\href{#{url}}{#{url}}\\end{scriptsize}>  # note this bit of dereferencing magic +                s_lnk_url=%<\\begin{scriptsize}\\url{#{url}}\\end{scriptsize}>  # note this bit of dereferencing magic                else                  url.gsub!(/\.\.\//,'')                  s_lnk_url="(#{@tex.site}) \\\\\n" + ' ' +                    "\\begin{scriptsize}" + -                  %<\\href\{#{@vz.url_root_http}/#{url}\}\{#{@vz.url_root_http}/#{url}\}> + # note this bit of dereferencing magic +                  %<\\url\{#{@vz.url_root_http}/#{url}\}> + # note this bit of dereferencing magic                    "\\end{scriptsize}"                end                @tex_file << " #{s_lnk} \\\\\n #{s_lnk_url} \n" unless  @md.doc_skin =~/skin_mail/ @@ -680,7 +693,9 @@ WOK            paranum=if ocn; para[m,2]            else ''            end -          do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,parablock,paranum) +          paranum = '' if paranum.to_i == 0 +          txt_obj={:txt =>parablock,:ocn =>paranum} +          do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj)            para=do_duo.para_num if parablock          elsif para =~/^#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #2005 this is added for tables, rationalise            m=/#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/m diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 0fa439f0..5c2b7ec5 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -68,7 +68,7 @@ module SiSU_TeX_Pdf      @@sys=SiSU_Env::System_call.new      @@tex_backslash="\\\\"      @@tilde='\\\\\\~' #?? debug crazy -    @@tex_pattern_margin_number=/\\begin\{tiny\}~\\end\{tiny\}\{\\marginpar.+?\}\}\}/ +    @@tex_pattern_margin_number=/\\begin\{tiny\}\\hspace\{0mm\}\\end\{tiny\}\{\\marginpar.+?\}\}\}/      @@tableheader={        'a4' => { :p => 0, :l => 0 },        'a5' => { :p => 0, :l => 0 }, @@ -78,8 +78,24 @@ module SiSU_TeX_Pdf      }      @@sys=SiSU_Env::System_call.new      @@dp=nil -    def initialize(md,string,string1=nil) -      @md,@string,@string1=md,string,string1 +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        @title =t_o[:title]        || nil +        @subtitle =t_o[:subtitle]  || nil +        @ps =t_o[:paper_size]      || nil +        @ocn =t_o[:ocn]            || nil +        @words =t_o[:words]        || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end +        if defined? @md.image \        and @md.image =~/center/          @center_begin,@center_end='\begin{center}','\end{center}' @@ -90,12 +106,11 @@ module SiSU_TeX_Pdf        @tx=SiSU_Env::Get_init.instance.tex        @url_brace=SiSU_Viz::Skin.new.url_decoration        @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine -      @ps=string1 if string1=~/(?:a4|letter|legal|book|a5|b5)/i      end      def longtable_landscape        @end_table='\end{longtable}'        @row_break='\\\\\\' -      if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u]          no_of_cols,cols_width,ocn=$1,$2,$3          tw=case @ps          when /a4/i;      @tx.a4.landscape.w     #European default, SiSU default @@ -106,10 +121,9 @@ module SiSU_TeX_Pdf          else             @tx.a4.landscape.w     #default currently A4          end          textwidth=(tw.to_i/2) - 24 -        @@tableheader[@ps][:l]=1 if @string =~/#{Mx[:gr_o]}Th/ +        @@tableheader[@ps][:l]=1 if @txt =~/#{Mx[:gr_o]}Th/          w=cols_width.split(/;\s*/)          @@number_of_cols=no_of_cols ||=@@number_of_cols -        #@@number_of_cols=0 unless @@number_of_cols.to_i > 0          @colW=[]          @colW << '{'          w.each  do |x| @@ -122,36 +136,35 @@ module SiSU_TeX_Pdf          @colW=@colW.join          @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +            "\\begin{tiny}\n\\begin{longtable}#@colW\n" -        @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table")        end -      if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}")        end -      @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +      @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')        if @@tableheader[@ps][:l] == 1 -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u -          tablefoot=@string[/\<!f(.+?)!\>/,1] -          @string.gsub!(/\<!f(.+?)!\>/,'') -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') -          @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") -          @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u +          tablefoot=@txt[/\<!f(.+?)!\>/,1] +          @txt.gsub!(/\<!f(.+?)!\>/,'') +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') +          @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") +          @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot            @@tableheader[@ps][:l]=0 -          #@@tableheader[@ps][:l],@@number_of_cols=0,0          end        else -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') -          @string.gsub!(/&\s*$/," #@row_break") +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') +          @txt.gsub!(/&\s*$/," #@row_break")          end        end -      @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string -      else @string +      @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt +      else @txt        end      end      def longtable_portrait        @end_table='\end{longtable}'        @row_break='\\\\\\' -      if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u]          no_of_cols,cols_width,ocn=$1,$2,$3          tw=case @ps          when /a4/i;      @tx.a4.portrait.w     #European default, SiSU default @@ -162,15 +175,14 @@ module SiSU_TeX_Pdf          else             @tx.a4.portrait.w     #default currently A4          end          textwidth=tw.to_i - 20 -        @@tableheader[@ps][:p]=1 if @string =~/#{Mx[:gr_o]}Th/ +        @@tableheader[@ps][:p]=1 if @txt =~/#{Mx[:gr_o]}Th/          w=cols_width.split(/;\s*/)          @@number_of_cols=no_of_cols ||=@@number_of_cols          @colW=[]          @colW << '{'          w.each  do |x|            x.strip! -          x=(x.to_i * textwidth)/100 -          #x=(x.to_i/100.0 * 160) +          x=(x.to_i * textwidth)/100 #x=(x.to_i/100.0 * 160)            col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil?            @colW << "p{#{col_w}mm}" if col_w          end @@ -178,30 +190,29 @@ module SiSU_TeX_Pdf          @colW=@colW.join          @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +            "\\begin{tiny}\n\\begin{longtable}#@colW\n" -        @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table)        end -      if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}")        end -      @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +      @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')        if @@tableheader[@ps][:p] == 1 -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u -          tablefoot=@string[/\<!f(.+?)!\>/,1] -          @string.gsub!(/\<!f(.+?)!\>/,'') -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') -          @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") -          @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u +          tablefoot=@txt[/\<!f(.+?)!\>/,1] +          @txt.gsub!(/\<!f(.+?)!\>/,'') +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') +          @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") +          @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot            @@tableheader[@ps][:p]=0 -          #@@tableheader[@ps][:p],@@number_of_cols=0,0          end        else -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') -          @string.gsub!(/&\s*$/," #@row_break") +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') +          @txt.gsub!(/&\s*$/," #@row_break")          end        end -      @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string -      else @string +      @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt +      else @txt        end      end      def scopedtable @@ -210,7 +221,7 @@ module SiSU_TeX_Pdf        @end_table="\\end{tabular}"        @row_break='\\\\\\\\'        @break_page="#@row_break\n#@row_break \n" -      if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u]          no_of_cols,cols_width=$1,$2          @w=cols_width.split(/;\s*/)          @colW=[] @@ -219,28 +230,28 @@ module SiSU_TeX_Pdf            @colW << "p{#{col_w}cm}" if col_w          end          @start_table="\\begin{tabular}{#@colW}\n" -        @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}")        end -      if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table")          @@table_pg_break_counter=1        end -      if @string =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u +      if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u          if @@table_pg_break_counter == 28 # taken from 34 ideal for portrait to 28 which suits landscape -          @string="\n\n#@end_table \n#@break_page#@start_table\n" +          @txt="\n\n#@end_table \n#@break_page#@start_table\n"            @@table_pg_break_counter=1          else -          @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +          @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')            @@table_pg_break_counter+=1 -          tablefoot=@string[/\<!f(.+?)!\>/,1] -          @string.gsub!(/\<!f(.+?)!\>/,'') +          tablefoot=@txt[/\<!f(.+?)!\>/,1] +          @txt.gsub!(/\<!f(.+?)!\>/,'')          end        end -      if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u -        @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") -        @string.gsub!(/&\s*$/,"#@row_break") +      if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u +        @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") +        @txt.gsub!(/&\s*$/,"#@row_break")        end -      @string +      @txt      end      def heading_major(para,lev) #\emph{        title=@md.title @@ -264,90 +275,90 @@ module SiSU_TeX_Pdf  para      end      def level1 -      heading_major(@string,1) +      heading_major(@txt,1)      end      def level2 -      heading_major(@string,2) +      heading_major(@txt,2)      end      def level3 -      heading_major(@string,3) +      heading_major(@txt,3)      end      def level4 -      @string.strip! if @string -      @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') -      cont_ln=@string.dup +      @txt.strip! if @txt +      @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') +      cont_ln=@txt.dup        cont_ln.gsub!(@@tex_pattern_margin_number,'')        cont_ln.gsub!(/#{@@tex_backslash*2}/,"#{@@tex_backslash*4}") # added w42        cont_ln.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'')        cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22        cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22        title=@md.title -      @string.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') -      if @string =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ +      @txt.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') +      if @txt =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/          # watch exclusion removes endnotes marker from pdf 2003w03 -        @string.gsub!(/.+/m,'') +        @txt.gsub!(/.+/m,'')        end -      if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! +      if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings!          cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ')          cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')        end -      if @string !~/#{Mx[:lv_o]}4:/ -        @string.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} +      if @txt !~/#{Mx[:lv_o]}4:/ +        @txt.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1}  \\addcontentsline{toc}{subsection}{#{cont_ln}}  \\markright{#{title}}")        else -        @string.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} +        @txt.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1}  \\addcontentsline{toc}{subsection}{#{cont_ln}}  \\markright{#{title}}")        end -      @string.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1') +      @txt.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1')      end      def level5 -      # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@string*, same for next section 2002w46 -      @string.strip! if @string -      @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') -      cont_ln=@string.dup +      # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 +      @txt.strip! if @txt +      @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') +      cont_ln=@txt.dup        cont_ln.gsub!(@@tex_pattern_margin_number,'')        cont_ln.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'')        cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22        cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22        cont_ln.gsub!(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa -      @string.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') -      if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! +      @txt.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') +      if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings!          cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ')          cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')        end -      if @string !~/#{Mx[:lv_o]}5:/ -        @string.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} +      if @txt !~/#{Mx[:lv_o]}5:/ +        @txt.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1}  \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\  }")        else -        @string.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, +        @txt.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m,            "\\subsubsection*{\\1}  \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\  }")        end -      @string.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1') +      @txt.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1')      end      def level6 -      # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@string*, same for previous section 2002w46 -      @string.strip! if @string -      @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') -      cont_ln=@string.dup +      # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46 +      @txt.strip! if @txt +      @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') +      cont_ln=@txt.dup        cont_ln.gsub!(@@tex_pattern_margin_number,'')        cont_ln.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'')        cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22        cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 -      @string.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') -      if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! +      @txt.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') +      if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings!          cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ')          cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')        end -      @string.gsub!(/(#{@md.lv6}.*)\n?$/m, -        "\\subsubsection*{\\1}") if (@string !~/#{Mx[:lv_o]}6:/) -      @string.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, +      @txt.gsub!(/(#{@md.lv6}.*)\n?$/m, +        "\\subsubsection*{\\1}") if (@txt !~/#{Mx[:lv_o]}6:/) +      @txt.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m,          '\subsubsection*{\1}') -      @string.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') +      @txt.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1')        #end BUGWATCH      end      def indent(lev) @@ -362,25 +373,25 @@ para        when /8/; '70mm'        when /9/; '80mm'        end -      @string.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, +      @txt.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m,          "\\begin{ParagraphIndent}{#{indent}}\\1  \\end{ParagraphIndent}}")      end      def symbol_graphic        dir=SiSU_Env::Info_env.new(@md.fns) -      image='c_' + /<:=\s*(\S+?)\s*>/m.match(@string).captures.join + '.png' #watch +      image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch        if FileTest.file?("#{dir.path.image_source_tex}/#{image}") -        @string.gsub!(/<:=\s*(\S+?)\s*>/, +        @txt.gsub!(/<:=\s*(\S+?)\s*>/,            "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}")        else          tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_tex}")          tell.error2 unless @md.cmd =~/q/ -        @string.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! +        @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile !        end      end      def image        dir=SiSU_Env::Info_env.new(@md.fns) -      image,m=/<:image\s+(\S+)\s+.+?width=``(\d+)''.+?>/m.match(@string).captures +      image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@txt).captures        width=m[1] || '100'        width=width.to_i*0.4        image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ @@ -397,17 +408,17 @@ para          nil        end        if image_source -        @string.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/, +        @txt.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/,            @center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end ) -        @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/, +        @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,            @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) -      else @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/,'\1}') +      else @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}')        end      end      def png #fc missing image check        dir=SiSU_Env::Info_env.new(@md.fns)        # messy clean up -      z=@string[/\\\{(\S.+?)\}(?:image|png)/,1].strip if @string =~ /\\\{\S.+?\}(?:image|png)/ # match operator for z \\ fragile ! +      z=@txt[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @txt =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile !        if z #debug 2004w14          image=z[/(\S+?\.(?:png|jpg|gif)\b)/m]          image.gsub!(/\\/,'') @@ -438,30 +449,29 @@ para          nil        end        if image_source -        @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/, # fragile match operator\\ fragile ! +        @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile !            "#@center_begin\n\\includegraphics*[width=#{width}pt]{#{image_source}/#{image}}#{caption}#@center_end") -      else -        @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,'') # fragile match operator\\ fragile ! +      else @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'')        end      end      def http_word_mode #(orientation='')        # clean up ! - work area, testing        dir=SiSU_Env::Info_env.new(@md.fns) -      @words=[] -      @url_generic_rgx=/\\\{.+?\\?\}(?:https?|file|ftp):\S+/ -      @string.each do |word| -        @words << if word=~@url_generic_rgx -          if word =~/\\\{(?:.+?)\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ -            regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ -            punctuate=/\\\{.+?\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join +      @w=[] +      @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ +      @words.each do |word| +        @w << if word=~@url_generic_rgx +          if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ +            regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ +            punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?([;.,]?(?:\s|$))/.match(word).captures.join            else -            regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ +            regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\S+)/              punctuate=''            end            z,url=regx_url.match(word).captures if word =~regx_url            url=url.strip -          if word =~/\{\s*\S+\.?(?:png|jpg|gif)/ \ -          and word=~/\s+\d+x\d+\s+/ +          if word =~/#{Mx[:lnk_o]}\s*\S+\.?(?:png|jpg|gif)/ \ +          and word=~/\s+\d+x\d+(\s+|\s*#{Mx[:lnk_c]})/              image,x,y=z.scan(/\S+/)              image.gsub!(/\\/,'')              width=if z =~/(\d+)x\d*/ @@ -486,56 +496,57 @@ para                "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}"              else ''              end -          elsif word =~/\{\s*(\S+\.?\.(?:png|jpg|gif))/ +          elsif word =~/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/              tell=SiSU_Screen::Ansi.new(@md.cmd,%{document built without image: "#{$1}" as image dimensions not provided (& librmagick-ruby is not installed)?\n})              tell.print_grey #unless @opt.cmd =~/q/            end            word=if image #most images fc etc. #% clean up !              word=if @md.fns =~/\.(?:ssm\.)?sst$/ \              and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") -              word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ +              word=if word =~ /(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/                  "#@center_begin\\\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_local_tex}/#{image}}}#{caption} #@center_end"                end                word              elsif @md.fns =~/\.-ss[tm]$/ \              and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") -              word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ +              word=if word =~ /(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/                  "#@center_begin\\\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_remote_tex}/#{image}}}#{caption}#@center_end"                end                word              elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}") -              word=if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ +              word=if word =~/(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/                  "#@center_begin\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}#@center_end"                end                word              else                tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_local_tex},#{dir.path.image_source_remote_tex} and #{dir.path.image_source_tex}")                tell.error2 unless @md.cmd =~/q/ -              word='' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/ +              word='' if word =~ /#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/                word              end            else              link=z.strip #[/(.+?)\\/m,1] -            word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/ +            word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/              word            end          else word          end        end -      @words=@words.join -      @words +      @txt=@w.join +      @txt      end      def http -      wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) -      @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm,@ps).http_word_mode #GET PAPER SIZE AND USE IT +      wm=@txt.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) +      txt_obj={:words =>wm,:paper_size =>@ps} +      @txt=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http_word_mode #GET PAPER SIZE AND USE IT      end      def title -      @string=SiSU_TeX_Pdf::Special_characters.new(@md,@string).special_characters_safe -      if @string1 -        @string1=SiSU_TeX_Pdf::Special_characters.new(@md,@string1).special_characters_safe -        @string1.gsub!(/\$/,"\\$") -        "\n\\title{#@string#{@@tex_backslash*2} \\textbf{\\normalsize #@string1}\\normalsize}" -      else "\n\\title{#@string}" +      @txt=SiSU_TeX_Pdf::Special_characters.new(@md,@title).special_characters_safe +      if @subtitle +        @subtitle=SiSU_TeX_Pdf::Special_characters.new(@md,@subtitle).special_characters_safe +        @subtitle.gsub!(/\$/,"\\$") +        "\n\\title{#@title#{@@tex_backslash*2} \\textbf{\\normalsize #@subtitle}\\normalsize}" +      else "\n\\title{#@txt}"        end      end      def title_landscape @@ -548,33 +559,49 @@ para        paranumber_display=if @md.markup.inspect =~/no_ocn/ \        or @md.mod.inspect =~/--no-ocn/          '' -      else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering +      else "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}#@ocn\\end{tiny}}}" #ocn object citation numbering        end -      if @string !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ -        @string.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect +      if @txt !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ +        @txt.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect        else -        if (@string =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect -          @string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect -          #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect -          #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect -          @string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? -          #@string.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? +        if (@txt =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect +          @txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect +          #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect +          #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect +          @txt.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? +          #@txt.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT?          else -          @string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") -          #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") -          #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") +          @txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") +          #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") +          #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n")          end        end -      @string +      @txt      end    end    class Format_head -    def initialize(md,ps,layout=nil,string1=nil) -      @md,@ps,@layout,@string1=md,ps,layout,string1 +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        #@title =t_o[:title]        || nil +        @subtitle =t_o[:subtitle]  || nil +        @ps =t_o[:paper_size]      || nil +        @ocn =t_o[:ocn]            || nil +        @layout=t_o[:orientation]  || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end +        @tx=SiSU_Env::Get_init.instance.tex        @url_brace=SiSU_Viz::Skin.new.url_decoration        @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine -      @ps=@string if @string=~/(?:a4|letter|legal|book|a5|b5)/i +      @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i      end      def language        @lang=if @md.dc_language[:code] @@ -670,7 +697,7 @@ WOK      def tex_head_paper_landscape(d)        <<WOK  #{tex_head_info} -\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang}, landscape, titlepage, twocolumn]{scrartcl}        %with titlepage +\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang},landscape,titlepage,twocolumn]{scrartcl}        %with titlepage  \\setlength{\\textheight}{#{d[:textheight]}mm}  \\setlength{\\textwidth}{#{d[:textwidth]}mm}  \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}}  \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}  \\setlength{\\topmargin}{#{d[:topmargin]}}  \\setlength{\\headheight}{#{d[:headheight]}} @@ -683,7 +710,7 @@ WOK      def tex_head_paper_portrait_dvi(d)        <<WOK  #{tex_head_info} -\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang},titlepage]{scrartcl}        %with titlepage +\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang},titlepage]{scrartcl}      %with titlepage  \\setlength{\\textheight}{#{d[:textheight]}mm}  \\setlength{\\textwidth}{#{d[:textwidth]}mm}  \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}}  \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}  \\setlength{\\topmargin}{#{d[:topmargin]}}  \\setlength{\\headheight}{#{d[:headheight]}} @@ -729,12 +756,12 @@ WOK        when /landscape/          #d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w          d[:papertype],d[:fontsize]='a4paper','11pt' -        d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-8mm','-8mm','-18mm' +        d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='6mm','6mm','-12mm'          d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt'          d[:marginparsep],d[:marginparwidth]='4mm','8mm'          case @ps #@md.papersize          when /a4/i                            #European default, SiSU default -          d[:papertype],d[:fontsize]='a4paper','12pt' +          d[:papertype],d[:fontsize]='a4paper','11pt'            d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w          when /letter/i                    #U.S. default            d[:papertype],d[:fontsize]='letterpaper','11pt' @@ -782,12 +809,11 @@ WOK        end        if @layout =~/portrait|landscape/        <<WOK -\\usepackage{url}  \\usepackage{alltt}  \\usepackage{thumbpdf}  \\usepackage[#{@tex2pdf},    #{color.strip} -  pdftitle={#@string1}, +  pdftitle={#{@txt}},  %  pdftitle={Untitled},    pdfauthor={LM-sisu-scribe},    pdfsubject={law}, @@ -820,10 +846,11 @@ WOK  \\definecolor{mygreen}{rgb}{0,0.5,0}  \\definecolor{myblue}{rgb}{0,0,0.5}  \\definecolor{mywhite}{rgb}{1,1,1} +\\usepackage{url} +%\\usepackage{breakurl}  WOK -      elsif @string =~/dvi/ +      elsif @txt =~/dvi/        <<WOK -\\usepackage{url}  \\usepackage{alltt}    #{color.strip}    pageanchor=true, @@ -840,6 +867,8 @@ WOK  \\definecolor{mygreen}{rgb}{0,0.5,0}  \\definecolor{myblue}{rgb}{0,0,0.5}  \\definecolor{mywhite}{rgb}{1,1,1} +\\usepackage{url} +%\\usepackage{breakurl}  WOK        end      end @@ -853,13 +882,13 @@ WOK  \\usepackage{graphicx}  \\makeatletter  \\parindent0pt -\\usepackage{mathptmx} +%\\usepackage{mathptmx}  \\usepackage{amssymb}  % amssymb used for backslash  WOK      end      def document_head_with_orientation -      endnotes=("\\usepackage{endnotes}" if @string =~/endnotes?/)||'' #not implemented see also def endnotes +      endnotes=("\\usepackage{endnotes}" if @txt =~/endnotes?/)||'' #not implemented see also def endnotes        language        <<WOK  #{tex_head_paper} @@ -870,8 +899,8 @@ WOK  \\setcounter{tocdepth}{4}  \\makeatletter  #{endnotes} -\\usepackage[multiple,marginal]{footmisc} -% \\setlength\\footnotemargin{40pt} +\\usepackage[multiple,ragged]{footmisc} +\\setlength\\footnotemargin{12pt}  \\usepackage[para]{manyfoot}  \\DeclareNewFootnote{A}  %\\DeclareNewFootnote[para]{A} @@ -922,7 +951,7 @@ WOK      @@flag_code=false      @@tex_backslash="\\\\"      def initialize(md,string) -      @md,@string=md,string +      @md,@txt=md,string        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        #@tx=SiSU_Env::Get_init.instance.tex        @url_brace=SiSU_Viz::Skin.new.url_decoration @@ -930,7 +959,7 @@ WOK      end      def pdftex_special_characters_1(string)             # ~ ^ $ & % _ { }  #LaTeX special characters - KEEP list        #p @@utf_8.list -      #@string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) +      #@txt=Iconv.conv('ISO-8859-1', 'UTF-8', @txt)        word=string.scan(/#{Mx[:mk_o]}\S+?#{Mx[:mk_c]}|\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/        para_array=[]        string=if word @@ -958,7 +987,7 @@ WOK        string.gsub!(/.+?<-#>/,'')        string.gsub!(/#{Mx[:br_eof]}|#{Mx[:br_endnotes]}/,'')        #problem sequence -> -      string.gsub!(/&(?:nbsp);/,'<=hardspace>')                                 # < SiSU special character also LaTeX +      string.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'<=hardspace>')                                 # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#nbsp#{Mx[:gl_c]}/,'<=hardspace>')                                 # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<=lt>')                                     # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'<=gt>')                                     # > SiSU special character also LaTeX @@ -972,7 +1001,7 @@ WOK        string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-')                                                # - SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+')                                                # + SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',')                                                # + SiSU special character also LaTeX -      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/                   # / SiSU special character also LaTeX +      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/                   # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>')                                         # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>')                                     # \ SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>')                                    # _ SiSU special character also LaTeX @@ -993,12 +1022,12 @@ WOK        string.gsub!(/\#/,'\#')        string.gsub!(/\%/,'\%')        string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes -      if string !~/^\s*<:image|\}:image\s/ +      if string !~/^\s*#{Mx[:lnk_o]}|#{Mx[:lnk_c]}image\s/          string.gsub!(/_/,'\_')        end        string.gsub!(/\{/,'\{')        #string.gsub!(/\}/,'\}') -      string.gsub!(/ /,'~') # ~ character for hardspace +      string.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace        # sequence important must appear after removal of { and }        string.gsub!(/&\S+?;/,'') #hmmm        # sequence imortant place before removal of & @@ -1013,11 +1042,15 @@ WOK        string.gsub!(/&\S+?;/,' ')        string.gsub!(/<a href=".+?">/,' ')        string.gsub!(/<\/a>/,' ') -      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case -      string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url -      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration +      string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, +        '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url +      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, +        ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case +      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, +        '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration        unless @@flag_code -        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start +        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, +          "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start        else #code-block: angle brackets special characters, note _ already escaped          string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}')          string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') @@ -1025,7 +1058,8 @@ WOK        string.gsub!(/<:ee>/,'')        string.gsub!(/<!>/,' ')        #proposed change, insert, but may be redundant -      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder +      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/, +        ' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder        string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area        string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}')        #string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') @@ -1049,7 +1083,8 @@ WOK          string.gsub!(/\s+'/,' `')                                # open '          string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`')  # open '        end -      string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ +      string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/, +        '\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_        string.gsub!(/(<font.*?>|<\/font>)/,'')        string.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1')        #string.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_paragraph]}|\n)\*/,' \\\\ ') @@ -1065,16 +1100,22 @@ WOK        #string.gsub!(/<=lt>/,'\<')        #string.gsub!(/<=gt>/,'\>')        string.gsub!(/<=underscore>/,'\_') -      string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text -      string.gsub!(/<=tilde>/,'{\~~}') +      while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') +      end +      string.gsub!(/<=tilde>/,'{$\sim$}')        string.gsub!(/<=pipe>/,'{\textbar}')        string.gsub!(/<=caret>/,'{\^{~}}')        #string.gsub!(/<=caret>/,'\^{}')        string.gsub!(/<=exclaim>/,'\Verbatim{!}') +      string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text        string.gsub!(/<=hash>/,'{\#}')        #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')        #string.gsub!(/<=slash>/,'{\slash}')        string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 +      while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') +      end        string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005        #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')        string.gsub!(/<=slash>/,'{/}') @@ -1084,12 +1125,13 @@ WOK        #string.gsub!(/<=asterisk>/,'{\ast}')        #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic        #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' -      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic +      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/, +        '^\copyright \textnormal{\1} \2') # watch likely to be problematic        string      end      def xetex_special_characters_1(string)             # ~ ^ $ & % _ { }  #LaTeX special characters - KEEP list        #p @@utf_8.list -      #string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) +      #string=Iconv.conv('ISO-8859-1', 'UTF-8', @txt)        word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/        para_array=[]        string=if word @@ -1119,7 +1161,7 @@ WOK        string.gsub!(/#{Mx[:br_endnotes]}/,'')        #string.gsub!(/<ENDNOTES?>/,'')        #problem sequence -> -      string.gsub!(/&(?:nbsp);/,'<=hardspace>')                                 # < SiSU special character also LaTeX +      string.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'<=hardspace>')                                 # < SiSU special character also LaTeX        string.gsub!(/&(?:lt|#060);/,'<=lt>')                                     # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'<=gt>')                                     # > SiSU special character also LaTeX        #string.gsub!(/#{Mx[:gl_o]}(&#(?:[a-z]+|[0-9]+);)#{Mx[:gl_c]}/,'\1') @@ -1132,7 +1174,7 @@ WOK        string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-')                                                # - SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+')                                                # + SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',')                                                # + SiSU special character also LaTeX -      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/                   # / SiSU special character also LaTeX +      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/                   # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>')                                         # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>')                                     # \ SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>')                                    # _ SiSU special character also LaTeX @@ -1153,12 +1195,12 @@ WOK        string.gsub!(/\#/,'\#')        string.gsub!(/\%/,'\%')        string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes -      if string !~/^\s*<:image|\}:image\s/ +      if string !~/^\s*#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\s/          string.gsub!(/_/,'\_')        end        string.gsub!(/\{/,'\{')        string.gsub!(/\}/,'\}') -      string.gsub!(/ /,'~') # ~ character for hardspace +      string.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace        # sequence important must appear after removal of { and }        string.gsub!(/&\S+?;/,'') #hmmm        # sequence imortant place before removal of & @@ -1166,18 +1208,23 @@ WOK        elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false        end        if @@flag_code; string.gsub!(/&/,'{\\\&}') -      else string.gsub!(/(\s+&\s+)/,' and ') +      else string.gsub!(/&/,'<=amp>') +      #else string.gsub!(/(\s+&\s+)/,' and ')        end        string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ')        string.gsub!(/£/u,'\pounds')        string.gsub!(/&\S+?;/,' ')        string.gsub!(/<a href=".+?">/,' ')        string.gsub!(/<\/a>/,' ') -      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case -      string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url -      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration +      string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, +        '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url +      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, +        ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case +      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, +        '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration        unless @@flag_code -        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start +        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, +          "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start        else #code-block: angle brackets special characters, note _ already escaped          string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}')          string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') @@ -1185,7 +1232,8 @@ WOK        string.gsub!(/<:ee>/,'')        string.gsub!(/<!>/,' ')        #proposed change, insert, but may be redundant -      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder +      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/, +        ' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder        string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area        string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}')        #string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') @@ -1230,16 +1278,22 @@ WOK        #string.gsub!(/<=lt>/,'\<')        #string.gsub!(/<=gt>/,'\>')        string.gsub!(/<=underscore>/,'\_') -      string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text -      string.gsub!(/<=tilde>/,'{\~~}') +      while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') +      end +      string.gsub!(/<=tilde>/,'{$\sim$}')        string.gsub!(/<=pipe>/,'{\textbar}')        string.gsub!(/<=caret>/,'{\^{~}}')        #string.gsub!(/<=caret>/,'\^{}')        string.gsub!(/<=exclaim>/,'\Verbatim{!}') +      string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text        string.gsub!(/<=hash>/,'{\#}')        #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')        #string.gsub!(/<=slash>/,'{\slash}')        string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 +      while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') +      end        string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005        #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')        string.gsub!(/<=slash>/,'{/}') @@ -1249,7 +1303,8 @@ WOK        #string.gsub!(/<=asterisk>/,'{\ast}')        #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic        #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' -      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic +      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/, +        '^\copyright \textnormal{\1} \2') # watch likely to be problematic        string      end      def special_characters_curly(string) @@ -1263,33 +1318,33 @@ WOK        string      end      def special_characters                                                       #special characters - some substitutions are sequence sensitive, rearrange with care. -      string=@string +      string=@txt        case @tex2pdf        when /pdf/          string=pdftex_special_characters_1(string) unless string.nil? -        string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@string) +        string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@txt)          string=pdftex_special_characters_2(string) unless string.nil?          string=pdftex_special_characters_3(string) unless string.nil?        when /xe/          string=xetex_special_characters_1(string) unless string.nil? -        string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@string) +        string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@txt)          string=xetex_special_characters_2(string) unless string.nil? #issues with xetex          string=xetex_special_characters_3(string) unless string.nil?        end -      @string=string +      @txt=string      end      def special_characters_safe                                                  #special characters - some substitutions are sequence sensitive, rearrange with care. -      string=@string +      string=@txt        case @tex2pdf        when /pdf/ -        string=pdftex_special_characters_1(@string) unless string.nil? -        string=pdftex_special_characters_2(@string) unless string.nil? -        #special_characters_3(@string) +        string=pdftex_special_characters_1(@txt) unless string.nil? +        string=pdftex_special_characters_2(@txt) unless string.nil? +        #special_characters_3(@txt)        when /xe/ -        string=xetex_special_characters_1(@string) unless string.nil? -        string=xetex_special_characters_2(@string) unless string.nil? # remove this to start with, causes issues +        string=xetex_special_characters_1(@txt) unless string.nil? +        string=xetex_special_characters_2(@txt) unless string.nil? # remove this to start with, causes issues        end -      @string=string +      @txt=string      end    end    class Use_TeX diff --git a/lib/sisu/v0/wikispeak.rb b/lib/sisu/v0/wikispeak.rb index 967387d9..d9cb3cbd 100644 --- a/lib/sisu/v0/wikispeak.rb +++ b/lib/sisu/v0/wikispeak.rb @@ -105,7 +105,7 @@ module SiSU_Wikispeak        attr_reader :format,:lev,:text,:ocn,:lev_para_ocn        def initialize(para)          @para=para -        @format,@ocn='null','null' +        @format,@ocn='ordinary','ordinary'          @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        end        def lev_segname_para_ocn @@ -253,16 +253,16 @@ WOK            para.gsub!(/<i>(.+?)<\/i>/,"''\\1''")            para.gsub!(/<b>(.+?)<\/b>/,"'''\\1'''")            para.gsub!(/<u>(.+?)<\/u>/,'_\1_') -          para.gsub!(/\{(.+?)\}(https?:\/\/\S+)/,'[\2 \1]') +          para.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(https?:\/\/\S+)/,'[\2 \1]')            para.gsub!(/(https?:\/\/\S+)/,'[\1]')            para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})?/,'')            para.gsub!(/<:p[bn]>/,'')                                         # remove page breaks            para.gsub!(/^\s*#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') # remove empty lines - check            para.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1')            para.gsub!(/<:name#\S+?>/,'')                                       # remove name links -          para.gsub!(/ /,' ')                                            # decide on -          para.gsub!(/(?:^|[^_\\])\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") -          para.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') +          para.gsub!(/ |#{Mx[:nbsp]}/,' ')                               # decide on +          para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") +          para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]')            #para.gsub!(/^\{\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')            wordlist=para.scan(/\S+/)            if para =~/^0~(\S+)\s+(.+?)\Z/m # for headers diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 067ed8a8..5f99cacf 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -267,8 +267,8 @@ WOK          (0..6).each { |x| @cont[x]=@level[x]=false }          (4..6).each { |x| @xml_contents_close[x]='' }          data.each do |para| -          para=@trans.markup(para)            @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 +          para=@trans.markup(para)            if para =~/^#{Rx[:meta]}\s*.+?$/ # for headers              d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta              if d_meta; xml_head(d_meta) @@ -289,7 +289,8 @@ WOK              unless @rcdc                m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/                if para =~m -                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ +                txt_obj={:txt =>@sto.text} +                format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/                  case @sto.format                  when /^(1):(\S*)/                    xml_structure(para,$1,@sto.ocn,$2) @@ -342,26 +343,29 @@ WOK                and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/                elsif para =~/(MetaData)/ \                and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info -                format_scroll=Format_scroll.new(@md,'<br /><a name="metadata">MetaData</a>') +                txt_obj={:txt =>'<br /><a name="metadata">MetaData</a>'} +                format_scroll=Format_scroll.new(@md,txt_obj)                  para=format_scroll.bold_para                elsif para =~/(Owner Details)/ \                and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -                format_scroll=Format_scroll.new(@md,'<br /><a name="owner.details">Owner Details</a>') +                txt_obj={:txt =>'<br /><a name="owner.details">Owner Details</a>'} +                format_scroll=Format_scroll.new(@md,txt_obj)                  @@xml[:owner_details]=format_scroll.bold_para                  para='' -              elsif para =~/(.*)<:#>(.*)/ -                one,two=$1,$2 -                format_text=Format_text_object.new(one,two) -                para=format_text.seg_no_paranum -              end -              if para =~/<a name="n\d+">/ \ -              and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote -                para='' +              #elsif para =~/(.*)<:#>(.*)/ +              #  one,two=$1,$2 +              #  format_text=Format_text_object.new(one,two) +              #  para=format_text.seg_no_paranum                end +              #if para =~/<a name="n\d+">/ \ +              #and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote +              #  para='' +              #end                para=case para                when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/                  if para =~/.*<:#>.*$/ -                  format_text=Format_text_object.new(para,'') +                  txt_obj={:txt =>para} +                  format_text=Format_text_object.new(@md,txt_obj)                    format_text.scr_inden_ocn_e_no_paranum                  end                else para @@ -369,11 +373,6 @@ WOK                if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/                  # i don't get the condition for no paranum                end -              if para =~/<:center>/ -                one,two=/(.*)<:center>(.*)/.match(para)[1,2] -                format_text=Format_text_object.new(one,two) -                para=format_text.center -              end              else #              end              para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 9f897266..49c71b88 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -291,8 +291,8 @@ WOK          (0..6).each { |x| @cont[x]=@level[x]=false }          (4..6).each { |x| @xml_contents_close[x]='' }          data.each do |para| -          para=@trans.markup(para)            @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 +          para=@trans.markup(para)            if para =~/^#{Rx[:meta]}\s*.+?$/ # for headers              d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta              if d_meta; xml_head(d_meta) @@ -313,7 +313,8 @@ WOK              unless @rcdc                m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/                if para =~m -                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ +                txt_obj={:txt =>@sto.text} +                format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/                  case @sto.format                  when /^(1):(\S*)/                    xml_structure(para,$1,@sto.ocn,$2) @@ -362,17 +363,20 @@ WOK                and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/                elsif para =~/(MetaData)/ \                and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info -                format_scroll=Format_scroll.new(@md,'<br /><a name="metadata">MetaData</a>') +                txt_obj={:txt =>'<br /><a name="metadata">MetaData</a>'} +                format_scroll=Format_scroll.new(@md,txt_obj)                  para=format_scroll.bold_para                elsif para =~/(Owner Details)/ \                and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -                format_scroll=Format_scroll.new(@md,'<br /><a name="owner.details">Owner Details</a>') +                txt_obj={:txt =>'<br /><a name="owner.details">Owner Details</a>'} +                format_scroll=Format_scroll.new(@md,txt_obj)                  @@xml[:owner_details]=format_scroll.bold_para                  para='' -              elsif para =~/(.*)<!#!>(.*)/ -                one,two=$1,$2 -                format_text=Format_text_object.new(one,two) -                para=format_text.seg_no_paranum +              #elsif para =~/(.*)<!#!>(.*)/ +              #  one,two=$1,$2 +              #  #txt_obj={:txt =>@sto.txt} +              #  format_text=Format_text_object.new(one,two) +              #  para=format_text.seg_no_paranum                end                if para =~/<a name="n\d+">/ \                and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote @@ -380,18 +384,11 @@ WOK                end                if para =~/.*<:#>.*$/ #investigate removal                  para=if para =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ -                  format_text=Format_text_object.new(para,'') +                  txt_obj={:txt =>para} +                  format_text=Format_text_object.new(@md,txt_obj)                    format_text.scr_inden_ocn_e_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 -              if para =~/<:center>/ -                one,two=/(.*)<:center>(.*)/.match(para)[1,2] -                format_text=Format_text_object.new(one,two) -                para=format_text.center -              end              else #              end              para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index 9bcb15ec..13aed504 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -349,8 +349,8 @@ WOK          (0..6).each { |x| @cont[x]=@level[x]=false }          (4..6).each { |x| @xml_contents_close[x]='' }          data.each do |para| -          para=@trans.markup(para)            @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 +          para=@trans.markup(para)            if para =~/^#{Rx[:meta]}\s*(.+?)$/ # for headers              d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta              if d_meta; xml_head(d_meta) @@ -371,7 +371,8 @@ WOK              unless @rcdc                m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/                if para =~m -                format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|null/ +                txt_obj={:txt =>@sto.text} +                format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/                  case @sto.format                  when /^(1):(\S*)/                    xml_markup(para) @@ -438,17 +439,19 @@ WOK                  #para=format_scroll.boldPara                elsif para =~/(MetaData)/ \                and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info -                format_scroll=Format_scroll.new(@md,'<br /><a name="metadata">MetaData</a>') +                txt_obj={:txt =>'<br /><a name="metadata">MetaData</a>'} +                format_scroll=Format_scroll.new(@md,txt_obj)                  para=format_scroll.bold_para                elsif para =~/(Owner Details)/ \                and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ -                format_scroll=Format_scroll.new(@md,'<br /><a name="owner.details">Owner Details</a>') +                txt_obj={:txt =>'<br /><a name="owner.details">Owner Details</a>'} +                format_scroll=Format_scroll.new(@md,txt_obj)                  @@xml[:owner_details]=format_scroll.bold_para                  para='' -              elsif para =~/(.*)<:#>(.*)/ -                one,two=$1,$2 -                format_text=Format_text_object.new(one,two) -                para=format_text.seg_no_paranum +              #elsif para =~/(.*)<:#>(.*)/ +              #  one,two=$1,$2 +              #  format_text=Format_text_object.new(one,two) +              #  para=format_text.seg_no_paranum                end                if para =~/<a name="n\d+">/ \                and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote @@ -456,18 +459,14 @@ WOK                end                if para =~/.*<:#>.*$/                  para=if para =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ -                  format_text=Format_text_object.new(para,'') +                  txt_obj={:txt =>para} +                  format_text=Format_text_object.new(@md,txt_obj)                    format_text.scr_inden_ocn_e_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 -              if para =~/<:center>/ -                one,two=/(.*)<:center>(.*)/.match(para)[1,2] -                format_text=Format_text_object.new(one,two) -                para=format_text.center -              end              else #              end              para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml_format.rb b/lib/sisu/v0/xml_format.rb index 20eb6736..a801f9d2 100644 --- a/lib/sisu/v0/xml_format.rb +++ b/lib/sisu/v0/xml_format.rb @@ -282,64 +282,74 @@ WOK    end    class Format_text_object      @@dp=nil -    attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped -    def initialize(md,*txt) -      @md=md -      txt[0].gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ -      @one,@two,@three=txt[0],txt[1],txt[2] -      @format,@parablock=txt[0],txt[1] -      if txt[2]=~/\d+/ -        @paranum=/(\d+)/m.match(txt[2])[1] +    attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        @format =t_o[:format]      || nil +        @lnk_url =t_o[:lnk_url]    || nil +        @lnk_txt =t_o[:lnk_txt]    || nil +        @ocn =t_o[:ocn]            || nil +        #@h_name =t_o[:h_name]      || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end +      if @t_o[:ocn]=~/\d+/ +        @paranum=/(\d+)/m.match(@t_o[:ocn])[1]          @headname=''          #if txt[2]=~/\d+/ -        m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(format) +        m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(@format)          headname=m[1] if m          @headname=%{<a name="h#{headname}"></a>} unless headname.nil?          @p_num=SiSU_XML_format::Paragraph_number.new(@md,@paranum)        end -      #{        rgx=/^[1-6-]~{1,2}/ #watch -      link=txt[0].gsub(rgx,'') if @one =~rgx +      @lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        rgx=/~\{\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}\}~/ -      link=txt[0].gsub(rgx,'\1') if txt[0] =~rgx -      @link,@linkname=link,txt[1] +      @lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx        @vz=SiSU_Env::Get_init.instance.skin      end      def scr_endnote_body -      "<endnote>#@one</endnote> " +      "<endnote>#{@txt}</endnote> "      end    end    class Format_scroll < Format_text_object -    def initialize(*txt) -      super(*txt) +    def initialize(md,t_o) +      super(md,t_o)      end      def heading_body -      %{<p class="norm">#{@p_num.name}#@headname#@parablock </p>} + +      %{<p class="norm">#{@p_num.name}#{@headname}#{@txt} </p>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end      def heading_body1 -      %{<h1 class="norm">#{@p_num.name}#@headname#@parablock </h1>} + +      %{<h1 class="norm">#{@p_num.name}#{@headname}#{@txt} </h1>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end      def heading_body2 -      %{<h2 class="norm">#{@p_num.name}#@headname#@parablock </h2>} + +      %{<h2 class="norm">#{@p_num.name}#{@headname}#{@txt} </h2>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end      def heading_body3 -      %{<h3 class="norm">#{@p_num.name}#@headname#@parablock </h3>} + +      %{<h3 class="norm">#{@p_num.name}#{@headname}#{@txt} </h3>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end      def heading_body4 -      %{<h4 class="norm">#{@p_num.name}#@headname#@parablock</h4>} + +      %{<h4 class="norm">#{@p_num.name}#{@headname}#{@txt}</h4>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end      def heading_body5 -      %{<h5 class="norm">#{@p_num.name}#@headname#@parablock </h5>} + +      %{<h5 class="norm">#{@p_num.name}#{@headname}#{@txt} </h5>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end      def heading_body6 -      %{<h6 class="norm">#{@p_num.name}#@headname#@parablock </h6>} + +      %{<h6 class="norm">#{@p_num.name}#{@headname}#{@txt} </h6>} +        %{<p class="paranum">#{@p_num.display} </p>\n}      end    end @@ -347,4 +357,3 @@ WOK    end  end  __END__ - | 
