From 17dfb02b30980c40a5b1227789aff1f070d57948 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 6 Oct 2007 00:45:59 +0100 Subject: param, multi-line parse, fixing @link: header --- lib/sisu/v0/param.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') 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|$)/ -- cgit v1.2.3 From 2386d74a25bcbeff7e3022001ed7d14dc0538792 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 6 Oct 2007 13:27:01 +0100 Subject: dal, fix shortcult for listing available generated output (without source); html, keep ocn id where no visible ocn --- lib/sisu/v0/dal.rb | 2 +- lib/sisu/v0/html_format.rb | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'lib') 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+|)$/, + %{

+   +

}) + else + ocn_class='ocn' + @paranum.gsub(/^(\d+|)$/, %{

  \\1

}) + end end def name %{} -- cgit v1.2.3 From 3804f096e2dd3c82ace274463df6b9b0767fbb60 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 7 Oct 2007 14:09:03 +0100 Subject: cleaning, and make sure in xml   rather than   is used --- lib/sisu/v0/html_segments.rb | 10 +++------- lib/sisu/v0/html_tune.rb | 7 +++---- lib/sisu/v0/shared_html_lite.rb | 10 ++++------ lib/sisu/v0/shared_xml.rb | 26 +++++++------------------- lib/sisu/v0/texpdf_format.rb | 7 +------ lib/sisu/v0/xhtml.rb | 19 ------------------- lib/sisu/v0/xml.rb | 21 --------------------- 7 files changed, 18 insertions(+), 82 deletions(-) (limited to 'lib') 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] << '
 
' 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,%{©}) 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}
[link]#{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|$))/,'\1\2') #http ftp matches escaped, no decoration para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\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 * ') - #para.gsub!(/^_\*\s+/,'* ') para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))\s+(\d+)x(\d+)(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1[\\2] \\5}) para.gsub!(/(^|\s)\{\s*(\S+?\.(?:jpg|png|gif))(\s+[^}]+)?\}(https?:\/\/\S+)/,%{\\1\\2}) para.gsub!(/(^|\s)\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?=\s|$))/, '\1\2\4') #watch, compare html_tune - #para.gsub!(/\B\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/, - # '\1\3') #watch, compare html_tune para.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, %{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) - #para.gsub!(/\b((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/, #also works - #%{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}\\2}) para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #escaped urls not linked, deal with later - #para.gsub!(/(^|\s)[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3') #escaped urls not linked, deal with later - para.gsub!(/ /,' ') #clean - else para.gsub!(/_/m,'>') #code-block: angle brackets special characters + para.gsub!(/ /,' ') + #para.gsub!(/ /,' ') #clean + else + 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)/, "#{@dir.url.images_local}\/\\1") - 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=%{ \n} - #if @md.subtitle - # @rdf_title=%{ dc.title="#{seg_name}#{@md.title} - #{@md.subtitle}"\n} - # @title=%{\n} - #else - # @rdf_title=%{ dc.title="#{seg_name}#{@md.title}"\n} - # @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}" << "\n" if para[@regx] - @@xml[:body] << "#{@tab*1}#{para[@regx,3]}" << "\n" if para[@regx,3] - @@xml[:body] << if lv; %{#{@tab*1}#{wrapped}\n} << "\n" - else %{#{@tab*1}#{wrapped}\n} # main text, contents, body KEEP - end - ##@@xml[:body] << "#{@tab*1}#{para[@regx,2]}\n" if para[@regx,2] # old unwrapped main text, contents, body KEEP - @@xml[:body] << "#{@tab*0}" << "\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}" << "\n" if para[@regx] - @@xml[:body] << "#{@tab*1}#{para[@regx,3]}" << "\n" if para[@regx,3] - @@xml[:body] << if lv; %{#{@tab*1}#{wrapped}\n} << "\n" - else %{#{@tab*1}#{wrapped}\n} # main text, contents, body KEEP - end - #@@xml[:body] << "#{@tab*1}#{wrapped}\n" # main text, contents, body KEEP - ##@@xml[:body] << "#{@tab*1}#{para[@regx,2]}\n" if para[@regx,2] # old unwrapped main text, contents, body KEEP - @@xml[:body] << "#{@tab*0}" << "\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}} << "\n" else "#{@tab*0}" << "\n" if para[@regx] end - #@@xml[:body] << "#{@tab*1}#{lv}" << "\n" if lv @@xml[:body] << "#{@tab*1}#{para[@regx,3]}" << "\n" if para[@regx,3] @@xml[:body] << if lv; %{#{@tab*1}\n#{@tab*2}#{wrapped}\n#{@tab*1}\n} << "\n" else %{#{@tab*1}\n#{@tab*2}#{wrapped}\n#{@tab*1}\n} # main text, contents, body KEEP -- cgit v1.2.3