aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-06-14 10:30:36 +0000
committerJamis Buck <jamis@37signals.com>2005-06-14 10:30:36 +0000
commitc23b2a4ad3f77222b6bfb219610fca79024ca4e5 (patch)
tree38c7eafd4577d8a0ff2effe0cc41d2f619292cf0 /actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
parentbca13f727eb7410857059bab38dc58f81dbde321 (diff)
downloadrails-c23b2a4ad3f77222b6bfb219610fca79024ca4e5.tar.gz
rails-c23b2a4ad3f77222b6bfb219610fca79024ca4e5.tar.bz2
rails-c23b2a4ad3f77222b6bfb219610fca79024ca4e5.zip
Updated vendor copy of html-scanner lib, for bug fixes and optimizations
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1416 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/vendor/html-scanner/html/document.rb')
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/document.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
index e14d9de166..f8a37e9454 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
@@ -1,7 +1,7 @@
require 'html/tokenizer'
require 'html/node'
-module HTML#:nodoc:
+module HTML #:nodoc:
# A top-level HTMl document. You give it a body of text, and it will parse that
# text into a tree of nodes.
@@ -11,7 +11,7 @@ module HTML#:nodoc:
attr_reader :root
# Create a new Document from the given text.
- def initialize(text)
+ def initialize(text, strict=false)
tokenizer = Tokenizer.new(text)
@root = Node.new(nil)
node_stack = [ @root ]
@@ -28,7 +28,7 @@ module HTML#:nodoc:
open_start = 0 if open_start < 0
close_start = node.position - 20
close_start = 0 if close_start < 0
- warn <<EOF.strip
+ msg = <<EOF.strip
ignoring attempt to close #{node_stack.last.name} with #{node.name}
opened at byte #{node_stack.last.position}, line #{node_stack.last.line}
closed at byte #{node.position}, line #{node.line}
@@ -36,6 +36,7 @@ ignoring attempt to close #{node_stack.last.name} with #{node.name}
text around open: #{text[open_start,40].inspect}
text around close: #{text[close_start,40].inspect}
EOF
+ strict ? raise(msg) : warn(msg)
end
elsif node.closing != :close
node_stack.push node