From 50d45c6deb0afd2e4222d2e33a45487a9d1fa676 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 23 Sep 2007 05:16:21 +0100 Subject: primarily todo with sisu documentation, changelog reproduced below: * start documenting sisu using sisu * sisu markup source files in data/doc/sisu/sisu_markup_samples/sisu_manual/ /usr/share/doc/sisu/sisu_markup_samples/sisu_manual/ * default output [sisu -3] in data/doc/manuals_generated/sisu_manual/ /usr/share/doc/manuals_generated/sisu_manual/ (adds substantially to the size of sisu package!) * help related edits * manpage, work on ability to generate manpages, improved * param, exclude footnote mark count when occurs within code block * plaintext changes made * shared_txt, line wrap visited * file:// link option introduced (in addition to existing https?:// and ftp://) a bit arbitrarily, diff here, [double check changes in sysenv and hub] * minor adjustments * html url match refinement * css added tiny_center * plaintext * endnotes fix * footnote adjustment to make more easily distinguishable from substantive text * flag -a only [flags -A -e -E dropped] controlled by modifiers --unix/msdos --footnote/endnote * defaults, homepage * renamed homepage (instead of index) implications for modifying skins, which need likewise to have any homepage entry renamed * added link to sisu_manual in homepage * css the css for the default homepage is renamed homepage.css (instead of index.css) [consider removing this and relying on html.css] * ruby version < ruby1.9 * place stop on installation and working with for now [ruby String.strip broken in ruby 1.9.0 (2007-09-10 patchlevel 0) [i486-linux], 2007-09-18:38/2] * debian/control restrict use to ruby > 1.8.4 and ruby < 1.9 * debian * debian/control restrict use to ruby > 1.8.4 and ruby < 1.9 * sisu-doc new sub-package for sisu documentation debian/control and sisu-doc.install --- lib/sisu/v0/composite.rb | 6 +- lib/sisu/v0/concordance.rb | 4 +- lib/sisu/v0/css.rb | 9 + lib/sisu/v0/dal.rb | 11 +- lib/sisu/v0/dal_doc_str_code.rb | 2 +- lib/sisu/v0/dal_syntax.rb | 8 +- lib/sisu/v0/db_import.rb | 4 +- lib/sisu/v0/defaults.rb | 12 +- lib/sisu/v0/digests.rb | 4 +- lib/sisu/v0/help.rb | 69 +++-- lib/sisu/v0/html_tune.rb | 22 +- lib/sisu/v0/hub.rb | 25 +- lib/sisu/v0/manpage.rb | 519 +++++++++++++++++++++++++++++++++ lib/sisu/v0/manpage_format.rb | 108 +++++++ lib/sisu/v0/odf.rb | 16 +- lib/sisu/v0/options.rb | 4 +- lib/sisu/v0/param.rb | 26 +- lib/sisu/v0/plaintext.rb | 142 +++++---- lib/sisu/v0/shared_html_lite.rb | 22 +- lib/sisu/v0/shared_txt.rb | 31 +- lib/sisu/v0/shared_xml.rb | 8 +- lib/sisu/v0/sisupod_make.rb | 21 +- lib/sisu/v0/spell.rb | 2 +- lib/sisu/v0/sst_do_inline_footnotes.rb | 2 +- lib/sisu/v0/sst_to_s_xml_dom.rb | 2 +- lib/sisu/v0/sysenv.rb | 70 +++-- lib/sisu/v0/texinfo.rb | 2 +- lib/sisu/v0/texinfo_format.rb | 12 +- lib/sisu/v0/texpdf.rb | 2 +- lib/sisu/v0/texpdf_format.rb | 40 +-- lib/sisu/v0/urls.rb | 15 +- lib/sisu/v0/wikispeak.rb | 6 +- 32 files changed, 972 insertions(+), 254 deletions(-) create mode 100644 lib/sisu/v0/manpage.rb create mode 100644 lib/sisu/v0/manpage_format.rb (limited to 'lib') 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{(?:(?:[a-zA-Z0-9"\s]){2,7}|(?:[a-zA-Z0-9"\s]){2,7}|http://\S+)|code\{.+?\}code|<\S+?>|\w+}mi + @rgx_scanlist=%r{(?:(?:[a-zA-Z0-9"\s]){2,7}|(?:[a-zA-Z0-9"\s]){2,7}|(?: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},
\\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!(//,'<:\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 line.gsub!(/^([56]~)(\S+)(.+)/,'\1\2 \3 <:name#\2>') #html name marker , 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>/,'
') #xml requires # depreciated --> line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)e\{(.+?)\}e/,'\1\2') #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 - %{ } + %{ } 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. WOK end - def index + def homepage < @@ -1550,6 +1550,14 @@ outputs include: plaintext, html, XHTML, XML, ODF (OpenDocument), LaTeX, PDF, SQ

---

+

+ + SiSU Manual + +

+

+ --- +

What does SiSU do? Summary 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 <require#{@cX.off} - #{@cX.green}<< #{@cX.off} + #{@cX.green}require#{@cX.off} + #{@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 %{#{caption}} else %{#{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=%{#{link}#{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+>/, %{}) 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)/,'<\1>\2') end - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration + para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration + para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url + para.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration if (para =~/..\/\S+/ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/) para.gsub!(/(\.\.\/\S+)/,'\1') 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** 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 ).+?<~(\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 [],: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
appropriately within manpage, consider + n=n.dup.to_s + if n =~// + fix = n.split(//) #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, < +.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!(//,'') # remove dummy headings (used by html) #check + para.gsub!(/_\*\s+/,'* ') # bullet markup, marked down + para.gsub!(/(.+?)<\/sup>/,'^\1^') + para.gsub!(/(.+?)<\/sub>/,'[\1]') + para.gsub!(/(.+?)<\/i>/,'<:br>.I \1<:br>') + para.gsub!(/\A(.+?)<\/b>
/m,'<:br>.BI \1<:br>') + para.gsub!(/(.+?)<\/b>/,'<:br>.B \1<:br>') + para.gsub!(/(.+?)<\/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!(/_/m,'>') #code-block: angle brackets special characters + end + para.gsub!(//,"\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!(//,"\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>|)/,'\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>/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~||)/ + 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!(/(.+)/, + # %{

(\\1)
}) + # para=@sto[:lev_para_ocn].scrPara + #when /^(b|bold)$/ + # para.gsub!(/(.+)/, + # %{(\\1)}) + # 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('
MetaData') + #para=formatMono.bold_para + elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + #formatMono=MonoSiSU.new('
Owner Details') + #@@manpage[:owner_details]=formatMono.bold_para + #para='' + elsif para =~/(¡|(.*)/ + one,two=$1,$2 + format_text=Format_text_object.new(one,two) + para=format_text.seg_no_paranum + end + para='' if (para =~// and para =~/^(-\{{2}~\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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** 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+)/,'  \1') + end + def name + @paranum.gsub(/(\d+)/,'') + end + def goto + @paranum.gsub(/(\d+)/,'') + 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 + "#@one " + 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|$))/, %{\\1\\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\2\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}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration #para.gsub!(/\b((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, also works #%{#{@url_brace.xml_open}\\1#{@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*$/,'
') - parablock.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + parablock.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, %{\\1\\2}) #http ftp matches escaped, no decoration parray << %{#{parablock}} 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, </ 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!(//,'') # remove dummy headings (used by html) #check para.gsub!(/_\*\s+/,'* ') # bullet markup, marked down - #para.gsub!(//,"\n") # introduces a bug - para.gsub!(/©/,'©') # bullet markup, marked down - para.gsub!(/&/,'&') # bullet markup, marked down para.gsub!(/(.+?)<\/sup>/,'^\1^') para.gsub!(/(.+?)<\/sub>/,'[\1]') para.gsub!(/(.+?)<\/i>/,'/\1/') para.gsub!(/(.+?)<\/b>/,'*\1*') para.gsub!(/(.+?)<\/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!(/_/m,'>') #code-block: angle brackets special characters end para.gsub!(//,"\n") # watch para.gsub!(/<:(?:group|verse|alt|code)(?:-end)?>(?:\s+<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>)?/,'') + else para.gsub!(//,"\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>/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('
MetaData') #para=formatMono.bold_para elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #formatMono=MonoSiSU.new('
Owner Details') - #@@plaintext[:owner_details]=formatMono.bold_para + #@plaintext[:owner_details]=formatMono.bold_para #para='' 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 [#{png}]#{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=%{#{link}#{d}} #ins=%{#{link} [link]#{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|$))/,'\1\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url - para.gsub!(/(^|\s)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration + para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration + para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url + para.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration else 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!(//,"\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\2\4') #watch, compare html_tune #para.gsub!(/\B\{([^}]+)\}(https?:\/\/[^"><]+?)([,.:;"><]?(?:\s|$))/, # '\1\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}\\2#{@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}\\1#{@url_brace.xml_close}\\2}) - para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #escaped urls not linked, deal with later + para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #escaped urls not linked, deal with later #para.gsub!(/(^|\s)[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([.,]?(?:\s|$))/,'\1\2\3') #escaped urls not linked, deal with later para.gsub!(/ /,' ') #clean else para.gsub!(/_/m,'>') #code-block: angle brackets special characters @@ -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)/, "#{@dir.url.images_local}\/\\1") 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>/,'DELETED(\1)') # deletions s=s.gsub(/(\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!(//,'
') 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)/, "#{dir.url.images_local}/\\1") 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!(//,' ') @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 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 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}{>}}') @@ -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>/,"''\\1''") para.gsub!(/(.+?)<\/b>/,"'''\\1'''") para.gsub!(/(.+?)<\/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>/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 -- cgit v1.2.3