Skip to content
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

Add responsive to markdown table #672

Merged
merged 1 commit into from
May 30, 2016
Merged
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/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def block_code(code, language)
end

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

# Extend to support img width
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/markdown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class Foo; end
| cell 3 | cell 4 |)
end

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>" }
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>" }
end

describe 'Escape HTML tags' do
Expand Down Expand Up @@ -641,7 +641,7 @@ class Foo
<li>Ruby</li>
<li>Go</li>
</ol>
<h3 id="Tables">Tables</h3><table class="table table-bordered table-striped">
<h3 id="Tables">Tables</h3><div class="table-responsive"><table class="table table-bordered table-striped">
<tr>
<th>header 1</th>
<th>header 3</th>
Expand All @@ -654,7 +654,7 @@ class Foo
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table><h3 id="Links">Links</h3>
</table></div><h3 id="Links">Links</h3>
<p>Inline links:</p>

<p><a href="http://url.com/" title="title" target="_blank">link text</a><br>
Expand Down