Commit 504a048b authored by http://jneen.net/'s avatar http://jneen.net/

remove the dead linenos and linenostart options

and the methods that relied on them
parent 96274c27
...@@ -9,14 +9,6 @@ module Rouge ...@@ -9,14 +9,6 @@ module Rouge
# #
# [+cssclass+] CSS class for the wrapping <tt><div></tt> tag # [+cssclass+] CSS class for the wrapping <tt><div></tt> tag
# (default: 'highlight'). # (default: 'highlight').
# [+linenos+] If set to 'table', output line numbers as a table
# with two cells, one containing the line numbers,
# the other the whole code. This is copy paste friendly,
# but may cause alignment problems with some browsers
# or fonts. If set to 'inline', the line numbers will
# be integrated in the <tt><pre></tt> tag that contains
# the code (default: nil).
# [+linenostart+] The line number for the first line (default: 1).
# [+lineanchors+] If set to true the formatter will wrap each output # [+lineanchors+] If set to true the formatter will wrap each output
# line in an anchor tag with a name of L-linenumber. # line in an anchor tag with a name of L-linenumber.
# This allows easy linking to certain lines # This allows easy linking to certain lines
...@@ -26,53 +18,23 @@ module Rouge ...@@ -26,53 +18,23 @@ module Rouge
# (default: 'L'). # (default: 'L').
def initialize( def initialize(
cssclass: 'highlight', cssclass: 'highlight',
linenos: nil,
linenostart: 1,
lineanchors: false, lineanchors: false,
lineanchorsid: 'L' lineanchorsid: 'L'
) )
@cssclass = cssclass @cssclass = cssclass
@linenos = linenos
@linenostart = linenostart
@lineanchors = lineanchors @lineanchors = lineanchors
@lineanchorsid = lineanchorsid @lineanchorsid = lineanchorsid
end end
def render(tokens) def render(tokens)
case @linenos
when 'table'
render_tableized(tokens)
when 'inline'
render_untableized(tokens)
else
render_untableized(tokens)
end
end
alias_method :format, :render
private
def render_untableized(tokens)
data = process_tokens(tokens) data = process_tokens(tokens)
wrap_lines(data[:code]) wrap_lines(data[:code])
end end
def render_tableized(tokens) alias_method :format, :render
data = process_tokens(tokens)
html = '' private
html << '<table><tbody>'
html << "<td class=\"linenos\"><pre>"
html << wrap_linenos(data[:numbers])
html << '</pre></td>'
html << "<td class=\"lines\"><pre><code>"
html << wrap_lines(data[:code])
html << '</code></pre></td>'
html << '</tbody></table>'
html
end
def process_tokens(tokens) def process_tokens(tokens)
rendered = [] rendered = []
...@@ -101,10 +63,6 @@ module Rouge ...@@ -101,10 +63,6 @@ module Rouge
{ numbers: numbers, code: rendered } { numbers: numbers, code: rendered }
end end
def wrap_linenos(numbers)
numbers.join("\n")
end
def wrap_lines(lines) def wrap_lines(lines)
if @lineanchors if @lineanchors
lines = lines.each_with_index.map do |line, index| lines = lines.each_with_index.map do |line, index|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment