Parse markdown tables and show them with some styling

(imported from commit fb3c599b1dbaed2447f1e710ed7202486000ca2a)
This commit is contained in:
Leo Franchi
2013-10-10 16:05:12 -04:00
parent 1db703595e
commit 1f89bf386f
3 changed files with 61 additions and 0 deletions

View File

@@ -1227,6 +1227,32 @@ table.focused_table {
text-decoration: underline; text-decoration: underline;
} }
div.message_content table {
padding-right: 10px;
margin: 5px 5px 5px 5px;
width: 99%;
}
div.message_content thead {
background-color: #EFEFEF;
}
div.message_content tr {
display: table-row;
vertical-align: inherit;
}
div.message_content tr th {
border: 1px solid #cccccc;
padding: 4px;
text-align: left;
}
div.message_content tr td {
border: 1px solid #cccccc;
padding: 4px;
}
blockquote { blockquote {
margin-bottom: 6px; margin-bottom: 6px;
} }

View File

@@ -689,6 +689,7 @@ def make_md_engine(key, opts):
safe_mode = 'escape', safe_mode = 'escape',
output_format = 'html', output_format = 'html',
extensions = ['nl2br', extensions = ['nl2br',
'tables',
codehilite.makeExtension(configs=[ codehilite.makeExtension(configs=[
('force_linenos', False), ('force_linenos', False),
('guess_lang', False)]), ('guess_lang', False)]),

View File

@@ -3254,6 +3254,40 @@ But you can never leave**"""
self.assertEqual(converted, '<p>We should fix <a href="https://trac.zulip.net/ticket/224" target="_blank" title="https://trac.zulip.net/ticket/224">#224</a> and <a href="https://trac.zulip.net/ticket/115" target="_blank" title="https://trac.zulip.net/ticket/115">#115</a>, but not issue#124 or #1124z or <a href="https://trac.zulip.net/ticket/16" target="_blank" title="https://trac.zulip.net/ticket/16">trac #15</a> today.</p>') self.assertEqual(converted, '<p>We should fix <a href="https://trac.zulip.net/ticket/224" target="_blank" title="https://trac.zulip.net/ticket/224">#224</a> and <a href="https://trac.zulip.net/ticket/115" target="_blank" title="https://trac.zulip.net/ticket/115">#115</a>, but not issue#124 or #1124z or <a href="https://trac.zulip.net/ticket/16" target="_blank" title="https://trac.zulip.net/ticket/16">trac #15</a> today.</p>')
def test_tables(self):
msg = """This is a table:
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
"""
expected = """<p>This is a table:</p>
<table>
<thead>
<tr>
<th>First Header</th>
<th>Second Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>Content Cell</td>
<td>Content Cell</td>
</tr>
<tr>
<td>Content Cell</td>
<td>Content Cell</td>
</tr>
</tbody>
</table>"""
converted = bugdown_convert(msg)
print converted
self.assertEqual(converted, expected)
class UserPresenceTests(AuthedTestCase): class UserPresenceTests(AuthedTestCase):
def common_init(self, email): def common_init(self, email):