diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v0/dal.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v0/html_format.rb | 15 | ||||
-rw-r--r-- | lib/sisu/v0/html_segments.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v0/html_tune.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v0/param.rb | 8 | ||||
-rw-r--r-- | lib/sisu/v0/shared_html_lite.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v0/shared_xml.rb | 26 | ||||
-rw-r--r-- | lib/sisu/v0/texpdf_format.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v0/xhtml.rb | 19 | ||||
-rw-r--r-- | lib/sisu/v0/xml.rb | 21 |
10 files changed, 33 insertions, 92 deletions
diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 0af589f2..15d1c55c 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -376,7 +376,7 @@ module SiSU_DAL para.gsub!(/^@(\S+?):([+-])\s+/,'0~\1\2 ') end if para !~/^%+\s/ and - para =~/^(?:_\*\s+)?\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]+))\]\}(?:\.\.\/\S+?\/|\S+?\.(?:sst|ssm)\b)(?:\s+~\{.+?\}~)?(?:\s+\*~\S+)*\s*$/ + para =~/^(?:_\*\s+)?\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.(?:sst|ssm)\b)(?:\s+~\{.+?\}~)?(?:\s+\*~\S+)*\s*$/ txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil url_and_stub=SiSU_Env::Info_env.new.url if defined? url_and_stub.remote diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index 5a28c271..e1109a6a 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -63,16 +63,21 @@ module SiSU_HTML_Format @md=md @paranum=paranum[/(\d+)/m,1] @paranum ||='' - @paranum='' if @md.mod.inspect =~/--no-ocn/ end def ocn_display - ocn_class=if @md.mod.inspect =~/--no-ocn/; 'ocn_off' - else 'ocn' - end - @paranum.gsub(/^(\d+|)$/, + if @md.markup.inspect =~/no_ocn/ or @md.mod.inspect =~/--no-ocn/ + ocn_class='ocn_off' + @paranum.gsub(/^(\d+|)$/, + %{ <p class="#{ocn_class}"> + + </p>}) + else + ocn_class='ocn' + @paranum.gsub(/^(\d+|)$/, %{ <p class="#{ocn_class}"> \\1 </p>}) + end end def name %{<a name="#@paranum" />} diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index fe2966df..18ed11ec 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -178,10 +178,10 @@ module SiSU_HTML_seg markup(pg) end end - Seg.new(para,@md).txt + #Seg.new(para,@md).txt if testforartnum[tracking-1] =~/endnote/ if printed_endnote_seg == 'n' - Seg.new(para,@md).endnote + #Seg.new(para,@md).endnote printed_endnote_seg='y' end end @@ -344,15 +344,11 @@ module SiSU_HTML_seg end end end - def txt - end - def endnote - 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| + @@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| end @@seg[:tail] << '<table summary="whitespace"><tr><td> </td></tr></table>' ads=SiSU_HTML_promo::Ad.new(@md) diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 0b861526..b98f19d8 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -278,7 +278,7 @@ module SiSU_Tune end word end - @words + @words=@words.join(' ') end def url_markup data=@data @@ -306,9 +306,8 @@ module SiSU_Tune end if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ @word_mode=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|\S+/) - word_mode=urls(@word_mode) - words=word_mode.join(' ') - para.gsub!(/.+/,words) + words=urls(@word_mode) + para.gsub!(/.+/m,words) end if (para !~/^0~|^<:code>/) para.gsub!(/\\copyright/i,%{<sup>©</sup>}) diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index e3b42933..8a652fa0 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -367,7 +367,7 @@ module SiSU_Param 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 - tags=para.match(/^(?:0~tags?|@tags?:)\s+(.+)$/m)[1] + tags=para.match(/^(?:0~tags?|@tags?:)\s+(.+)\Z/m)[1] tags.split(/,|$/).each do |tag| tag.strip! @tags << tag @@ -387,7 +387,7 @@ module SiSU_Param 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+(.+?)$/m #% 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 @@ -405,7 +405,7 @@ module SiSU_Param lv6=@toc[5] ||='6~ ' @lv6=/^#{lv6}\b/ when /^(?:0~(?:level|page|markup)|@(?:level|page|markup):)\s+(.+?)$/m #% processing revisit..., use syntax 0~level new=1,2,3; break=4 - if para =~/(?:0~|@)(?:markup|level|page):?\s+(.+?)$/m + if para =~/(?:0~|@)(?:markup|level|page):?\s+(.+?)\Z/m page_break_str=$1 pagebreaks=page_break_str.split(/;\s*/) #pagebreaks=[ pagebreaks ] if pagebreaks == String @@ -459,7 +459,7 @@ module SiSU_Param @vocabulary=$1 #not actually used by concordance when /^(?:0~skin|@skin:)\s+(.+?)$/; @doc_skin=$1.strip #% processing when /^(?:0~(?:css|stylesheet)|@(?:css|stylesheet):)\s+(.+?)$/; @doc_css=$1.strip #% processing - when /^(?:0~links|@links:)\s+(.+?)$/m #% processing + when /^(?:0~links|@links:)\s+(.+?)\Z/m #% processing doc_links_str=$1 @lnk=[] if doc_links_str=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index f258f0a9..85368a28 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -93,7 +93,7 @@ module SiSU_Format_Shared else m,u=/\{(.+?)\}((?:https?|file|ftp)\S+|image)/.match(word).captures d='' end - case m + word=case m when /\.png|\.jpg|\.gif|c=|\d+x\d+/ w,h=/(\d+)x(\d+)/.match(m).captures if m =~/\d+x\d+/ w=%{width="#{w}"} if w @@ -117,20 +117,18 @@ module SiSU_Format_Shared #ins=%{#{link} <a href="#{u}">[link]</a>#{d}} word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) end - word else word end word end - @words + @words=@words.join(' ') end def markup(para) if para !~/^<:code>/ if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ wm=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|\S+/) - word_mode=urls(wm) - words=word_mode.join(' ') - para.gsub!(/.+/,words) + words=urls(wm) + para.gsub!(/.+/m,words) 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 diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 135f368e..4b9ccb12 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -355,22 +355,18 @@ module SiSU_XML_munge para.gsub!(/<0;\w\d+;[um]\d+><#@dp:#@dp>/,'') if para !~/^<:code>/ #embeds a red-bullet image --> - #para.gsub!(/^(<:i[1-9]>\s*_\*)\s+/,'\1 <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_09.png" width="12" height="12" alt="*" /> ') - #para.gsub!(/^_\*\s+/,'<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="/usr/share/sisu/image/bullet_09.png" width="12" height="12" alt="*" /> ') para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\2" width="\\3" height="\\4" />[\\2] \\5}) para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\2"/>\\2}) para.gsub!(/(^|\s)\{([^}]+)\}(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!(/\B\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/, - # '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\1</link>\3') #watch, compare html_tune para.gsub!(/(^|\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|$))/, #also works - #%{#{@url_brace.xml_open}<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\\1">\\1</link>#{@url_brace.xml_close}\\2}) 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!(/(^|\s)[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\2</link>\3') #escaped urls not linked, deal with later - para.gsub!(/ /,' ') #clean - else para.gsub!(/_</m,'<'); para.gsub!(/_>/m,'>') #code-block: angle brackets special characters + para.gsub!(/ /,' ') + #para.gsub!(/ /,' ') #clean + else + para.gsub!(/_</m,'<'); para.gsub!(/_>/m,'>') #code-block: angle brackets special characters + para.gsub!(/ /,' ') end para end @@ -386,7 +382,8 @@ module SiSU_XML_munge 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)/, "<image.path>#{@dir.url.images_local}\/\\1</image.path>") - para.gsub!(/ /,' ') + para.gsub!(/ /,' ') + #para.gsub!(/ /,' ') #clean wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 para=tidywords(wordlist).join(' ').strip para @@ -412,15 +409,6 @@ module SiSU_XML_tags #Format if @md.dc_title # DublinCore 1 - title @rdf_title=%{ dc.title="#{seg_name}#{@md.dc_title}"\n} @dc_title=%{ <meta name="dc.title" content="#{seg_name}#{@md.dc_title}" />\n} - #if @md.subtitle - # @rdf_title=%{ dc.title="#{seg_name}#{@md.title} - #{@md.subtitle}"\n} - # @title=%{<meta name="dc.title" } + - # %{content="#{seg_name}#{@md.title} - #{@md.subtitle}" />\n} - #else - # @rdf_title=%{ dc.title="#{seg_name}#{@md.title}"\n} - # @title=%{<meta name="dc.title" } + - # %{content="#{seg_name}#{@md.title}" />\n} - #end end if @md.dc_creator # DublinCore 2 - creator/author (author) @rdf_creator=%{ dc.creator="#{@md.dc_creator}"\n} diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 55f1e19a..51681ce7 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -798,9 +798,6 @@ WOK if word =~/\\\{(.+?)\\\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/ r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ d=/\\\{.+?\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.to_s -# if word =~/\\\{(.+?)\\\}((?:https?|file|ftp)\S+?)([;.,]?(?:\s|$))/ -# r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ -# d=/\\\{.+?\\?\}(?:https?|file|ftp):\S+?([;.,]?(?:\s|$))/.match(word).captures.to_s else r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ d='' @@ -820,8 +817,6 @@ WOK when /a5/; @tx.a5 else @tx.a4 end - ##dm=SiSU_Env::Get_init.instance.tex(@md.papersize).dimensions #test! - #dm=SiSU_Viz::TeX.new(@md.papersize).dimensions width=if orientation =~/portrait/ #value is not currently passed width=if width.to_i > dm.portrait.img_px; dm.portrait.img_px else width @@ -875,7 +870,7 @@ WOK @words.join end def http(orientation) - wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) #first match of interest others passed through + wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm).http_word_mode(orientation) end def language diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 1d7d63d1..6b91f34f 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -190,25 +190,6 @@ WOK else '' end end - def xml_structure_ee(para='',lv='',ocn='',hname='') #embedded endnotes - lv=lv.to_i - n=lv - 1 - n3=lv + 2 - lv=nil if lv == 0 - embedded_endnotes(para) - if para[@regx] - paragraph="#{para[@regx,2]}" - util=SiSU_text_utils::Wrap.new(paragraph,70) - wrapped=util.line_wrap - end - @@xml[:body] << "#{@tab*0}<object>" << "\n" if para[@regx] - @@xml[:body] << "#{@tab*1}<ocn>#{para[@regx,3]}</ocn>" << "\n" if para[@regx,3] - @@xml[:body] << if lv; %{#{@tab*1}<text class="h#{lv}">#{wrapped}</text>\n} << "\n" - else %{#{@tab*1}<text class="norm">#{wrapped}</text>\n} # main text, contents, body KEEP - end - ##@@xml[:body] << "#{@tab*1}<text>#{para[@regx,2]}</text>\n" if para[@regx,2] # old unwrapped main text, contents, body KEEP - @@xml[:body] << "#{@tab*0}</object>" << "\n" if para[@regx] - end def xml_structure(para='',lv='',ocn='',hname='',type='norm') #extracted endnotes lv=lv.to_i n=lv - 1 diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 2dd25491..b230ec9f 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -214,26 +214,6 @@ WOK end @@xml[:sc]=sc end - def xml_structure_ee(para='',lv='',ocn='',hname='') #embedded endnotes - lv=lv.to_i - n=lv - 1 - n3=lv + 2 - lv=nil if lv == 0 - embedded_endnotes(para) - if para[@regx] - paragraph="#{para[@regx,2]}" - util=SiSU_text_utils::Wrap.new(paragraph,70) - wrapped=util.line_wrap - end - @@xml[:body] << "#{@tab*0}<object>" << "\n" if para[@regx] - @@xml[:body] << "#{@tab*1}<ocn>#{para[@regx,3]}</ocn>" << "\n" if para[@regx,3] - @@xml[:body] << if lv; %{#{@tab*1}<text class="h#{lv}">#{wrapped}</text>\n} << "\n" - else %{#{@tab*1}<text class="norm">#{wrapped}</text>\n} # main text, contents, body KEEP - end - #@@xml[:body] << "#{@tab*1}<text>#{wrapped}</text>\n" # main text, contents, body KEEP - ##@@xml[:body] << "#{@tab*1}<text>#{para[@regx,2]}</text>\n" if para[@regx,2] # old unwrapped main text, contents, body KEEP - @@xml[:body] << "#{@tab*0}</object>" << "\n" if para[@regx] - end def xml_structure(para='',lv='',ocn='',hname='',type='norm') #extracted endnotes lv=lv.to_i n=lv - 1 @@ -249,7 +229,6 @@ WOK @@xml[:body] << if para[@regx,3]; %{#{@tab*0}<object id="#{para[@regx,3]}">} << "\n" else "#{@tab*0}<object>" << "\n" if para[@regx] end - #@@xml[:body] << "#{@tab*1}<heading>#{lv}</heading>" << "\n" if lv @@xml[:body] << "#{@tab*1}<ocn>#{para[@regx,3]}</ocn>" << "\n" if para[@regx,3] @@xml[:body] << if lv; %{#{@tab*1}<text class="h#{lv}">\n#{@tab*2}#{wrapped}\n#{@tab*1}</text>\n} << "\n" else %{#{@tab*1}<text class="#{type}">\n#{@tab*2}#{wrapped}\n#{@tab*1}</text>\n} # main text, contents, body KEEP |