diff options
author | murphy <murphy@rubychan.de> | 2006-04-16 00:42:38 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2006-04-16 00:42:38 +0000 |
commit | a2834bb05c4ab5bd32437f333a26f8286438ade4 (patch) | |
tree | 9c984ba59c66e301de4de18b46e3f76c50ead402 /lib/coderay/encoders | |
parent | ee808b400543d924286eebaee8ed1ad8a4e28ced (diff) | |
download | coderay-a2834bb05c4ab5bd32437f333a26f8286438ade4.tar.gz |
All scanners revisited not to produce errors unless in DEBUG mode. [thx@Daniel]
Fixed numerization for input not ending with \n. Added test cases in C scanner tests.
Added WoNáDo as contributer for last Ruby scanner fix.
Updated TODO.
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r-- | lib/coderay/encoders/html/numerization.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/coderay/encoders/html/numerization.rb b/lib/coderay/encoders/html/numerization.rb index 19c760e..1e1f952 100644 --- a/lib/coderay/encoders/html/numerization.rb +++ b/lib/coderay/encoders/html/numerization.rb @@ -48,9 +48,6 @@ module Encoders raise ArgumentError, 'Invalid value %p for :bolding; false or Integer expected.' % bold_every
end
- line_count = count("\n")
- line_count += 1 unless self[-1] == ?\n
-
case mode
when :inline
max_width = (start + line_count).to_s.size
@@ -106,6 +103,17 @@ module Encoders self
end
+ def line_count
+ line_count = count("\n")
+ position_of_last_newline = rindex(?\n)
+ if position_of_last_newline
+ after_last_newline = self[position_of_last_newline + 1 .. -1]
+ ends_with_newline = after_last_newline[/\A(?:<\/span>)*\z/]
+ line_count += 1 if not ends_with_newline
+ end
+ line_count
+ end
+
end
end
|