Skip to content

Commit e5b2708

Browse files
authored
support html tables (#41)
* support html tables * use -markdown_in_html_blocks
1 parent 0c33b2d commit e5b2708

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

build.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ if [ -n "${pdf_output}" ]; then
265265
--template=eisvogel.latex \
266266
--filter=mermaid-filter \
267267
--filter=pandoc-crossref \
268+
--lua-filter=parse-html.lua \
268269
--resource-path=.:/resources \
269270
--data-dir=/resources \
270271
--top-level-division=section \
@@ -279,7 +280,7 @@ if [ -n "${pdf_output}" ]; then
279280
--metadata=titlepage-rule-height:0 \
280281
--metadata=colorlinks:true \
281282
--metadata=contact:[email protected] \
282-
--from=markdown+implicit_figures+grid_tables+table_captions-citations \
283+
--from=markdown+implicit_figures+grid_tables+table_captions-citations-markdown_in_html_blocks \
283284
${extra_pandoc_options} \
284285
--to=pdf \
285286
"${build_dir}/${input_file}.3" \
@@ -296,6 +297,7 @@ if [ -n "${latex_output}" ]; then
296297
--template=eisvogel.latex \
297298
--filter=mermaid-filter \
298299
--filter=pandoc-crossref \
300+
--lua-filter=parse-html.lua \
299301
--resource-path=.:/resources \
300302
--data-dir=/resources \
301303
--top-level-division=section \
@@ -310,7 +312,7 @@ if [ -n "${latex_output}" ]; then
310312
--metadata=titlepage-rule-height:0 \
311313
--metadata=colorlinks:true \
312314
--metadata=contact:[email protected] \
313-
--from=markdown+implicit_figures+grid_tables+table_captions-citations \
315+
--from=markdown+implicit_figures+grid_tables+table_captions-citations-markdown_in_html_blocks \
314316
${extra_pandoc_options} \
315317
--to=latex \
316318
"${build_dir}/${input_file}.3" \
@@ -327,9 +329,10 @@ if [ -n "${docx_output}" ]; then
327329
--filter=/resources/filters/info.py \
328330
--filter=mermaid-filter \
329331
--filter=pandoc-crossref \
332+
--lua-filter=parse-html.lua \
330333
--resource-path=.:/resources \
331334
--data-dir=/resources \
332-
--from=markdown+implicit_figures+grid_tables+table_captions-citations \
335+
--from=markdown+implicit_figures+grid_tables+table_captions-citations-markdown_in_html_blocks \
333336
--reference-doc=/resources/templates/tcg_template.docx \
334337
${extra_pandoc_options} \
335338
--to=docx \

filter/parse-html.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- https://tex.stackexchange.com/questions/631243/how-to-render-html-tables-in-markdown-using-pandoc
2+
3+
function RawBlock (raw)
4+
return raw.format:match 'html'
5+
and pandoc.read(raw.text, 'html').blocks
6+
or raw
7+
end
8+

sample3.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,46 @@ This section contains a Grid Table.
148148
| Earth | -89.2 | 14 | 56.7 |
149149
+---------------------+-------+-------+-------+
150150

151+
### HTML Table
152+
153+
This section contains an HTML Table.
154+
155+
<table>
156+
<colgroup>
157+
<col style="width: 13%" />
158+
<col style="width: 86%" />
159+
</colgroup>
160+
<thead>
161+
<tr>
162+
<th>A || B</th>
163+
<th>concatenation of B to A</th>
164+
</tr>
165+
</thead>
166+
<tbody>
167+
<tr>
168+
<td>CEIL(x)</td>
169+
<td>the smallest integer not less than x</td>
170+
</tr>
171+
<tr>
172+
<td><strong>FLOOR(</strong>x<strong>)</strong></td>
173+
<td>the largest integer not greater than x</td>
174+
</tr>
175+
<tr>
176+
<td>A $\coloneqq$ B</td>
177+
<td>assignment of the results of the expression on the right (B) to the
178+
parameter on the left</td>
179+
</tr>
180+
<tr>
181+
<td>A = B</td>
182+
<td>equivalence (A is the same as B)</td>
183+
</tr>
184+
<tr>
185+
<td>{ A }</td>
186+
<td>an optional element</td>
187+
</tr>
188+
</tbody>
189+
</table>
190+
151191
## Code
152192

153193
```c++

0 commit comments

Comments
 (0)