Hi Ara,
I was actually working on another machine where I had to install tagz.
I noticed this morning when I was trying to do a line-by-line
comparison, that this machine had 5.0.1 instead of 5.0.0. It appears
that the behavior is fixed by the change between 5.0.0 and 5.0.1.
Given this, I’ve re-patched 5.0.1 with the PI support (if anyone else
cares), and included it below.
$ ruby a.rb
hello
worldhello
world
Cheers,
ast
$ diff -u /usr/lib/ruby/gems/1.8/gems/tagz-5.0.1/lib/tagz.rb
tagz-local.rb
— /usr/lib/ruby/gems/1.8/gems/tagz-5.0.1/lib/tagz.rb 2009-03-28
04:08:17.000000000 +0000
+++ tagz-local.rb 2009-03-28 08:57:43.000000000 +0000
@@ -5,7 +5,7 @@
Tagz::VERSION = [
Tagz::VERSION_MAJOR = 5,
Tagz::VERSION_MINOR = 0,
-
Tagz::VERSION_TEENY = 1
-
endTagz::VERSION_TEENY = 0 ].join('.') def Tagz.version() Tagz::VERSION end
@@ -15,27 +15,7 @@open_tag
def tagz__ name, *argv, &block
-
options = argv.last.is_a?(Hash) ? argv.pop : {} -
content = argv -
unless options.empty? -
attributes = ' ' << -
options.map do |key, value| -
key = XChar.escape key.to_s -
value = XChar.escape value.to_s -
if value =~ %r/"/ -
raise ArgumentError, value if value =~ %r/'/ -
value = "'#{ value }'" -
else -
raise ArgumentError, value if value =~ %r/"/ -
value = "\"#{ value }\"" -
end -
[key, value].join('=') -
end.join(' ') -
else -
attributes = '' -
end
-
attributes, content = process_attributes *argv, &block tagz.concat "<#{ name }#{ attributes }>" if content.empty?
@@ -53,7 +33,6 @@
tagz << value.to_s unless(tagz.size > size)
tagz.concat “</#{ name }>”
end
end
else
tagz << content.join
@@ -74,6 +53,13 @@
tagz.concat “</#{ tag }>”
end
-
processing instruction
- def tagz_? name, *argv, &block
-
attributes, content = process_attributes *argv, &block -
tagz.concat "<?#{ name }#{ attributes }?>" - end
-
access tagz doc and enclose tagz operations
def tagz document = nil, &block
@@ -100,6 +86,8 @@
def method_missing m, *a, &b
strategy =
case m.to_s -
when %r/^(.*[^?])_\?$/o -
:processing_instruction when %r/^(.*[^_])_(!)?$/o :open_tag when %r/^_([^_].*)$/o
@@ -125,6 +113,9 @@
m, bang = $1, $2
b ||= lambda{} if bang
tagz{ tagz__(m, *a, &b) }
-
when :processing_instruction -
m = $1 -
tagz{ tagz_?(m, *a, &b) } when :close_tag m = $1 tagz{ __tagz(m, *a, &b) }
@@ -141,6 +132,33 @@
end
end
- def process_attributes *argv, &block
-
options = argv.last.is_a?(Hash) ? argv.pop : {} -
content = argv -
attributes = nil -
unless options.empty? -
attributes = ' ' << -
options.map do |key, value| -
key = XChar.escape key.to_s -
value = XChar.escape value.to_s -
if value =~ %r/"/ -
raise ArgumentError, value if value =~ %r/'/ -
value = "'#{ value }'" -
else -
raise ArgumentError, value if value =~ %r/"/ -
value = "\"#{ value }\"" -
end -
[key, value].join('=') -
end.join(' ') -
else -
attributes = '' -
end -
[ attributes, content ] - end
- class Document < ::String
def Document.for other
Document === other ? other : Document.new(other.to_s)