diff options
author | Ralph Amissah <ralph@amissah.com> | 2007-09-23 05:16:53 +0100 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2007-09-23 05:16:53 +0100 |
commit | bcd7f88ba20b1dbc956522d90fca4f1982dddcef (patch) | |
tree | fea6227b42001b2949635b36daaf30da864e53ce /lib | |
parent | Merge branch 'upstream' into debian/sid (diff) | |
parent | primarily todo with sisu documentation, changelog reproduced below: (diff) |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib')
32 files changed, 972 insertions, 254 deletions
diff --git a/lib/sisu/v0/composite.rb b/lib/sisu/v0/composite.rb index 6223743c..557a0519 100644 --- a/lib/sisu/v0/composite.rb +++ b/lib/sisu/v0/composite.rb @@ -158,7 +158,7 @@ module SiSU_Assemble else @code_flag end unless @code_flag - i.gsub!(/^([12]|:?[AB])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i.gsub!(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^0~|^@\S+?:/ i.gsub!(/\n/m,"\n% ") i.gsub!(/\n%\s+$/m,'') @@ -189,8 +189,8 @@ module SiSU_Assemble loadfile=$1.strip tell=SiSU_Screen::Ansi.new(@opt.cmd,'loading:',loadfile) tell.txt_grey if @opt.cmd =~/[MVv]/ - tuned_file << if loadfile =~ /http:\/\/\S+?\.ss[ti]$/ # and NetTest - imagedir = /(http:\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch + tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[ti]$/ # and NetTest + imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[ti]$/.match(loadfile).captures.join + '/_sisu/image' #watch require 'uri' image_uri=URI.parse(imagedir) require 'open-uri' diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 111741ab..9e114f80 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -196,9 +196,9 @@ WOK @rxp_t1=Regexp.new('^T1') @rxp_t2=Regexp.new('^T2') @rxp_t3=Regexp.new('^T3') - @rxp_excluded1=/(?:https?|ftp):\/\/\S+/mi + @rxp_excluded1=/(?:https?|file|ftp):\/\/\S+/mi @rxp_excluded0=/^(?:to\d+|\d+| |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\.?)$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! - @rgx_scanlist=%r{(?:<i>(?:[a-zA-Z0-9"\s]){2,7}</i>|<b>(?:[a-zA-Z0-9"\s]){2,7}</b>|http://\S+)|code\{.+?\}code|<\S+?>|\w+}mi + @rgx_scanlist=%r{(?:<i>(?:[a-zA-Z0-9"\s]){2,7}</i>|<b>(?:[a-zA-Z0-9"\s]){2,7}</b>|(?:https?|file)://\S+)|code\{.+?\}code|<\S+?>|\w+}mi rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error end end diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index f5aabf7f..f4cf5228 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -306,6 +306,15 @@ WOK margin-right: 5mm; 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 { font-size: 80%; margin-top: 0px; diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index c2c92485..f5da8b05 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -264,7 +264,7 @@ module SiSU_DAL end data.each do |para| para.strip! - if para =~/\{\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?\}(?:(?:https?|ftp):\S+|image)/ + 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 @@ -295,7 +295,7 @@ module SiSU_DAL end end para.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else para.gsub!(/\{\s*(\S+)\.(png|jpg|gif).+?\}((?:https?|ftp):\S+|image)/,'[ \1 (\2 missing) ]') + else para.gsub!(/\{\s*(\S+)\.(png|jpg|gif).+?\}((?:https?|file|ftp):\S+|image)/,'[ \1 (\2 missing) ]') end end else @@ -306,7 +306,7 @@ module SiSU_DAL end end end - para.gsub!(/\{\s+(\S+\.(?:png|jpg|gif))\s+/i,'{\1 ') if para =~/\{\s+\S+\.(?:png|jpg|gif).+?\}(?:(?:https?|ftp):\S+|image)/ + 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 @@ -329,6 +329,8 @@ module SiSU_DAL end file_type_names <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] end + #file_type_names <<= if cmd_list =~ /i/; 'manpage.1' + #end file_type_names <<= if cmd_list =~ /o/; 'opendocument.odt' end file_type_names <<= if cmd_list =~ /b/; 'scroll.xhtml' @@ -406,6 +408,7 @@ module SiSU_DAL 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)' @@ -1069,7 +1072,7 @@ module SiSU_DAL #s=s.gsub(/¡¡\d+¡/,' ') # tables #s=s.gsub(/¡/,' ') # tables tidy later #s=s.gsub(/<.+?>/,'') - s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|ftp)\\\:\S+ /,' [image] ') # else image names found in search + 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 diff --git a/lib/sisu/v0/dal_doc_str_code.rb b/lib/sisu/v0/dal_doc_str_code.rb index 52aa4a40..c45d95f1 100644 --- a/lib/sisu/v0/dal_doc_str_code.rb +++ b/lib/sisu/v0/dal_doc_str_code.rb @@ -153,7 +153,7 @@ module SiSU_document_structure_code if line =~/\S/ and line !~/^code\{|^\}code|<:code.+/ line.gsub!(/\s\s/,' ') line.gsub!(/^/,'<:codeline>') if type=='code' # try sort for texpdf special case - if line =~/https?:\/\/\S+$/ + if line =~/(?:https?|file|ftp):\/\/\S+$/ line.gsub!(/$/,' <:br>') else line.gsub!(/$/,'<:br>') #unless type=='code' end diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 36ea3b04..bf83c8ef 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -65,7 +65,7 @@ module Syntax @data,@md=data,md @vz=SiSU_Env::Get_init.instance.skin @data_new=[] - @http_m='\{.+?\}https?://\S+|https?:\S+|\.\.\/\S+|\S+?\.png\b|[*]~\S+|^0~.+|<:(?:code|group|alt|verse)(?:-end)?>|<:br>' + @http_m='\{.+?\}(?:https?|file)://\S+|(?:https?|file):\S+|\.\.\/\S+|\S+?\.png\b|[*]~\S+|^0~.+|<:(?:code|group|alt|verse)(?:-end)?>|<:br>' @manmkp_ital='[i/]\\{.+?\\}[i/]' tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)} tail_m_bold=%q{(?:(?:<\/i>)?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} @@ -212,7 +212,7 @@ module Syntax line.gsub!(/^(1~\??) @title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 #{@md.title} - #{@md.subtitle},<br />\\2#{@md.dc_creator}") line.gsub!(/^(1~\??) @title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") # line.gsub!(/^([23]~\??) (?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 \\2#{@md.dc_creator}") # - line.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup + line.gsub!(/<((?:https?|file):\/\/\S+?)>/,'< \1 >') #catch problem markup line.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu') #adjustment 2005w30 line.gsub!(/<!(\S+)!>/,'<:\1>') #escaped special character line.gsub!(/\\~/,'~') #escaped special character @@ -239,8 +239,8 @@ module Syntax line.gsub!(/\\\!/,'!') #escaped special character line.gsub!(/(?:^| )\*~([a-z0-9._-]+)/i,' <:name#\1>') #html name marker <a name="\\1"></a> line.gsub!(/^([56]~)(\S+)(.+)/,'\1\2 \3 <:name#\2>') #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!(/(^| )\{~\^ (.+?)\s*\}((?:https?|ftp):\S+?)([;,.]?(?=\s[^~]|$))/,'\1{ \2 }\3\4 ~{ \3 }~ ') #text url endnote url shortcut {~^ [text] }http://url is { [text] }http://url ~{ http://url }~ [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.. - line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch + line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+?)([;,.]?(?=\s[^~]|$))/,'\1{ \2 }\3\4 ~{ \3 }~ ') #text url endnote url shortcut {~^ [text] }http://url is { [text] }http://url ~{ http://url }~ [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.. + line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch line.gsub!(/<:?br>/,'<br />') #xml requires # depreciated --> line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)e\{(.+?)\}e/,'\1<b>\2</b>') #emphasis diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 5ef26466..91729e3a 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -125,7 +125,7 @@ module SiSU_DB_import string.gsub!(/<:(?:code|alt|group|verse)(?:-end)?>/,'') string.gsub!(/<:name#\S+?>/,'') string.gsub!(/\{\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)\}\S+/,'[image: \1] \2') - string.gsub!(/\{\s*(.+?)\s*\}https?:\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') + string.gsub!(/\{\s*(.+?)\s*\}(?:https?|file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') end def unicode_special_character_escape(string) #string.gsub!(/(["';:,])/, %{\\\\\\1}) @@ -139,7 +139,7 @@ module SiSU_DB_import string.gsub!(/¡¡\d+¡/,' ') #tables string.gsub!(/¡/,' ') #tables tidy later string.gsub!(/<.+?>/,'') - string.gsub!(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|ftp)\\\:\S+ /,' [image] ') # else image names found in search + string.gsub!(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|file|ftp)\\\:\S+ /,' [image] ') # else image names found in search string.gsub!(/\s\s+/,' ') string.strip! end diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index c46860c3..4d97aed1 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -149,7 +149,7 @@ module SiSU_Viz end #% path def path_stylesheet_home - %{ <link rel="stylesheet" href="./#{@dir.path.style}/index.css" type="text/css" />} + %{ <link rel="stylesheet" href="./#{@dir.path.style}/homepage.css" type="text/css" />} end #% text #changed from txt to avoid naming conflicts #FOLLOW def txt_generator @@ -1482,7 +1482,7 @@ If your browser supports redirection, you will be escorted there shortly. </html> WOK end - def index + def homepage <<WOK <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> @@ -1551,6 +1551,14 @@ outputs include: plaintext, html, XHTML, XML, ODF (OpenDocument), LaTeX, PDF, SQ --- </p> <p class="small"> + <a href="http://www.jus.uio.no/sisu/sisu_manual/" target="_top" > + SiSU Manual + </a> +</p> +<p class="tiny"> + --- +</p> +<p class="small"> <a href="http://www.jus.uio.no/sisu/SiSU/1.html#summary" target="_top" > What does SiSU do? Summary </a> diff --git a/lib/sisu/v0/digests.rb b/lib/sisu/v0/digests.rb index 1e4e3c6a..7324b93b 100644 --- a/lib/sisu/v0/digests.rb +++ b/lib/sisu/v0/digests.rb @@ -158,8 +158,8 @@ module SiSU_Digest_view para_endnotes << para.scan(/~[{\[]([\d*+]+).+?<([0-9a-f]{#@dl})>[}\]]~/) end ima=[] - if para =~/\{(\S+\.(png|jpg|gif))\s.+?\}(?:(?:https?|ftp):\/\/\S+|image)/ - images=para.scan(/\{(\S+\.(?:png|jpg|gif))\s.+?\}(?:(?:https?|ftp):\/\/\S+|image)/).flatten + if 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 else image=nil end x=case para diff --git a/lib/sisu/v0/help.rb b/lib/sisu/v0/help.rb index e22808d1..4805f6ad 100644 --- a/lib/sisu/v0/help.rb +++ b/lib/sisu/v0/help.rb @@ -238,9 +238,7 @@ WOK def commands print <<WOK - #{@cX.ruby}-A#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces plaintext with dos linefeeds. Without markup, (object numbers are omitted), has footnotes at end of each para‐ graph that contains them [ -a for equivalent Unix (ascii) output file] [see -E for endnotes] - - #{@cX.ruby}-a#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces plaintext with Unix linefeeds. Without markup, (object numbers are omitted), has footnotes at end of each para‐ graph that contains them [ -A for equivalent dos (ascii) output file] [see -e for endnotes] + #{@cX.ruby}-a#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces plaintext with Unix linefeeds. Without markup, (object numbers are omitted), has footnotes at end of each para‐ graph that contains them. Modifier options available: --footnotes (default) or --endnotes and for linefeeds --unix (default) or --msdos #{@cX.ruby}-b#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces xhtml/XML output for browser viewing (sax parsing) @@ -252,10 +250,6 @@ WOK #{@cX.ruby}-d#{@cX.off} #{@cX.green}[instruction]#{@cX.off} #{@cX.green}[filename]#{@cX.off} database instruction, see database section below [only -D currently available] - #{@cX.ruby}-E#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces plaintext with dos linefeeds, and without markup, endnotes follow the main text (in -a endnotes follow the paragraphs that contain them). There are no object numbers [see -e for Unix (ascii) output file] [see -A for footnotes] - - #{@cX.ruby}-e#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces plaintext with Unix linefeeds, and without markup, endnotes follow the main text. Object numbers are omitted. [ -E for equivalent dos (ascii) output file] [ -a for footnotes] - #{@cX.ruby}-F#{@cX.off} generate examples of (naive) cgi search form for sqlite and pgsql depends on your already having used sisu to populate an sqlite and/or pgsql database, (the sqlite version scans the output directories for existing sisu_sqlite databases, so it is first necessary to create them, before generating the search form) see -d -D and the database section below. If the optional parameter webrick is passed, the cgi examples created will be set up to use the default port set for use by the webrick server, (otherwise the port is left blank and the system setting used, usually 80). The samples are dumped in the present work directory which must be writable, (with screen instructions given that they be copied to the cgi-bin directory). #{@cX.ruby}-H#{@cX.off} #{@cX.green}[filename/wildcard]#{@cX.off} produces html (css version) (creates html (using css)), with url link suffixes (.html .pdf etc.) omitted ("Hide"). For web servers that are confireud so as not to require file extensions to locate and serve files. [behaviour switched see -h] @@ -456,19 +450,19 @@ sisu Note: page breaks are usually introduced to pdfs either as header instructions, indicating that pages should break at given levels ------------------------------------------ #{@cX.cyan}Composite documents#{@cX.off} - It is possible to build a document by requiring other documents. The documents required may complete documents that could be generated independently, or they could be markup snippets, prepared so as to be easily available to be placed within another text. If the calling document is a master document (built mainly from other documents), by convention it should be named with the suffix .ssc or .ssm The documents called if complete documents would have the suffix .sst, [.ssf, or .ssd], and if markup snippets .ssi. A temporary file of the composite document is built prior to processing with the same prefix and the suffix ._sst There are a number of alternative syntaxes for requiring external documents in order to permit use of ascii hypertext linking available in the vim editor. They are as follows (place at start of line): + It is possible to build a document by creating a master document that requires other documents. The documents required may complete documents that could be generated independently, or they could be markup snippets, prepared so as to be easily available to be placed within another text. If the calling document is a master document (built mainly from other documents), it should be named with the suffix #{@cX.blue}.ssm#{@cX.off} Within this document you would provide information on the other documents that should be included within the text. These may be other documents that would be processed in a regular way, or markup bits prepared only for inclusion within a master document #{@cX.blue}.sst#{@cX.off} regular markup file, or #{@cX.blue}.ssi#{@cX.off} (insert/information) A secondary file of the composite document is built prior to processing with the same prefix and the suffix #{@cX.blue}._sst#{@cX.off} #{@cX.cyan}#basic sisu markup alternatives#{@cX.off} - #{@cX.green}{#{@cX.off}filename.si#{@cX.green}}require#{@cX.off} - #{@cX.green}<< {#{@cX.off}filename.si#{@cX.green}}#{@cX.off} + #{@cX.green}{#{@cX.off}filename.ssi#{@cX.green}}require#{@cX.off} + #{@cX.green}<< {#{@cX.off}filename.ssi#{@cX.green}}#{@cX.off} #{@cX.cyan}#using textlink alternatives#{@cX.off} - #{@cX.green}|#{@cX.off}filename.si#{@cX.green}|@|^|require#{@cX.off} - #{@cX.green}<< |#{@cX.off}filename.si#{@cX.green}|@|^|#{@cX.off} + #{@cX.green}|#{@cX.off}filename.ssi#{@cX.green}|@|^|require#{@cX.off} + #{@cX.green}<< |#{@cX.off}filename.ssi#{@cX.green}|@|^|#{@cX.off} #{@cX.cyan}#using thlnk alternatives#{@cX.off} - #{@cX.green}<url:#{@cX.off}filename.si#{@cX.green}>require#{@cX.off} - #{@cX.green}<< <url:#{@cX.off}filename.si#{@cX.green}>#{@cX.off} + #{@cX.green}<url:#{@cX.off}filename.ssi#{@cX.green}>require#{@cX.off} + #{@cX.green}<< <url:#{@cX.off}filename.ssi#{@cX.green}>#{@cX.off} #{@cX.cyan}Composite documents - remote parts#{@cX.off} Composite documents may be built from remote parts, by using the composite document syntax with a url. This makes sense using either sisu regular syntax (which is just a convenient way of marking up), or thlnk syntax, which also recognises remote urls, and permits hyperlinking ascii to the url location. @@ -598,7 +592,7 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c #{@cX.cyan}@subtitle:#{@cX.off} The Subtitle if any -#{@cX.fuschia}@creator:#{@cX.off} [or ~author] Ralph Amissah +#{@cX.fuschia}@creator:#{@cX.off} [or @author:] Name of Author #{@cX.fuschia}@subject:#{@cX.off} (whatever your subject) @@ -608,11 +602,11 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c #{@cX.fuschia}@contributor:#{@cX.off} -#{@cX.fuschia}@translator:#{@cX.off} [or ~translated_by] +#{@cX.fuschia}@translator:#{@cX.off} [or @translated_by:] -#{@cX.fuschia}@illustrator:#{@cX.off} [or ~illustrated_by] +#{@cX.fuschia}@illustrator:#{@cX.off} [or @illustrated_by:] -#{@cX.fuschia}@prepared_by:#{@cX.off} [or ~digitized_by] +#{@cX.fuschia}@prepared_by:#{@cX.off} [or @digitized_by:] #{@cX.fuschia}@date:#{@cX.off} 2000-08-27 \t[ also #{@cX.fuschia}@date.created:#{@cX.off} #{@cX.fuschia}@date.issued:#{@cX.off} #{@cX.fuschia}@date.available:#{@cX.off} #{@cX.fuschia}@date.valid:#{@cX.off} #{@cX.fuschia}@date.modified:#{@cX.off} ] @@ -625,7 +619,13 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c #{@cX.fuschia}@source:#{@cX.off} -#{@cX.fuschia}@language:#{@cX.off} [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bul garian ) [however, encodings are not available for all of the languages listed.] +#{@cX.fuschia}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bul garian ) [however, encodings are not available for all of the languages listed.] + +#{@cX.fuschia}@language.original:#{@cX.off} +original language in which the work was published + +#{@cX.fuschia}@papersize:#{@cX.off} +(A4|US_letter|book_B5|book_A5|US_legal) #{@cX.fuschia}@relation:#{@cX.off} @@ -658,24 +658,23 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c #{@cX.cyan}@rcs:#{@cX.off} $Id$ [used by rcs or cvs to embed version (revision control) information into document, rcs or cvs can usefully provide a history of updates to a document ] #{@cX.ruby}@structure:#{@cX.off} PART; CHAPTER; SECTION; ARTICLE; none; none; - structure can be defined by a match words or regular expression (the regular expression is assumed to start at the beginning of a line of text i.e. ^) - can be used within text instead, without this header tag, and may be used to suppliment the instructions provided in this header tag if provided +optional, document structure can be defined by words to match or regular expression (the regular expression is assumed to start at the beginning of a line of text i.e. ^) default markers :A~ to :C~ and 1~ to 6~ can be used within text instead, without this header tag, and may be used to supplement the instructions provided in this header tag if provided (@structure: is a synonym for @toc:) #{@cX.ruby}@level:#{@cX.off} newpage=3; breakpage=4 [paragraph level, used by latex to breakpages, the page is optional eg. in newpage] #{@cX.ruby}@markup:#{@cX.off} num_top=4 [various markup instructions, eg: num_top=4 headings tobe numbered, starting at heading level 4... the default is to provide 3 levels, as in 1 level 4, 1.1 level 5, 1.1.1 level 6, markup to be merged within level] -#{@cX.ruby}@bold:#{@cX.off} [list of words to make bold with semi colon separator] +#{@cX.ruby}@bold:#{@cX.off} [regular expression of words/phrases to be made bold] -#{@cX.ruby}@italics:#{@cX.off} [list of words to italize with semi colon separator] +#{@cX.ruby}@italics:#{@cX.off} [regular expression of words/phrases to italize] #{@cX.ruby}@vocabulary:#{@cX.off} name of taxonomy/vocabulary/wordlist to use against document #{@cX.ruby}@skin:#{@cX.off} skin_doc_[name_of_desired_document_skin] -#{@cX.ruby}@links:#{@cX.off} http://google.com; Google; +#{@cX.ruby}@links:#{@cX.off} { SiSU }http://www.jus.uio.no/sisu/; { FSF }http://www.fsf.org -#{@cX.ruby}@@promo:#{@cX.off} sisu, ruby, search_libre_docs, open_society [places content in right pane in html, makes use of list.yml and promo.yml, commented out sample in document sample: free_as_in_freedom.richard_stallman_cru‐ sade_for_free_software.sam_williams.sst] +#{@cX.ruby}@@promo:#{@cX.off} sisu, ruby, search_libre_docs, open_society [places content in right pane in html, makes use of list.yml and promo.yml, commented out sample in document sample: free_as_in_freedom.richard_stallman_crusade_for_free_software.sam_williams.sst] #{@cX.grey}% header ends here, NB only @title: is mandatory [this would be a comment]#{@cX.off} #{@cX.grey}% NOTE: headings/levels below refer to 0.38 expermental markup @@ -770,7 +769,7 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c #{@cX.green}0~#{@cX.off}#{@cX.ruby}toc#{@cX.off} PART; CHAPTER; SECTION; ARTICLE; none; none; optional, where document structure can be defined by a match words or regular expression (the regular expression is assumed to start at the beginning of a line of text i.e. ^) -default markers 1~ to 6~ can be used within text instead, without this header tag, and may be used to suppliment the instructions provided in this header tag if provided +default markers 1~ to 6~ can be used within text instead, without this header tag, and may be used to supplement the instructions provided in this header tag if provided #{@cX.green}0~#{@cX.off}#{@cX.ruby}level#{@cX.off} newpage=3; breakpage=4 [paragraph level, used by latex to breakpages, the page is optional eg. in newpage] @@ -784,7 +783,7 @@ default markers 1~ to 6~ can be used within text instead, without this header ta #{@cX.green}0~#{@cX.off}#{@cX.ruby}skin#{@cX.off} skin_doc_[name_of_desired_document_skin] -#{@cX.green}0~#{@cX.off}#{@cX.ruby}links#{@cX.off} http://google.com; Google; +#{@cX.green}0~#{@cX.off}#{@cX.ruby}links#{@cX.off} { Google }http://google.com; #{@cX.grey}% header ends here, NB only 0~title is mandatory [this would be a comment]#{@cX.off} @@ -1733,6 +1732,18 @@ WOK #{@cX.off} #{@cX.orange} man estcmd #{@cX.off} + + on sisu_hyperestraier: + + #{@cX.blue} + man sisu_hyperestraier + + /usr/share/doc/sisu/sisu_markup/sisu_hyperestraier/index.html + #{@cX.off} + + NOTE: The examples that follow assume that sisu output is placed in the directory + /home/ralph/sisu_www + (A) to generate the index within the webserver directory to be indexed: #{@cX.orange}estcmd gather -sd [index name] [directory path to index]#{@cX.off} @@ -1754,13 +1765,13 @@ WOK as sisu duplicates output in multiple file formats, it it is probably preferable to limit the estraier index - to html output, and as it may also be desireable to + to html output, and as it may also be desirable to exclude files 'doc.html' and 'concordance.html', as these duplicate information held in other html output e.g. #{@cX.green} find /home/ralph/sisu_www -type f | egrep '/sisu_www/(sisu|bookmarks)/.+?\.html$' | egrep -v '(doc|concordance)\.html$' |estcmd gather -sd casket - #{@cX.off} - from your current document preperation/markup directory, you would construct a rune along the following lines: #{@cX.green} + from your current document preparation/markup directory, you would construct a rune along the following lines: #{@cX.green} find /home/ralph/sisu_www -type f | egrep '#{@env.path.webserv}/([specify first directory for inclusion]|[specify second directory for inclusion]|[another directory for inclusion? ...])/.+?\.html$' | egrep -v '(doc|concordance)\.html$' |estcmd gather -sd #{@env.path.webserv}/casket - #{@cX.off} diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 639ecd26..0b861526 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -244,10 +244,10 @@ module SiSU_Tune def urls(data) @words=[] data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ - if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([;.,]?(?:\s|$))/ - m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([;.,]?(?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures + @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 d='' end case m @@ -265,13 +265,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?|ftp)\S+|image)/,ins) + word.gsub!(/\{.+?\}((?: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?|ftp)\S+/,ins) + word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) end word else word @@ -304,8 +304,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 =~/\{.+?\}((?:http|ftp)\S+|image)/ - @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) + 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) @@ -326,9 +326,9 @@ module SiSU_Tune if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<<a href="mailto:\1">\1</a>>\2') end - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|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 + 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)((?: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+<)/) para.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>') end diff --git a/lib/sisu/v0/hub.rb b/lib/sisu/v0/hub.rb index 12e477c0..52937b8e 100644 --- a/lib/sisu/v0/hub.rb +++ b/lib/sisu/v0/hub.rb @@ -152,7 +152,10 @@ module SiSU 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 + when /^manpage$/; SiSU_manpage::Source.new(@opt).read # -i when /^texinfo$/; SiSU_TexInfo::Source.new(@opt).read # -I + #when /^plaintext_exp$/; SiSU_Plaintext_exp::Source.new(@opt).read # -j + #when /^manpage_exp$/; SiSU_manpage_exp::Source.new(@opt).read # -J #when /^docbook$/; SiSU_Docbook::Source.new(@opt).read # -B when /^html$/; SiSU_HTML::Source.new(@opt).read # -h -H when /^xml$/; SiSU_XML_SAX::Source.new(@opt).read # -x @@ -287,7 +290,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ def actions if @opt.mod.inspect =~/--convert|--to|--from/; require "#{SiSU_lib}/sst_convert_markup" end - if @opt.cmd =~/([AabCcDdEeFfgGHhIiLMmNnOoprRSsTtQqUuVvwWXxYyZ_0-9])/ and + if @opt.cmd =~/([AabCcDdEeFfgGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ and @opt.cmd =~/^-/ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ #and @@ -296,7 +299,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ flag=SiSU_Env::Info_processing_flag.new extra='' if @opt.cmd !~/[mn]/ - extra+=if @opt.cmd =~/[abeghHhINOoptTwXxz]/ and @opt.cmd !~/[mn]/; 'm' #% add dal + extra+=if @opt.cmd =~/[abeghHhIiJjNOoptTwXxz]/ and @opt.cmd !~/[mn]/; 'm' #% add dal elsif ((@opt.cmd =~/[Dd]/ or (@opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ and @opt.mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ and @opt.cmd !~/[mn]/ @@ -305,7 +308,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end end if @opt.cmd !~/y/ - extra+=if @opt.cmd =~/[abehHhINopsSstwXxz]/ and @opt.cmd !~/y/; 'y' #% add manifest + extra+=if @opt.cmd =~/[abehHhIiJjNopsSstwXxz]/ and @opt.cmd !~/y/; 'y' #% add manifest elsif (@opt.cmd =~/[Dd]/ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) and @opt.files[0] !~/^remove$/ and @opt.cmd !~/y/; 'y' #% add manifest else '' end @@ -375,8 +378,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ path_image='./_sisu/processing/external_document/image' path_skin='./_sisu/processing/external_document/skin/doc' @get_s,@get_p=[],[] - re_s=/(http:\/\/\S+?\.sst)/ - re_p=/(http:\/\/\S+?(?:\/sisupod(?:\.zip)?|\.ssp))/ + re_s=/((?:https?|file):\/\/\S+?\.sst)/ + re_p=/((?:https?|file):\/\/\S+?(?:\/sisupod(?:\.zip)?|\.ssp))/ @opt.files.each do |fns| if fns =~re_s @get_s << re_s.match(fns)[1] if re_s @@ -396,10 +399,10 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ threads << Thread.new(requested_page) do |url| open(url) do |f| raise "#{url} not found" unless f - re_fnb=/(http:\/\/[^\/ ]+?\/[^\/ ]+?)\/\S+?\/([^\/]+?)\.ss(t)/ #revisit and remove DO + re_fnb=/((?:https?|file):\/\/[^\/ ]+?\/[^\/ ]+?)\/\S+?\/([^\/]+?)\.ss(t)/ #revisit and remove DO base_uri,fnb,instr=re_fnb.match(url)[1..3] if re_fnb imagedir= base_uri + '/_sisu/image_local' #check on - doc_skin_dir = /(http:\/\/\S+?)\/[^\/]+?\.sst$/.match(url).captures.join + '/_sisu/skin/doc' + doc_skin_dir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.sst$/.match(url).captures.join + '/_sisu/skin/doc' #"Got file, and ready to process: #{fnb}.t#{instr}" downloaded_file=File.new("#{fnb}.-sst",'w+') images=SiSU_Assemble::Remote_image.new.image(imagedir) @@ -445,7 +448,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ retry unless @retry_count > 1 ensure end - @opt.files=@opt.files.collect {|x| x=x.gsub(/http:\/\/\S+\/(\S+)\.sst/,'\1.-sst') } + @opt.files=@opt.files.collect {|x| x=x.gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst/,'\1.-sst') } end if @opt.cmd=~/m/; op('dal','dal') #% -m dal end @@ -496,8 +499,14 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end if @opt.cmd =~/p/; op('texpdf','LaTeX pdf') #% -p latex/ texpdf end + if @opt.cmd =~/i/; op('manpage','manpage') #% -i manpage + end if @opt.cmd =~/I/; op('texinfo','TeX Info') #% -I texinfo (i taken by db import) end + #if @opt.cmd =~/j/; op('plaintext_exp','plaintext exp') #% -j plaintext + #end + #if @opt.cmd =~/J/; op('manpage_exp','manpage exp') #% -J manpage + #end if @opt.cmd =~/D/ or @opt.mod.inspect =~/--pgsql/; op('dbi','postgresql') #% -D DB postgresql end if @opt.cmd =~/d/ or @opt.mod.inspect =~/--sqlite/; op('dbi','sqlite') #% -d DB sqlite diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb new file mode 100644 index 00000000..dfc1ebf8 --- /dev/null +++ b/lib/sisu/v0/manpage.rb @@ -0,0 +1,519 @@ +=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 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/licenses/gpl.html> + <http://www.gnu.org/copyleft/gpl.html> + <http://www.jus.uio.no/sisu/gpl.fsf> + + * 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: manpage text generation, stripped manpage output (unix, + linefeed) + +=end +module SiSU_manpage + require "#{SiSU_lib}/dal" + require "#{SiSU_lib}/sysenv" + include SiSU_Env + include SiSU_Param + include SiSU_Viz + require "#{SiSU_lib}/manpage_format" + include Format + require "#{SiSU_lib}/shared_txt" + pwd=Dir.pwd + @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@tablefoot='' + class Source + def initialize(opt) + @opt=opt + if @opt.fns =~/(.+?)\.[_-]?sst$/ + @@dostype='unix endnotes' + else puts "#{sf} not a processed file type" + end + end + def read + begin + @md=SiSU_Param::Parameters.new(@opt).get + @env=SiSU_Env::Info_env.new(@opt.fns) + path=@env.path.output_tell + tool=if @opt.cmd =~/[MVv]/; "#{@env.program.text_editor} #{path}/man/#{@md.fn[:manpage]}" + else '' + end + tell=SiSU_Screen::Ansi.new(@opt.cmd,'Manpage',tool) + tell.green_hi_blue unless @opt.cmd =~/q/ + tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.path.output_tell}/man/#{@md.fn[:manpage]}") + tell.flow if @opt.cmd =~/[MV]/ + my_make=SiSU_Env::Create_file.new(@opt.cmd,@opt.fns) + @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here + SiSU_manpage::Source::Scroll.new(@dal_array,@md).songsheet + SiSU_Env::Info_skin.new(@md).select #watch + rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + ensure + end + end + private + class Split_text_object <Source + require "#{SiSU_lib}/manpage_format" + include SiSU_Viz + include Format + @@alt_id_count=0 + @@dp=nil + attr_reader :format,:lev,:text,:ocn,:lev_para_ocn + def initialize(para) + @para=para + @format,@ocn='null','null' + @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + end + def lev_segname_para_ocn + @text=nil + if @para =~/^(\d~|<:.+?>).+?<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + if /^(([1-6])~(\S+))\s+(\S.+?)<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @format,@lev,segname,@text,@ocn=$1,$2,$3,$4,$5 + elsif /^(([1-6])~)\s+(\S.+?)<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @format,@lev,@text,@ocn=$1,$2,$3,$4 + elsif /<:(.+?)>\s*(\S.+?)<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @format,@text,@ocn=$1,$2,$3 + elsif /^(([1-6])~(\S+))\s+(\S.+?)<~(\d+);(?:\w|[0-6]:)\d+;[um]\d+><#@dp:#@dp>$/m.match(@para) + @@alt_id_count+=1 + @format,@lev,segname,@text,@ocn=$1,$2,$3,$4,"x#{@@alt_id_count}" + elsif /^(([1-6])~)\s+(\S.+?)<~(\d+);[um]\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @@alt_id_count+=1 + @format,@lev,@text,@ocn=$1,$2,$3,"x#{@@alt_id_count}" + end + else + if /(.+?)<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m.match(@para) + @text,@ocn=$1,$2 + end + if @para !~/<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$|^$/ #added 2002w06 + @text=/(.+?)/m.match(@para)[1] + end + if /^((\d)~(?:~\S+)?)\s+(.+)/m.match(@para) + @format,@lev,@text=$1,$2,$3 + end + end + format=@format.dup + @lev_para_ocn=if @para =~/.+<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + Format::Format_text_object.new(format,@text,@ocn) + else + Format::Format_text_object.new(format,@text,"<~(\d+);[um]\d+;\w\d+><#@dp:#@dp>") + end + self + end + end + class Scroll <Source + require "#{SiSU_lib}/defaults" + require "#{SiSU_lib}/shared_txt" + include SiSU_text_utils + @@endnotes={ :para=>[],:end=>[] } + @@dp=nil + def initialize(data,md) + @data,@md=data,md + @url_brace=SiSU_Viz::Skin.new.url_decoration + @vz=SiSU_Env::Get_init.instance.skin + @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m # 2004w18 pb pn removal added + @tab="\t" + @br="\n" + @@dostype='unix endnotes' + @manpage={ :body=>[],:open=>[],:close=>[],:head=>[],:metadata=>[],:tail=>[],:endnotes=>[] } + end + def songsheet + manpage=markup(@data) + publish(manpage) + end + # Used for extraction of endnotes from paragraphs + def extract_endnotes(para='') + notes=para.scan(/~[{\[]([\d*+]+\s+.+?)\s*<#@dp>[}\]]~/) + @n=[] + notes.each do |n| #high cost to deal with <br> appropriately within manpage, consider + n=n.dup.to_s + if n =~/<br(?: \/)?>/ + fix = n.split(/<br(?: \/)?>/) #watch #added + fix.each do |x| + unless x.empty?; @n << x + end + end + else @n << n + end + end + notes=@n.flatten + notes.each do |e| + util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_text_utils::Wrap.new(e.to_s,78,4,1) + else SiSU_text_utils::Wrap.new(e.to_s,78,0,1) + end + wrap=util.line_wrap + if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m + wrap.gsub!(/(["''])/,"\\\\\\1") # quotation marks need escape + wrap.gsub!(/^\s*([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB +.TP +.BI \\1. +\\2 +GSUB + ) + else + wrap.gsub!(/^(.+)\Z/m, <<GSUB +\\1 +GSUB + ) + end + @@endnotes[:para] << wrap + @@endnotes[:end] << wrap + @@endnotes + end + end + def manpage_metadata(meta) + util=SiSU_text_utils::Wrap.new(meta.text,78,15,1) + txt=util.line_wrap + @manpage[:metadata] <<= if meta.type == 'meta' + <<WOK + +#{@tab}#{meta.el}: #{txt} +WOK + else '' + end + end + def manpage_tail + SiSU_Env::Info_skin.new(@md).select + vz=SiSU_Env::Get_init.instance.skin + generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] + lastdone="Last Generated on: #{Time.now}" + rubyv="Ruby version: #{@md.ruby_version}" + sc=if @md.sc_info + "Source file: #{@md.sc_filename}#{@br}Version number: #{@md.sc_number}#{@br}Version date: #{@md.sc_date}#{@br}" + else '' + end + @manpage[:tail] <<<<WOK +#@br +.TP +Other versions of this document: +.TP +manifest: <#{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:manifest]}> +.TP +html: <#{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:toc]}> +.TP +pdf: <#{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:pdf_p]}> +.TP +pdf: <#{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:pdf_l]}> +.\" .TP +.\" manpage: #{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:manpage]} +.TP +at: <#{vz.url_site}> +.TP +#{sc} +.TP +* #{generator} +.TP +* #{rubyv} +.TP +* #{lastdone} +.TP +* SiSU #{vz.url_sisu} +WOK + end + def manpage_structure(para='',lv='',ocn='',hname='') #% Used to extract the structure of a document + lv=lv.to_i + n=lv - 1 + n3=lv + 2 + lv=nil if lv == 0 + wrapped=if para[@regx] + paragraph=para[@regx,2] + if paragraph =~/<:i([1-9])>/ + m=$1.to_i + paragraph.gsub!(/<:i#{m}>/,'') + util=SiSU_text_utils::Wrap.new(paragraph,78,m*2) + else util=SiSU_text_utils::Wrap.new(paragraph,78,0) + end + util.line_wrap + end + if lv + times=wrapped.length + times=78 if times > 78 + @manpage[:body] << case lv + when 1; '.SH ' << @br << wrapped.upcase << @br << '.BR' + when 2..3; '.SH ' << @br << wrapped.upcase << @br << '.BR' + when 4; '.SH ' << @br << wrapped.upcase << @br << '.BR' + when 5..6; '.SH ' << @br << wrapped.upcase << @br + #when 1; '.SH ' + wrapped.upcase << @br << '.BR' + #when 2..3; '.SH ' + wrapped.upcase << @br << '.BR' + #when 4; '.SH ' + wrapped.upcase << @br << '.BR' + #when 5..6; '.SH ' + wrapped.upcase << @br + ##when 1; '.SH ' + wrapped.upcase << @br << '.TP' << @br # << '*'*times << @br + ##when 2..3; '.SH ' + wrapped.upcase << @br << '.TP' << @br # << '='*times << @br + ##when 4; '.SH ' + wrapped.upcase << @br << '.TP' << @br # << '-'*times << @br + ##when 5..6; '.SH ' + wrapped.upcase << @br << '.TP' << @br # << '.'*times << @br + end + else + ##@manpage[:body] << wrapped << '.TP' # main text, contents, body KEEP + #@manpage[:body] << '.BR' << wrapped # main text, contents, body KEEP [consider s/.BR/.PP/] + + @manpage[:body] << if wrapped =~/^\.BI\s/ # main text, contents, body KEEP + '.TP' << @br << wrapped.gsub!(/^\.BI\s/,'.B ') # sleight ... simpler output + else + '.BR' << @br << wrapped # [consider s/.BR/.PP/] + end + end + if @@endnotes[:para] and @@dostype =~/footnote/ #edit out to switch off endnotes following paragraph to which they belong + @manpage[:body] << @br + @@endnotes[:para].each { |e| @manpage[:body] << e << @br } + elsif @@endnotes[:para] and @@dostype =~/endnote/ + @manpage[:body] << @br*2 + end + @@endnotes[:para]=[] + end + def markup(data) # Used for major markup instructions + dir=SiSU_Env::Info_env.new(@md.fns) + @data_mod,@endnotes,@level,@cont,@copen,@manpage_contents_close=Array.new(6){[]} + (0..6).each { |x| @cont[x]=@level[x]=false } + (4..6).each { |x| @manpage_contents_close[x]='' } + manpage_tail #($1,$2) + table_message='[table omitted, see other document formats]' + fix=[] + data.each do |para| + para.gsub!(/<!Th?¡.+/m,"#@br#{table_message}") + para.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check + para.gsub!(/_\*\s+/,'* ') # bullet markup, marked down + para.gsub!(/<sup>(.+?)<\/sup>/,'^\1^') + para.gsub!(/<sub>(.+?)<\/sub>/,'[\1]') + para.gsub!(/<i>(.+?)<\/i>/,'<:br>.I \1<:br>') + para.gsub!(/\A<b>(.+?)<\/b><br \/>/m,'<:br>.BI \1<:br>') + para.gsub!(/<b>(.+?)<\/b>/,'<:br>.B \1<:br>') + para.gsub!(/<u>(.+?)<\/u>/,'<:br>.I \1<:br>') + unless para =~/<:code>/ + para.gsub!(/(?:^|\s)\{(.+?)\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1 #{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") + para.gsub!(/(^|\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!(/~[{\[]([\d*+]+)\s+(?:.+?)[}\]]~/,'[^\1]') # endnote marker marked up + para.gsub!(/&/,'&') + para.gsub!(/!/,'!') + para.gsub!(/#/,'#') + para.gsub!(/*/,'*') + para.gsub!(/-/,'-') + para.gsub!(///,'/') + para.gsub!(/_/,'_') + para.gsub!(/{/,'{') + para.gsub!(/}/,'}') + para.gsub!(/~/,'~') + para.gsub!(/©/,'©') + end + para.gsub!(/-/,'\-') #manpages use this + para.gsub!(/~/,'~') if para #manpages use this + if para =~/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/ + if para =~/<:code>/ + para.gsub!(/_</,'<'); para.gsub!(/_>/m,'>') #code-block: angle brackets special characters + end + para.gsub!(/<br(?: \/)?>/,"\n\n.P\n\n") # watch + para.gsub!(/<:(?:group|verse|alt)(?:\\-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,'') + para.gsub!(/<:code>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,"\n\n.nf\n\n") + para.gsub!(/<:code\\-end>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,"\n\n.fi\n\n") + else + para.gsub!(/<br(?: \/)?>/,"\n\n") #watch introduces a bug + end + blit=para.scan(/\[[^\]]+\]|[^\[]+/) + blit_array=[] + blit.each do |x| + if x =~/^\[/ + x.gsub!(/\s+/,' \ ') #manpages use this + elsif x =~/\.(?:TP|BI)\s/ + x.gsub!(/\s+/,' \ ') #manpages use this + else x + end + blit_array << x + end + para = blit_array.join + para.gsub!(/\s\\\s+(<:br>|<br(?: \/)?>)/,'\1') #a messy solution + para.gsub!(/\s(\[)/,' \ \1') #manpages use this + para.gsub!(/<:p[bn]>/,'') # remove page breaks + para.gsub!(/^\s*<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'') # remove empty lines - check + para.gsub!(/(^|\s)[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3') + para.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1') + para.gsub!(/<:name#\S+?>/,'') # remove name links + para.gsub!(/ /,' ') # decide on + para.gsub!(/(["''])/,"\\\\\\1") # quotation marks need escape + #para.gsub!(/(["''])/,"\\\\\\1") # decide on + 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"]') + wordlist=para.scan(/\S+/) + if para =~/^0~(\S+)\s+(.+?)\Z/m # for headers + d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta + if d_meta; manpage_metadata(d_meta) + end + end + if para !~/(^0~|<ENDNOTES>|<EOF>)/ + if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change + paranum=para[@regx,3] + @p_num=Format::Paragraph_number.new(paranum) + end + @sto=Split_text_object.new(para).lev_segname_para_ocn + ### problem in scroll, it appears tables are getting paragraph numbers + m=/<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + if para =~m and para=~/\S+/ + para=case @sto.format + when /^(1)~(?:(\S+))?/ + manpage_structure(para,$1,@sto.ocn,$2) + @sto.lev_para_ocn.heading_body1 + when /^(2)~(?:(\S+))?/ + manpage_structure(para,$1,@sto.ocn,$2) + @sto.lev_para_ocn.heading_body2 + when /^(3)~(?:(\S+))?/ + manpage_structure(para,$1,@sto.ocn,$2) + @sto.lev_para_ocn.heading_body3 + when /^(4)~(\S+)/ # work on see SiSU_text_parts::Split_text_object + manpage_structure(para,$1,@sto.ocn,$2) + @sto.lev_para_ocn.heading_body4 + when /^(5)~(?:(\S+))?/ + manpage_structure(para,$1,@sto.ocn,$2) + @sto.lev_para_ocn.heading_body5 + 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 + end + elsif para =~/#{table_message}/ + @manpage[:body] << para << @br + elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(MetaData)/ and para =~/<~(\d+);[um]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info ####suspect visit + #formatMono=MonoSiSU.new('<br /><a name="metadata">MetaData</a>') + #para=formatMono.bold_para + elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + #formatMono=MonoSiSU.new('<br /><a name="owner.details">Owner Details</a>') + #@@manpage[:owner_details]=formatMono.bold_para + #para='' + elsif para =~/(¡|<!Th?)/ #tables ! + 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 /<:i[1-9]>/ + if para =~/.*<:#>.*$/m + format_text=Format_text_object.new(para,'') + 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!(/~/,'~') if para #manpages use this + para.gsub!(/{/,'{') if para #manpages use this + para.gsub!(/<!.+!>/,' ') if para ## Clean Prepared Text + para.gsub!(/<:\S+>/,' ') if para ## Clean Prepared Text + end + end + @manpage + end + def publish(manpage) + divider='=' + content=[] + date=if @md.dc_date; @md.dc_date + else '2007' #date missing decide on action + end + proj=SiSU_Env::Info_version.new.get_version + manpage[:open] = %{.TH "#{@md.fnb}" "1" "#{date}" "#{proj[:version]}" "#{@md.title}"} + content << manpage[:open] + content << manpage[:head] + content << manpage[:body] + content << @@endnotes[:end] if @@dostype =~/endnotes/ + #content << manpage[:metadata] + #content << manpage[:owner_details] if @md.stmp =~/\w+/ #not used? + content << manpage[:tail] + Output.new(content,@md).manpage + @@endnotes[:para],@@endnotes[:end]=[],[] + end + end + class Output <Source + include SiSU_Param + include SiSU_Env + def initialize(content,md) + @content,@md=content,md + end + def manpage #%manpage output + SiSU_Env::SiSU_file.new(@md).mkdir + filename_manpage=SiSU_Env::SiSU_file.new(@md,@md.fn[:manpage]).mkfile_man + @sisu=[] + @content.each do |para| # this is a hack + if para.class == Array and para.length > 0 + para.each do |line| + line.gsub!(/\s+$/m,'') + filename_manpage.puts line #unix manpage + end + else filename_manpage.puts para #unix manpage # /^([*=-]|\.){5}/ + end + end + filename_manpage.close + end + end + end +end +__END__ diff --git a/lib/sisu/v0/manpage_format.rb b/lib/sisu/v0/manpage_format.rb new file mode 100644 index 00000000..20f62fb3 --- /dev/null +++ b/lib/sisu/v0/manpage_format.rb @@ -0,0 +1,108 @@ +=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 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/licenses/gpl.html> + <http://www.gnu.org/copyleft/gpl.html> + <http://www.jus.uio.no/sisu/gpl.fsf> + + * 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: manpage formatting template + +=end +module Format + require "#{SiSU_lib}/param" + include SiSU_Param + include SiSU_Viz + class Paragraph_number + def initialize(paranum) + @paranum=/(\d+)/m.match(paranum)[1] + end + def display + @paranum.gsub(/(\d+)/,'<font size="1" color="#777777"> \1</font>') + end + def name + @paranum.gsub(/(\d+)/,'<a name="\1"></a>') + end + def goto + @paranum.gsub(/(\d+)/,'<a href="#\1">') + end + 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 + rgx=/^[1-6-]~/ + @one.gsub!(rgx,'') if @one =~rgx + @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + rgx=/~\{[\d*+]+\s+(.+?)<#@dp>\}~/ + @one.gsub!(rgx,'\1') if @one =~rgx + @link,@linkname=one,two + @vz=SiSU_Env::Get_init.instance.skin + end + def scr_endnote_body + "<endnote>#@one</endnote> " + end + def heading_body1 + end + def heading_body2 + end + def heading_body3 + end + def heading_body4 + end + def heading_body5 + end + def heading_body6 + end + end + class XML + end +end +__END__ + diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 93a5be52..15b95a3c 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -259,7 +259,7 @@ module SiSU_ODF end def image(para) para.gsub!(@serial,'') - m=para.scan(/(\{\s*(.+?)\}((?:https?|ftp)\S+|image))/) + m=para.scan(/(\{\s*(.+?)\}((?:https?|file|ftp)\S+|image))/) if m; m.each do |i| cont,url=i[1],i[2] cont.gsub!(/([)(\]\[])/,"\\\\\\1") @@ -279,7 +279,7 @@ module SiSU_ODF end def text_link(para) para.gsub!(@serial,'') - m=para.scan(/(\{([^}]+?)\}((?:https?|ftp)\S+?))([;.,]?(?=\s|$))/) #sort + m=para.scan(/(\{([^}]+?)\}((?:https?|file|ftp)\S+?))([;.,]?(?=\s|$))/) #sort if m m.each do |i| txt,url,trail=i[1],i[2] @@ -295,11 +295,11 @@ module SiSU_ODF end def normal(para) #P1 - P3 para.gsub!(@serial,'') - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + 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?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + para.gsub!(/((?:^|\s)[}])((?: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!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + para.gsub!(/(^|\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 @@ -379,7 +379,7 @@ module SiSU_ODF para.split(/<:?br(?: \/)?>/).each do |parablock| parablock=group_clean(parablock) parablock.gsub!(/^\s*$/,'<br />') - parablock.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + parablock.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 parray << %{<text:p text:style-name="P5">#{parablock}</text:p>} if parablock =~/\S+/ end @@ -400,8 +400,8 @@ module SiSU_ODF #extract_endnotes(para) #para=fontface(para) para=unless para=~/^<:code>/ - para=if para =~/\{\s*\S+?\.(?:png|jpg|gif)\s.+?\}(?:(?:https?|ftp):\S+|image)/; image(para) - elsif para =~/\{.+?\}(?:(?:https?|ftp):\S+|image)/; text_link(para) + 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) else para end else para diff --git a/lib/sisu/v0/options.rb b/lib/sisu/v0/options.rb index 1ca771ff..8b014c04 100644 --- a/lib/sisu/v0/options.rb +++ b/lib/sisu/v0/options.rb @@ -94,7 +94,7 @@ module SiSU_commandline end s << " #{y}" unless y.empty? end - s.strip! + s.strip! # String.strip is broken in ruby 1.9.0 (2007-09-10 patchlevel 0) [i486-linux], 2007-09-18:38/2 a=s.split(/\s+/) a.each do |x| if x =~/^-[a-z0-5]+/i or x =~/^--\S+/ @@ -103,7 +103,7 @@ module SiSU_commandline if x =~/^--\S+/; m << x end elsif x =~ /(?:\.(?:[_-]?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|sisupod(?:\.zip)?)$/ - if x =~/^http:\/\/\S+/; f << x + if x =~/^(?:https?|file):\/\/\S+/; f << x elsif FileTest.file?(x); f << x else puts "file not found: #{x}" end diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index f4bf6a3f..446c2d46 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -459,12 +459,12 @@ module SiSU_Param when /^(?:0~links|@links:)\s+(.+?)$/m #% processing doc_links_str=$1 @lnk=[] - if doc_links_str=~/\{.+?\}(?:(?:https?|ftp):\/|\.\.)\/\S+(?:\s|$)/ - doc_links=doc_links_str.scan(/\{.+?\}(?:(?:https?|ftp):\/|\.\.)\/\S+/) + if doc_links_str=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + doc_links=doc_links_str.scan(/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+/) count=1 doc_links.each do |x| @lnk[count]={} - @lnk[count][:say],@lnk[count][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|ftp):\/|\.\.)\/\S+)/im.match(x)[1,2] + @lnk[count][:say],@lnk[count][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(x)[1,2] count +=1 end else @@ -473,7 +473,7 @@ module SiSU_Param count=1 lnks.each do |x| @lnk[count]={} - if x =~/^\s*(?:(?:https?|ftp):\/\/|\.\.\/)/; @lnk[count][:url]=x + if x =~/^\s*(?:(?:https?|file|ftp):\/\/|\.\.\/)/; @lnk[count][:url]=x else @lnk[count][:say]=x count +=1 @@ -536,14 +536,16 @@ module SiSU_Param end end end - case para - when /~\{\s+.+?\}~/ #% processing - en=para.scan(/~\{.+?\}~/) - en.each { |e| @en[:sum] +=1 } - when /~\^(?:\s|$)/ #% processing - mk=para.scan(/~\^(?:\s|$)/) - mk.each { |e| @en[:mark] +=1 } - when /^\^~\s+\S/; @en[:note] +=1 #% processing + unless @code_flag + case para + when /~\{\s+.+?\}~/ #% processing + en=para.scan(/~\{.+?\}~/) + en.each { |e| @en[:sum] +=1 } + when /~\^(?:\s|$)/ #% processing + mk=para.scan(/~\^(?:\s|$)/) + mk.each { |e| @en[:mark] +=1 } + when /^\^~\s+\S/; @en[:note] +=1 #% processing + end end if para =~/~\{|\^~ |~\^|<:ee>/; @flag_auto_endnotes,@flag_endnotes=true,true end diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index ddcf3a42..886e50a2 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -70,12 +70,12 @@ module SiSU_Plaintext class Source def initialize(opt) @opt=opt - if @opt.fns =~/(.+?)\.[_-]?sst$/ - case @opt.cmd - when /[af]/; @@dostype='unix footnotes' - when /e/; @@dostype='unix endnotes' - when /[AF]/; @@dostype='msdos footnotes' - when /E/; @@dostype='msdos endnotes' + @@dostype=if @opt.fns =~/(.+?)\.[_-]?sst$/ + if @opt.mod.inspect =~ /--footnote/ and @opt.mod.inspect =~ /--dos/; 'msdos footnotes' + elsif @opt.mod.inspect =~ /--endnote/ and @opt.mod.inspect =~ /--dos/; 'msdos endnotes' + elsif @opt.mod.inspect =~ /--footnote/; 'unix footnotes' + elsif @opt.mod.inspect =~ /--endnote/; 'unix endnotes' + else 'unix footnotes' end else puts "#{sf} not a processed file type" end @@ -153,36 +153,36 @@ module SiSU_Plaintext require "#{SiSU_lib}/defaults" require "#{SiSU_lib}/shared_txt" include SiSU_text_utils - @@endnotes_para=[] - @@plaintext={ :body=>[],:open=>[],:close=>[],:head=>[],:metadata=>[],:tail=>[],:endnotes=>[] } + @@endnotes={ :para=>[],:end=>[] } @@dp=nil def initialize(data,md) @data,@md=data,md @url_brace=SiSU_Viz::Skin.new.url_decoration @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern - @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #m # 2004w18 pb pn removal added + @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m # 2004w18 pb pn removal added @tab="\t" - @br=case md.cmd - when /[af]/ - @@dostype='unix footnotes' - "\n" - when /e/ - @@dostype='unix endnotes' - "\n" - when /[AF]/ + @br=if md.mod.inspect =~ /--footnote/ and md.mod.inspect =~ /--dos/ @@dostype='msdos footnotes' "\r\n" - when /E/ + elsif md.mod.inspect =~ /--endnote/ and md.mod.inspect =~ /--dos/ @@dostype='msdos endnotes' "\r\n" - else "\n" + elsif md.mod.inspect =~ /--footnote/ + @@dostype='unix footnotes' + "\n" + elsif md.mod.inspect =~ /--endnote/ + @@dostype='unix endnotes' + "\n" + else + @@dostype='unix footnotes' + "\n" end + @plaintext={ :body=>[],:open=>[],:close=>[],:head=>[],:metadata=>[],:tail=>[] } end def songsheet - @data=markup(@data) - publish - #@data.each { |x| puts x.inspect if x =~/\[table/ } + plaintext=markup(@data) + publish(plaintext) end # Used for extraction of endnotes from paragraphs def extract_endnotes(para='') @@ -201,13 +201,12 @@ module SiSU_Plaintext end notes=@n.flatten notes.each do |e| - util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_text_utils::Wrap.new(e.to_s,70,4,1) - else SiSU_text_utils::Wrap.new(e.to_s,70,1,1) + util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_text_utils::Wrap.new(e.to_s,78,4,1) + else SiSU_text_utils::Wrap.new(e.to_s,78,1,1) end wrap=util.line_wrap if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m wrap.gsub!(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB - \\1[\\2]: \\3 GSUB ) @@ -217,14 +216,15 @@ GSUB GSUB ) end - @@plaintext[:endnotes] << wrap - @@endnotes_para << wrap + @@endnotes[:para] << "-#{wrap}" + @@endnotes[:end] << wrap end + @@endnotes end def plaintext_metadata(meta) - util=SiSU_text_utils::Wrap.new(meta.text,70,15,1) + util=SiSU_text_utils::Wrap.new(meta.text,78,15,1) txt=util.line_wrap - @@plaintext[:metadata] <<= if meta.type == 'meta' + @plaintext[:metadata] <<= if meta.type == 'meta' <<WOK #{@tab}#{meta.el}: #{txt} @@ -242,7 +242,7 @@ WOK "Source file: #{@md.sc_filename}#{@br}Version number: #{@md.sc_number}#{@br}Version date: #{@md.sc_date}#{@br}" else '' end - @@plaintext[:tail] <<<<WOK + @plaintext[:tail] <<<<WOK #@br Other versions of this document: #@br manifest: @@ -269,37 +269,35 @@ WOK n=lv - 1 n3=lv + 2 lv=nil if lv == 0 - extract_endnotes(para) - para.gsub!(/~[{\[]([\d*+]+)\s+(?:.+?)[}\]]~/,'[^\1]') # endnote marker marked up wrapped=if para[@regx] paragraph=para[@regx,2] if paragraph =~/<:i([1-9])>/ m=$1.to_i paragraph.gsub!(/<:i#{m}>/,'') - util=SiSU_text_utils::Wrap.new(paragraph,70,m*2) - else util=SiSU_text_utils::Wrap.new(paragraph,70,0) + util=SiSU_text_utils::Wrap.new(paragraph,78,m*2) + else util=SiSU_text_utils::Wrap.new(paragraph,78,0) end util.line_wrap end if lv times=wrapped.length - times=70 if times > 70 - @@plaintext[:body] << case lv + times=78 if times > 78 + @plaintext[:body] << case lv when 1; wrapped.upcase << @br << '*'*times << @br when 2..3; wrapped.upcase << @br << '='*times << @br when 4; wrapped.upcase << @br << '-'*times << @br when 5..6; wrapped.upcase << @br << '.'*times << @br end else - @@plaintext[:body] << wrapped << @br # main text, contents, body KEEP + @plaintext[:body] << wrapped << @br # main text, contents, body KEEP end - if @@endnotes_para and @@dostype =~/footnote/ #edit out to switch off endnotes following paragraph to which they belong - @@plaintext[:body] << @br - @@endnotes_para.each {|e| @@plaintext[:body] << e << @br} - elsif @@endnotes_para and @@dostype =~/endnote/ - @@plaintext[:body] << @br*2 + if @@endnotes[:para] and @@dostype =~/footnote/ #edit out to switch off endnotes following paragraph to which they belong + @plaintext[:body] << @br + @@endnotes[:para].each {|e| @plaintext[:body] << e << @br} + elsif @@endnotes[:para] and @@dostype =~/endnote/ + @plaintext[:body] << @br*2 end - @@endnotes_para=[] + @@endnotes[:para]=[] end def markup(data) # Used for major markup instructions dir=SiSU_Env::Info_env.new(@md.fns) @@ -313,29 +311,44 @@ WOK para.gsub!(/<!Th?¡.+/m,"#@br#{table_message}") para.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check para.gsub!(/_\*\s+/,'* ') # bullet markup, marked down - #para.gsub!(/<br(?: \/)?>/,"\n") # introduces a bug - para.gsub!(/©/,'©') # bullet markup, marked down - para.gsub!(/&/,'&') # bullet markup, marked down para.gsub!(/<sup>(.+?)<\/sup>/,'^\1^') para.gsub!(/<sub>(.+?)<\/sub>/,'[\1]') para.gsub!(/<i>(.+?)<\/i>/,'/\1/') para.gsub!(/<b>(.+?)<\/b>/,'*\1*') para.gsub!(/<u>(.+?)<\/u>/,'_\1_') + unless para =~/<:code>/ + para.gsub!(/\{(.+?)\}((?:https?|file|ftp):\/\/\S+|image)/,'\1 [link:] \2') + para.gsub!(/(^|\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) + para.gsub!(/~[{\[]([\d*+]+)\s+(?:.+?)[}\]]~/,'[^\1]') # endnote marker marked up + para.gsub!(/&/,'&') + para.gsub!(/!/,'!') + para.gsub!(/#/,'#') + para.gsub!(/*/,'*') + para.gsub!(/-/,'-') + para.gsub!(///,'/') + para.gsub!(/_/,'_') + para.gsub!(/{/,'{') + para.gsub!(/}/,'}') + para.gsub!(/~/,'~') + para.gsub!(/©/,'©') + end if para =~/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/ if para =~/<:code>/ para.gsub!(/_</,'<'); para.gsub!(/_>/m,'>') #code-block: angle brackets special characters end para.gsub!(/<br(?: \/)?>/,"\n") # watch para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,'') + else para.gsub!(/<br(?: \/)?>/,"\n\n") # watch introduces a bug end para.gsub!(/<:p[bn]>/,'') # remove page breaks para.gsub!(/^\s*<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'') # remove empty lines - check - para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,"\\1#{@url_brace.txt_open}\\2#{@url_brace.txt_close}\\3") - para.gsub!(/(^|\s)[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3') + para.gsub!(/(^|\s)[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3') 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?|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") + 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"]') wordlist=para.scan(/\S+/) if para =~/^0~(\S+)\s+(.+?)\Z/m # for headers @@ -395,14 +408,14 @@ WOK para end elsif para =~/#{table_message}/ - @@plaintext[:body] << para << @br + @plaintext[:body] << para << @br elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ elsif para =~/(MetaData)/ and para =~/<~(\d+);[um]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info ####suspect visit #formatMono=MonoSiSU.new('<br /><a name="metadata">MetaData</a>') #para=formatMono.bold_para elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #formatMono=MonoSiSU.new('<br /><a name="owner.details">Owner Details</a>') - #@@plaintext[:owner_details]=formatMono.bold_para + #@plaintext[:owner_details]=formatMono.bold_para #para='' elsif para =~/(¡|<!Th?)/ #tables ! elsif para =~/(.*)<!#!>(.*)/ @@ -430,21 +443,22 @@ WOK para.gsub!(/<:\S+>/,' ') if para ## Clean Prepared Text end end + @plaintext end - def publish - divider="=" + def publish(plaintext) + divider='=' content=[] - content << @@plaintext[:open] - content << @@plaintext[:head] - content << @@plaintext[:body] - content << @@plaintext[:endnotes] if @@dostype =~/endnotes/ - content << "#@br#{divider*70}#@br" - content << @@plaintext[:metadata] - content << "#@br#{divider*70}#@br" if @md.stmp =~/\w+/ #not used? - content << @@plaintext[:owner_details] if @md.stmp =~/\w+/ #not used? - content << @@plaintext[:tail] + content << plaintext[:open] + content << plaintext[:head] + content << plaintext[:body] + content << @@endnotes[:end] if @@dostype =~/endnotes/ + content << "#@br#{divider*78}#@br" + content << plaintext[:metadata] + content << "#@br#{divider*78}#@br" if @md.stmp =~/\w+/ #not used? + content << plaintext[:owner_details] if @md.stmp =~/\w+/ #not used? + content << plaintext[:tail] Output.new(content,@md).plaintext - @@plaintext[:head],@@plaintext[:body],@@plaintext[:tail],@@plaintext[:metadata]=[],[],[],[] + @@endnotes[:para],@@endnotes[:end]=[],[] end end class Output <Source @@ -466,8 +480,10 @@ WOK else filename_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ end end + filename_plaintext.close end end end end __END__ +!\|#\|&*\|-\|/\|_\|{\|}\|~\|&# diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index df6b0bcb..f258f0a9 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -87,10 +87,10 @@ module SiSU_Format_Shared def urls(data) @words=[] data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ - if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([;.,](?:\s|$))/ - m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([;.,](?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures + @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 d='' end case m @@ -108,14 +108,14 @@ module SiSU_Format_Shared %{<a href="#{u}">[#{png}]</a>#{caption}} else %{[#{png}] #{caption}} end - word.gsub!(/\{.+?\}((?:https?|ftp)\S+|image)/,ins) + word.gsub!(/\{.+?\}((?: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?|ftp)\S+/,ins) + word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) end word else word @@ -126,15 +126,15 @@ module SiSU_Format_Shared end def markup(para) if para !~/^<:code>/ - if para =~/\{.+?\}((?:http|ftp)\S+|image)/ - wm=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) + 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) end - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|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 + 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)((?: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,'<'); para.gsub!(/_>/m,'>') #code-block: angle brackets special characters end para diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb index ceeaa4ce..6af436b0 100644 --- a/lib/sisu/v0/shared_txt.rb +++ b/lib/sisu/v0/shared_txt.rb @@ -58,6 +58,7 @@ module SiSU_text_utils class Wrap def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil) @para,@n_char_max,@n_indent=para,n_char_max,n_indent + @n_char_max_extend = n_char_max @br="\n" @n_hang=unless n_hang; @n_hang=@n_indent else n_hang @@ -69,21 +70,33 @@ module SiSU_text_utils line=0 out=[] out[line]='' - #line=0,out,out[line]=0,[],'' - #@para.gsub!(/<br(?: \/)?>/,"\n") #watch #added - words=@para.scan(/\S+/) + @para.gsub!(/<:br>/,"\n\n") + words=@para.scan(/\n\n|\S+/m) while words != '' word=words.shift if not word - out[line].strip!.squeeze!(' ') unless out[line].empty? #check + out[line] unless out[line].empty? #check break - elsif (out[line].length + word.length) > (@n_char_max - @n_indent) and out[line] =~/\S+/ - out[line].strip!.squeeze!(' ') + elsif word =~/\n\n/ + word="\n" + @n_char_max_extend = @n_char_max + out[line].length + line=line + elsif (out[line].length + word.length) > (@n_char_max_extend - @n_indent) and out[line] =~/\S+/ + @n_char_max_extend = @n_char_max + out[line].squeeze!(' ') line += 1 end - out[line]="#{out[line]} #{word}" if word + if word + out[line]=if out[line] and out[line] !~/\S+$/m + "#{out[line]}#{word}" + elsif out[line] and out[line] =~/\S+/ + "#{out[line]} #{word}" + else "#{word.strip}" + end + end + @oldword=word if word =~/\S+/ end - out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang) + x=out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang) end def line_wrap_indent1 @n_indent,@n_hang=2,2 @@ -94,8 +107,6 @@ module SiSU_text_utils line_wrap end end -#end -#module SiSU_scan class Header_scan def initialize(md,para) @regxcl=/<~\d+;\w\d+;\w\d+><(?:[0-9a-f]{32}|[0-9a-f]{64}):(?:[0-9a-f]{32}|[0-9a-f]{64})>/ diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 0d9c0476..866939ea 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -363,11 +363,11 @@ module SiSU_XML_munge '\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?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + 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?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/, #also works + #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?|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!(/\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 @@ -384,7 +384,7 @@ module SiSU_XML_munge para.gsub!(/<[-~]#>/,'') para.gsub!(/(^|\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?|ftp):\/\/\S+|image)/, + para.gsub!(/\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, "<image.path>#{@dir.url.images_local}\/\\1</image.path>") para.gsub!(/ /,' ') wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 diff --git a/lib/sisu/v0/sisupod_make.rb b/lib/sisu/v0/sisupod_make.rb index 340371c4..32811f0f 100644 --- a/lib/sisu/v0/sisupod_make.rb +++ b/lib/sisu/v0/sisupod_make.rb @@ -182,17 +182,16 @@ module SiSU_Doc docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')] docskin='skin_sisupod' end - if skin_source and docskin - cp_r(skin_source[:name],"#{docskin_place}/#{docskin}.rb") - #if skin_source[:type] =~/dir/ - # File.symlink("#{docskin_place}/#{docskin}.rb","#{docskin_place}/skin_#{@env.stub_pwd}.rb") - #end - skinfile_array=IO.readlines(skin_source[:name],'') - para_images=[] - skinfile_array.each do |f| #% work area - unless f =~/^%+ / #hmmm - images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image #and FileTest.file?(f.scan(@rgx_rb_image).uniq) - #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool + if skin_source and docskin #imperfect, revisit + unless skin_source[:name].nil? or skin_source[:name].empty? + cp_r(skin_source[:name],"#{docskin_place}/#{docskin}.rb") + skinfile_array=IO.readlines(skin_source[:name],'') + para_images=[] + skinfile_array.each do |f| #% work area + unless f =~/^%+ / #hmmm + images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image #and FileTest.file?(f.scan(@rgx_rb_image).uniq) + #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool + end end end end diff --git a/lib/sisu/v0/spell.rb b/lib/sisu/v0/spell.rb index 6ddddb5d..cc9e99e7 100644 --- a/lib/sisu/v0/spell.rb +++ b/lib/sisu/v0/spell.rb @@ -68,7 +68,7 @@ module Utility end def check @input.each do |data| - data.gsub!(/(http|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!(/<\/?(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 3a6282c4..0bbaa131 100644 --- a/lib/sisu/v0/sst_do_inline_footnotes.rb +++ b/lib/sisu/v0/sst_do_inline_footnotes.rb @@ -461,7 +461,7 @@ module SiSU_Convert_footnotes s=s.gsub(/<del>(.+?)<\/del>/,'DELETED(\1)') # deletions s=s.gsub(/<sup>(\d+)<\/sup>/,'[\1]') s=s.gsub(/(?: \\;)+/,' ') - s=s.gsub(/\{.+?\.(?:png|jpg|gif).+?\}(?:https?|ftp)\\\:\S+ /,' [image] ') # else image names found in search + 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 diff --git a/lib/sisu/v0/sst_to_s_xml_dom.rb b/lib/sisu/v0/sst_to_s_xml_dom.rb index 84f72037..46c2d366 100644 --- a/lib/sisu/v0/sst_to_s_xml_dom.rb +++ b/lib/sisu/v0/sst_to_s_xml_dom.rb @@ -346,7 +346,7 @@ WOK para.gsub!(/<[-~]#>/,'') para.gsub!(/<br\/?>/,'<br />') para.gsub!(/<:pb>\s*/,'') - para.gsub!(/\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|ftp):\/\/\S+|image)/, + para.gsub!(/\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|file|ftp):\/\/\S+|image)/, "<image.path>#{dir.url.images_local}/\\1</image.path>") para.gsub!(/ /,' ') para=SiSU_document_structure::Structure.new(@md,para).structure diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 0f6652b8..15dbeba5 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -450,6 +450,7 @@ module SiSU_Env :index => filename(code,'index','.html'), :odf => filename(code,'opendocument','.odt'), :plain => filename(code,'plain','.txt'), + :manpage => filename(code,@fnb,'.1'), :wiki => filename(code,'wiki','.txt'), :digest => filename(code,'digest','.txt'), :metadata => filename(code,'metadata','.html'), #chk @@ -835,7 +836,7 @@ module SiSU_Env flag=if defined? @rc['search'][type] and defined? @rc['search'][type]['action'] and @rc['search'][type]['flag']==true and - @rc['search'][type]['action'] =~/http:\/\// #and + @rc['search'][type]['action'] =~/https?:\/\// #and #defined? @rc['search'][type]['db'] and @rc['search'][type]['db'] =~/\S+/ # and flag=if promo?[:ad] false @@ -858,7 +859,7 @@ module SiSU_Env flag=if defined? @rc['search'] searches.each do |type| if defined? @rc['search'][type] and - defined? @rc['search'][type]['action'] and @rc['search'][type]['action'] =~/http:\/\// and + defined? @rc['search'][type]['action'] and @rc['search'][type]['action'] =~/https?:\/\// and defined? @rc['search'][type]['db'] and @rc['search'][type]['db'] =~/\S+/ # and flag=if promo?[:ad] false @@ -878,10 +879,10 @@ module SiSU_Env rc=SiSU_Env::Get_init.instance.yamlrc create_form_hyperestraier=if defined? rc['search']['sisu']['flag'] and rc['search']['sisu']['flag']==true and - action and action =~/http:\/\//; true + action and action =~/https?:\/\//; true else false end - create_form_sisu=if action and db and action =~/http:\/\// and db =~/\S+/ + create_form_sisu=if action and db and action =~/https?:\/\// and db =~/\S+/ true elsif widget.search? db=if rc['search']['sisu']['flag']==true and @@ -946,7 +947,7 @@ WOK def search_form_static(action=nil,db=nil) rc=SiSU_Env::Get_init.instance.yamlrc create_form=if rc['search']['sisu']['flag']==true and - action and db and action =~/http:\/\// and db =~/\S+/ + action and db and action =~/https?:\/\// and db =~/\S+/ true elsif widget.search_fixed? db=if rc['search']['sisu']['flag']==true and rc['search']['sisu']['db']=~/\S+/ @@ -993,7 +994,7 @@ WOK def search? flag=if defined? @rc['search'] and defined? @rc['search']['sisu'] and - defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/http:\/\// and + defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/https?:\/\// and defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ flag=if defined? @vz.widget_search and @vz.widget_search == true @@ -1010,7 +1011,7 @@ WOK def search_fixed? flag=if defined? @rc['search'] and defined? @rc['search']['sisu'] and - defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/http:\/\// and + defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/https?:\/\// and defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ flag=if defined? @vz.widget_search and @vz.widget_search == true @@ -1028,7 +1029,7 @@ WOK rc=SiSU_Env::Get_init.instance.yamlrc create_form=if defined? rc['search']['sisu']['flag'] and rc['search']['sisu']['flag']==true and - action and db and action =~/http:\/\// and db =~/\S+/ + action and db and action =~/https?:\/\// and db =~/\S+/ true elsif widget_static.search? and rc['search']['sisu']['flag']==true db=if rc['search']['sisu']['db']=~/\S+/ @@ -1081,7 +1082,6 @@ WOK def path #dir def home @sys.home - #@home end def pwd @sys.pwd @@ -1132,7 +1132,7 @@ WOK end @yamlrc_dir end - def man + def man #check use if defined? @rc['webserv']['man']; "#{webserv}/#{@rc['webserv']['man']}" else defaults[:webserv_man] end @@ -1178,6 +1178,9 @@ WOK def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names "#{path.webserv}/#@stub_pwd" end + def manpage + "#{path.output}/man" + end def sitemaps "#{path.output}/sitemaps" end @@ -1324,7 +1327,7 @@ WOK "http://#{hostname}/#@stub_pwd" end def root - if defined? @rc['webserv']['url_root'] and @rc['webserv']['url_root'] =~/http:\/\//; "#{@rc['webserv']['url_root']}/#@stub_pwd" + if defined? @rc['webserv']['url_root'] and @rc['webserv']['url_root'] =~/https?:\/\//; "#{@rc['webserv']['url_root']}/#@stub_pwd" elsif defined? @rc['webserv']['url_root'] and @rc['webserv']['url_root'] =~/localhost/; "http://localhost/#@stub_pwd" else "file://#{path.output}" end @@ -1335,8 +1338,8 @@ WOK def webserv_host_base if defined? @rc['webserv']['host'] case @rc['webserv']['host'] - when /http:\/\//; @rc['webserv']['host'] - when /\S+/; "http://#{@rc['webserv']['host']}" + when /https?:\/\//; @rc['webserv']['host'] + when /\S+/; "http://#{@rc['webserv']['host']}" else defaults[:webserv_host_cgi] end else defaults[:webserv_host_cgi] @@ -1374,13 +1377,13 @@ WOK end def webserv_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] and not @rc['webserv_cgi']['host'].nil? - http=@rc['webserv_cgi']['host'] =~ /http:\/\// ? '' : 'http://' + http=@rc['webserv_cgi']['host'] =~ /https?:\/\// ? '' : 'http://' #check https? missing if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#@stub_pwd" else "#{http}#{@rc['webserv_cgi']['host']}/#@stub_pwd" end else - http=webserv_host_base=~/http:\/\// ? '' : 'http://' + http=webserv_host_base=~/https?:\/\// ? '' : 'http://' if webserv_port_cgi "#{http}#{webserv_host_base}:#{webserv_port_cgi}/#@stub_pwd" else "#{http}#{webserv_host_base}/#@stub_pwd" @@ -1389,13 +1392,13 @@ WOK end def webserv_base_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] and not @rc['webserv_cgi']['host'].nil? - http=@rc['webserv_cgi']['host'] =~ /http:\/\// ? '' : 'http://' + http=@rc['webserv_cgi']['host'] =~ /https?:\/\// ? '' : 'http://' if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" else "#{http}#{@rc['webserv_cgi']['host']}" end else - http=webserv_host_base=~/http:\/\// ? '' : 'http://' + http=webserv_host_base=~/https?:\/\// ? '' : 'http://' if webserv_port_cgi "#{http}#{webserv_host_base}:#{webserv_port_cgi}" else "#{http}#{webserv_host_base}" @@ -1407,13 +1410,14 @@ WOK if defined? @rc['webserv_cgi']['host'] and not @rc['webserv_cgi']['host'].nil? http=if @rc['webserv_cgi']['host'] =~/http:\/\// 'http://' + elsif @rc['webserv_cgi']['host'] =~/https:\/\// + 'https://' else defaults end "#{http}#{@rc['webserv_cgi']['host']}" elsif webserv_host_base and not webserv_host_base.nil? "#{http}#{webserv_host_base}" - else "#{http}localhost" - end + else "#{http}localhost" end end def webserv #web url for local webserv (localhost, or hostname) if path.webserv_dir and path.webserv =~ /#{path.webserv_dir}/ #revisit @@ -1438,7 +1442,7 @@ WOK case @rc['webserv_cgi']['file_links'] when /webserv_cgi/; url.webserv_base_cgi when /webserv/; @rc['webserv']['url_root'] - when /http:\/\//; @rc['webserv_cgi']['file_links'] + when /https?:\/\//; @rc['webserv_cgi']['file_links'] when /\S+/; "http://#{@rc['webserv_cgi']['file_links']}" else webserv_base_cgi end @@ -1811,7 +1815,7 @@ WOK if @opt.cmd =~/m/; @md=SiSU_Param::Parameters.new(@opt).get end ft=[] - if @md and defined? @md.fn and @md.fn # used for multilingual + if @md and defined? @md.fn and @md.fn # used for multilingual if @md.cmd =~ /[hH]/; ft << @md.fn[:html] end if @md.cmd =~ /w/ and @md.cmd !~ /[hH]/; ft << @md.fn[:concordance] @@ -1826,7 +1830,9 @@ WOK end if @md.cmd =~ /b/; ft << @md.fn[:xhtml] end - if @md.cmd =~ /[aAeE]/; ft << @md.fn[:plain] + if @md.cmd =~ /a/; ft << @md.fn[:plain] + end + if @md.cmd =~ /i/; ft << @md.fn[:manpage] end if @md.cmd =~ /[g]/; ft << @md.fn[:wiki] end @@ -1856,7 +1862,9 @@ WOK end if @opt.cmd =~ /b/; ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' end - if @opt.cmd =~ /[aAeE]/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' + end + if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' end if @opt.cmd =~ /[g]/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' end @@ -1960,14 +1968,13 @@ WOK remote=remote_host_base_general #host_ip=IPSocket.getaddress(remote[:host]) unless remote[:host].empty? @@flag_remote=true if remote[:name] =~/\S+@\S+/ #and host_ip =~/\d+\.\d+\.\d+\.\d+/ #very naive check should be enough /[0-255]+\.[0-255]+\.[0-255]+\.[0-255]+/ - #remote[:name] remote_host_base_general[:name] end def scp #sort out later using ruby libraries #not ideal, first time each file is sent, -r must be called separately for subdir to be built input=@local_sisu_source output=case @opt.cmd when /u/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/." #creates remote directory tree, this is not the usual function of u - when /[aAbeEhHNopwxXy]/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/#{@fnb}/." + when /[abhHNopwxXy]/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/#{@fnb}/." else "#{self.remote_host_base}/#{@env.path.stub_pwd}/." end if (input =~/\S/ and input !~/\/\//) and (output =~/\S/ and output !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ @@ -2251,7 +2258,7 @@ WOK 'docbook.css' end def homepage - 'index.css' + 'homepage.css' end end class CSS_select < Info_env @@ -2377,6 +2384,12 @@ WOK filename=@fno file=make_file(path,filename) end + def mkfile_man + path="#{@env.path.output}/man" + make_path(path) + filename=@fno + file=make_file(path,filename) + end def mkfile_pwd path=Dir.pwd filename=@fno @@ -2505,8 +2518,8 @@ WOK end filename_homepage=File.new("#{@env.path.webserv}/#{@env.path.stub_pwd}/index.html",'w') filename_homepage_toc=File.new("#{@env.path.webserv}/#{@env.path.stub_pwd}/toc.html",'w') - filename_homepage << @vz_home.index - filename_homepage_toc << @vz_home.index + filename_homepage << @vz_home.homepage + filename_homepage_toc << @vz_home.homepage end end def cp_images(src_path,dest_path) @@ -2595,3 +2608,4 @@ module SiSU_Errors require "#{SiSU_lib}/errors" end __END__ +https? intro check 2007-09-22 diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index 6c47ae4c..18415c47 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -164,7 +164,7 @@ module SiSU_TexInfo @@flag['tables']='y' # KLUDGE get from param end para.gsub!(/<:p[bn]>/,'') - para.gsub!(/(^|\s)\{(.+?)\}(http:\/\/\S+)/,'\1(\2 [linked to:] \3)') + para.gsub!(/(^|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') do_mono=TexInfoFormat::Texinfo.new(para,@md) @tex_file << do_mono.spec_char end diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index e4803d87..57bca409 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -330,7 +330,7 @@ WOK #if @para !~ /^\s*<:image|\}:image\s/ # @para.gsub!(/_/,'\_') #end - @para.gsub!(/_(http:\/\/)/,'\1') + @para.gsub!(/_(https?:\/\/)/,'\1') @para.gsub!(/§/i,'\S') @para.gsub!(/£/i,'\pounds') @para.gsub!(/å/i,'\aa') @@ -464,7 +464,7 @@ WOK width="100" width=@para[/<:image.+?width=``(\d+)''.+?>/im,1] width=width.to_i*0.4 - @para.gsub!(/<:image\s+((?:https?|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, + @para.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, "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\1}") @@ -478,8 +478,8 @@ WOK end def http # very messy clean up ! - work area, testing - z=@para[/\\\{(.+?)\}(?:https?|ftp):\/\//,1] # match operator for z \\ fragile ! - url=@para[/((?:https?|ftp):\S+)/im,1] + z=@para[/\\\{(.+?)\}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! + url=@para[/((?:https?|file|ftp):\S+)/im,1] if @para =~/\.(png|jpg|gif)/ image,w,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') @@ -492,11 +492,11 @@ WOK end if image dir=SiSU_Env::Info_env.new(@md.fns) - @para.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+/, # fragile match operator\\ fragile ! + @para.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?: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?|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! + @para.gsub!(/\{.+?\}(?: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 ccde6687..31447aae 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -487,7 +487,7 @@ WOK @tex_file << insert.flatten end else - if para =~ /\}(?:https?|ftp)/ + if para =~ /\}(?:https?|file|ftp)/ para=mono.http(@orientation) end case para diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index d86c053a..83fd90a1 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -498,11 +498,11 @@ WOK @string.gsub!(/&\S+?;/,' ') @string.gsub!(/<a href=".+?">/,' ') @string.gsub!(/<\/a>/,' ') - @string.gsub!(/[^\}>_]((?:https?|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case - @string.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - @string.gsub!(/\B(?:\\_|\\)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + @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 unless @@flag_code - @string.gsub!(/(^|\s)((?:https?|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!(/(^|\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 else #code-block: angle brackets special characters, note _ already escaped @string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}') @string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') @@ -724,7 +724,7 @@ WOK 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?|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! + @string.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! end end def image @@ -744,7 +744,7 @@ WOK nil end if image_source - @string.gsub!(/<:image\s+((?:https?|ftp)\S+)\s+(\S+)\s+.+\s+?>/, + @string.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/, @center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end ) @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/, @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) @@ -794,15 +794,15 @@ WOK dir=SiSU_Env::Info_env.new(@md.fns) @words=[] @string.each do |word| - @words << if word=~/\\\{.+?\\\}(?:https?|ftp):\S+/ - if word =~/\\\{(.+?)\\\}((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/ - r=%r/\\\{(.+?)\\?\}((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ - d=/\\\{.+?\\?\}(?:https?|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.to_s -# if word =~/\\\{(.+?)\\\}((?:https?|ftp)\S+?)([;.,]?(?:\s|$))/ -# r=%r/\\\{(.+?)\\?\}((?:https?|ftp):\S+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ -# d=/\\\{.+?\\?\}(?:https?|ftp):\S+?([;.,]?(?:\s|$))/.match(word).captures.to_s + @words << if word=~/\\\{.+?\\\}(?:https?|file|ftp):\S+/ + 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?|ftp):\S+)/ + r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ d='' end z,url=r.match(word).captures if word =~r @@ -845,29 +845,29 @@ WOK "{\\includegraphics*[width=#{width}pt]" + "{#{dir.path.image_source_local_tex}/#{image}}}" + "#{caption}" + - @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+)/ + @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") @center_begin + "\\\n\\href{#{url}}" + #not satisfactory: \\ added to ^line to mimic reference file output "{\\includegraphics*[width=#{width}pt]" + "{#{dir.path.image_source_remote_tex}/#{image}}}" + "#{caption}" + - @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+)/ + @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}") @center_begin + "\\\n\\href{#{url}}\n" + #not satisfactory: \\ added to ^line to mimic reference file output, mirror above ... not tested "{\\includegraphics*[width=#{width}pt]" + "{#{dir.path.image_source_tex}/#{image}}}" + "#{caption}" + - @center_end if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+)/ + @center_end if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ 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/ - '' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+/ + '' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/ end else link=z.strip #[/(.+?)\\/m,1] - word="\\href{#{url}}{#{link}}#{d}" if word =~/\\\{.+?\\\}(?:https?|ftp):\/\/\S+/ + word="\\href{#{url}}{#{link}}#{d}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/ end else word end @@ -875,7 +875,7 @@ WOK @words.join end def http(orientation) - wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|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) #first match of interest others passed through @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm).http_word_mode(orientation) end def language diff --git a/lib/sisu/v0/urls.rb b/lib/sisu/v0/urls.rb index 09b15f2d..2a69040a 100644 --- a/lib/sisu/v0/urls.rb +++ b/lib/sisu/v0/urls.rb @@ -113,6 +113,7 @@ module SiSU_urls 'h (HTML scroll)'=>@fn[:doc], 'H (HTML scroll)'=>@fn[:doc], 'I (Info file)'=>'info', + 'i (manpage)'=>'manpage', 'm (Document Abstraction)'=>'dal', 'N (Digests md5/sha256)'=>@fn[:digest], 'o (ODF:ODT - Open Document)'=>@fn[:odf], @@ -137,7 +138,7 @@ module SiSU_urls end end def urls_maintenance(opt,x,y) - if x=~/^([aAbceEhHmNopwxXy])/ and opt.cmd =~/[aAbceEhHmNopwxXy]/ and x=~/^[#{opt.cmd}]/ + if x=~/^([abchHmNopwxXy])/ and opt.cmd =~/[abchHmNopwxXy]/ and x=~/^[#{opt.cmd}]/ m=$1 f=y tool=@editor @@ -164,6 +165,9 @@ module SiSU_urls if x=~/^o/ and @opt.cmd=~/o/ and x=~/^[#{@opt.cmd}]/ tool=@odf_viewer end + #if x=~/^i/ and @opt.cmd=~/i/ and x=~/^[#{@opt.cmd}]/ + # + #end if x !~/^m/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{tool} #{@env.path.output}/#@fnb/#{y}") tell.maintenance unless @opt.cmd =~/q/ @@ -180,7 +184,7 @@ module SiSU_urls @pwd_stub="#@webserv_url"[m,1] @u.each do |x,y| if @opt.fns =~ @m_regular - if x=~/^([aAbceEhHNopsSwxXyY])/ and @opt.cmd=~/[aAbceEhHNopsSwxXyY]/ and x=~/^[#{@opt.cmd}]/ + if x=~/^([abchHNopsSwxXyY])/ and @opt.cmd=~/[abchHNopsSwxXyY]/ and x=~/^[#{@opt.cmd}]/ m=$1 tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@browser #@webserv_url/#@fnb/#{y}") tell.result unless @opt.cmd =~/q/ @@ -201,6 +205,11 @@ module SiSU_urls tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/d[iu]/,'') end + if x=~/^i/ and @opt.cmd =~/i/ + tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","nroff -man #{@path.path.manpage}/#@fnb.1 |most") + tell.result unless @opt.cmd =~/q/ + @opt.cmd.gsub!(/I/,'') + end if x=~/^P/ and @opt.cmd =~/P/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} Psql","#@pwd_stub::#{@opt.fns}",y) tell.result unless @opt.cmd =~/q/ @@ -219,7 +228,7 @@ module SiSU_urls tell=case x when /^m/ SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@env.program.text_editor} ~#{y}/#@fnb.#{y}") - when /^[aAbBcdeEhHNopswxXy]/ + when /^[abBcdhHNopswxXy]/ tellx=SiSU_Screen::Ansi.new(@opt.cmd,"-p (LaTeX)","#{@env.program.text_editor} ~work/tex_rz/#@fnb.tex") if y=~/landscape/ SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@browser #@webserv_url/#@fnb/#{y}") when /^Y/ diff --git a/lib/sisu/v0/wikispeak.rb b/lib/sisu/v0/wikispeak.rb index bcc2da04..a0ca2cd5 100644 --- a/lib/sisu/v0/wikispeak.rb +++ b/lib/sisu/v0/wikispeak.rb @@ -249,15 +249,15 @@ WOK para.gsub!(/<i>(.+?)<\/i>/,"''\\1''") para.gsub!(/<b>(.+?)<\/b>/,"'''\\1'''") para.gsub!(/<u>(.+?)<\/u>/,'_\1_') - para.gsub!(/\{(.+?)\}(http:\/\/\S+)/,'[\2 \1]') - para.gsub!(/(http:\/\/\S+)/,'[\1]') + para.gsub!(/\{(.+?)\}(https?:\/\/\S+)/,'[\2 \1]') + para.gsub!(/(https?:\/\/\S+)/,'[\1]') para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,'') para.gsub!(/<:p[bn]>/,'') # remove page breaks para.gsub!(/^\s*<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'') # 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?|ftp):\/\/\S+|image)/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") + 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"]') wordlist=para.scan(/\S+/) if para =~/^0~(\S+)\s+(.+?)\Z/m # for headers |