Skip to content

Commit b8f6016

Browse files
songjiayanghuacnlee
authored andcommitted
Add responsive to markdown table (ruby-china#672)
1 parent 03771da commit b8f6016

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/markdown.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def block_code(code, language)
2727
end
2828

2929
def table(header, body)
30-
%(<table class="table table-bordered table-striped">#{header}#{body}</table>)
30+
%(<div class="table-responsive"><table class="table table-bordered table-striped">#{header}#{body}</table></div>)
3131
end
3232

3333
# Extend to support img width

spec/lib/markdown_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class Foo; end
469469
| cell 3 | cell 4 |)
470470
end
471471

472-
it { expect(doc.inner_html).to eq "<table class=\"table table-bordered table-striped\">\n<tr>\n<th>header 1</th>\n<th>header 3</th>\n</tr>\n<tr>\n<td>cell 1</td>\n<td>cell 2</td>\n</tr>\n<tr>\n<td>cell 3</td>\n<td>cell 4</td>\n</tr>\n</table>" }
472+
it { expect(doc.inner_html).to eq "<div class=\"table-responsive\"><table class=\"table table-bordered table-striped\">\n<tr>\n<th>header 1</th>\n<th>header 3</th>\n</tr>\n<tr>\n<td>cell 1</td>\n<td>cell 2</td>\n</tr>\n<tr>\n<td>cell 3</td>\n<td>cell 4</td>\n</tr>\n</table></div>" }
473473
end
474474

475475
describe 'Escape HTML tags' do
@@ -641,7 +641,7 @@ class Foo
641641
<li>Ruby</li>
642642
<li>Go</li>
643643
</ol>
644-
<h3 id="Tables">Tables</h3><table class="table table-bordered table-striped">
644+
<h3 id="Tables">Tables</h3><div class="table-responsive"><table class="table table-bordered table-striped">
645645
<tr>
646646
<th>header 1</th>
647647
<th>header 3</th>
@@ -654,7 +654,7 @@ class Foo
654654
<td>cell 3</td>
655655
<td>cell 4</td>
656656
</tr>
657-
</table><h3 id="Links">Links</h3>
657+
</table></div><h3 id="Links">Links</h3>
658658
<p>Inline links:</p>
659659
660660
<p><a href="http://url.com/" title="title" target="_blank">link text</a><br>

0 commit comments

Comments
 (0)