summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders
diff options
context:
space:
mode:
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r--lib/coderay/encoders/html/numerization.rb14
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