Skip to content

Show Line Numbers in Table Mode #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/coderay/encoders/html/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def apply target, replacement
TABLE = Template.new <<-TABLE
<table class="CodeRay"><tr>
<td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><%LINE_NUMBERS%></pre></td>
<td class="code"><pre><%CONTENT%></pre></td>
<td class="code" ondblclick="with (this.parentNode.children[0].firstChild.style) { display = (display == 'none') ? '' : display }"><pre><%CONTENT%></pre></td>
</tr></table>
TABLE

Expand Down
6 changes: 3 additions & 3 deletions test/executable/suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def coderay args, options = {}

source = File.read source_file

pre = %r{<td class="code"><pre>(.*?)</pre>}m
pre = %r{<td class="code".*?><pre>(.*?)<\/pre>}m
tag = /<[^>]*>/

should 'not throw an error' do
Expand Down Expand Up @@ -169,7 +169,7 @@ def coderay args, options = {}

source = File.read source_file

pre = %r{<td class="code"><pre>(.*?)</pre>}m
pre = %r{<td class="code".*?><pre>(.*?)</pre>}m
tag_class = /<span class="([^>"]*)"?[^>]*>/

should 'respect the file extension and highlight the input as Python' do
Expand All @@ -184,7 +184,7 @@ def coderay args, options = {}

source = File.read source_file

pre = %r{<td class="code"><pre>(.*?)</pre>}m
pre = %r{<td class="code".*?><pre>(.*?)</pre>}m
tag_class = /<span class="([^>"]*)"?[^>]*>/

should 'ignore the file extension and highlight the input as Ruby' do
Expand Down
4 changes: 2 additions & 2 deletions test/functional/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_examples
<a href="#n2" name="n2">2</a>
<a href="#n3" name="n3">3</a>
</pre></td>
<td class="code"><pre><span style="color:#00D">5</span>.times <span style="color:#080;font-weight:bold">do</span>
<td class="code" ondblclick="with (this.parentNode.children[0].firstChild.style) { display = (display == 'none') ? '' : display }"><pre><span style="color:#00D">5</span>.times <span style="color:#080;font-weight:bold">do</span>
puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hello, world!</span><span style="color:#710">'</span></span>
<span style="color:#080;font-weight:bold">end</span></pre></td>
</tr></table>
Expand All @@ -40,7 +40,7 @@ def test_examples
<table class="CodeRay"><tr>
<td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>
</pre></td>
<td class="code"><pre>puts <span class="string"><span class="delimiter">&quot;</span><span class="content">Hello, world!</span><span class="delimiter">&quot;</span></span></pre></td>
<td class="code" ondblclick="with (this.parentNode.children[0].firstChild.style) { display = (display == 'none') ? '' : display }"><pre>puts <span class="string"><span class="delimiter">&quot;</span><span class="content">Hello, world!</span><span class="delimiter">&quot;</span></span></pre></td>
</tr></table>

</body>
Expand Down