Skip to content

Commit 5695298

Browse files
committed
Add full table test
1 parent 62763a8 commit 5695298

3 files changed

Lines changed: 71 additions & 6 deletions

File tree

docs/content/markdown/tables.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ icon: icons/table.svg
66
To add a table, use three or more hyphens (`---`) to create each column’s header, and use pipes (`|`) to separate each column. You can also add a pipe at either end of the row, but it is not necessary.
77

88
::: div example
9-
```md
109

10+
```md
1111
Method | Description
1212
----------- | ---------------
1313
`GET` | Fetch resource
1414
`PUT` | Update resource
1515
`DELETE` | Delete resource
16-
1716
```
1817

1918
Method | Description
@@ -23,6 +22,27 @@ Method | Description
2322
`DELETE` | Delete resource
2423
:::
2524

25+
or
26+
27+
::: div example
28+
29+
```md
30+
| Option | Default |
31+
|--------------|-----------------------|
32+
| `database` | (required) |
33+
| `expires_in` | `172800` (2 days) |
34+
| `serializer` | `None` |
35+
| `timeout` | `5` |
36+
```
37+
38+
| Option | Default |
39+
|--------------|-----------------------|
40+
| `database` | (required) |
41+
| `expires_in` | `172800` (2 days) |
42+
| `serializer` | `None` |
43+
| `timeout` | `5` |
44+
:::
45+
2646
You don't have to make each cell the same width, but it looks clearer if you do.
2747

2848
::: tip

src/writeadoc/md/render.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
md = mistune.Markdown(
2727
HTMLRenderer(escape=False),
2828
plugins=[
29+
# Built-in plugins
2930
abbr,
3031
def_list,
3132
footnotes,
3233
table,
3334
task_lists,
34-
#
35+
# Custom plugins
3536
mdjx,
3637
block_attrs,
3738
inline_attrs,
@@ -40,11 +41,11 @@
4041
strikethrough,
4142
subscript,
4243
superscript,
43-
# md_in_html, ???
4444
BlockDirective([
45+
# Built-in directives
4546
Include(),
4647
TableOfContents(),
47-
#
48+
# Custom directives
4849
Admonition(),
4950
Container(),
5051
Figure(),

tests/md/test_plugins.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,51 @@
3030
</section>
3131
"""),
3232

33-
( # tables
33+
( # simple table
34+
"""
35+
Left Header | Right Header
36+
------------- | -------------
37+
Content Cell | Content Cell
38+
""",
39+
"""<table>
40+
<thead>
41+
<tr>
42+
<th>Left Header</th>
43+
<th>Right Header</th>
44+
</tr>
45+
</thead>
46+
<tbody>
47+
<tr>
48+
<td>Content Cell</td>
49+
<td>Content Cell</td>
50+
</tr>
51+
</tbody>
52+
</table>
53+
"""),
54+
55+
( # full table
56+
"""
57+
| Left Header | Right Header |
58+
|---------------|---------------|
59+
| Content Cell | Content Cell |
60+
""",
61+
"""<table>
62+
<thead>
63+
<tr>
64+
<th>Left Header</th>
65+
<th>Right Header</th>
66+
</tr>
67+
</thead>
68+
<tbody>
69+
<tr>
70+
<td>Content Cell</td>
71+
<td>Content Cell</td>
72+
</tr>
73+
</tbody>
74+
</table>
75+
"""),
76+
77+
( # table align
3478
"""
3579
| Left Header | Center Header | Right Header |
3680
| :----------- | :-------------: | ------------: |

0 commit comments

Comments
 (0)