aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/shared_txt.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-09-23 05:16:21 +0100
committerRalph Amissah <ralph@amissah.com>2007-09-23 05:16:21 +0100
commit50d45c6deb0afd2e4222d2e33a45487a9d1fa676 (patch)
tree100c62d678f009139999bf77c26c81653a721eeb /lib/sisu/v0/shared_txt.rb
parentsisu-0.58.3 + md5s (diff)
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
Diffstat (limited to 'lib/sisu/v0/shared_txt.rb')
-rw-r--r--lib/sisu/v0/shared_txt.rb31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb
index ceeaa4ce..6af436b0 100644
--- a/lib/sisu/v0/shared_txt.rb
+++ b/lib/sisu/v0/shared_txt.rb
@@ -58,6 +58,7 @@ module SiSU_text_utils
class Wrap
def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil)
@para,@n_char_max,@n_indent=para,n_char_max,n_indent
+ @n_char_max_extend = n_char_max
@br="\n"
@n_hang=unless n_hang; @n_hang=@n_indent
else n_hang
@@ -69,21 +70,33 @@ module SiSU_text_utils
line=0
out=[]
out[line]=''
- #line=0,out,out[line]=0,[],''
- #@para.gsub!(/<br(?: \/)?>/,"\n") #watch #added
- words=@para.scan(/\S+/)
+ @para.gsub!(/<:br>/,"\n\n")
+ words=@para.scan(/\n\n|\S+/m)
while words != ''
word=words.shift
if not word
- out[line].strip!.squeeze!(' ') unless out[line].empty? #check
+ out[line] unless out[line].empty? #check
break
- elsif (out[line].length + word.length) > (@n_char_max - @n_indent) and out[line] =~/\S+/
- out[line].strip!.squeeze!(' ')
+ elsif word =~/\n\n/
+ word="\n"
+ @n_char_max_extend = @n_char_max + out[line].length
+ line=line
+ elsif (out[line].length + word.length) > (@n_char_max_extend - @n_indent) and out[line] =~/\S+/
+ @n_char_max_extend = @n_char_max
+ out[line].squeeze!(' ')
line += 1
end
- out[line]="#{out[line]} #{word}" if word
+ if word
+ out[line]=if out[line] and out[line] !~/\S+$/m
+ "#{out[line]}#{word}"
+ elsif out[line] and out[line] =~/\S+/
+ "#{out[line]} #{word}"
+ else "#{word.strip}"
+ end
+ end
+ @oldword=word if word =~/\S+/
end
- out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang)
+ x=out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang)
end
def line_wrap_indent1
@n_indent,@n_hang=2,2
@@ -94,8 +107,6 @@ module SiSU_text_utils
line_wrap
end
end
-#end
-#module SiSU_scan
class Header_scan
def initialize(md,para)
@regxcl=/<~\d+;\w\d+;\w\d+><(?:[0-9a-f]{32}|[0-9a-f]{64}):(?:[0-9a-f]{32}|[0-9a-f]{64})>/