Skip to content

Commit

Permalink
support html tables (#41)
Browse files Browse the repository at this point in the history
* support html tables

* use -markdown_in_html_blocks
  • Loading branch information
chrisfenner authored Dec 3, 2023
1 parent 0c33b2d commit e5b2708
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ if [ -n "${pdf_output}" ]; then
--template=eisvogel.latex \
--filter=mermaid-filter \
--filter=pandoc-crossref \
--lua-filter=parse-html.lua \
--resource-path=.:/resources \
--data-dir=/resources \
--top-level-division=section \
Expand All @@ -279,7 +280,7 @@ if [ -n "${pdf_output}" ]; then
--metadata=titlepage-rule-height:0 \
--metadata=colorlinks:true \
--metadata=contact:[email protected] \
--from=markdown+implicit_figures+grid_tables+table_captions-citations \
--from=markdown+implicit_figures+grid_tables+table_captions-citations-markdown_in_html_blocks \
${extra_pandoc_options} \
--to=pdf \
"${build_dir}/${input_file}.3" \
Expand All @@ -296,6 +297,7 @@ if [ -n "${latex_output}" ]; then
--template=eisvogel.latex \
--filter=mermaid-filter \
--filter=pandoc-crossref \
--lua-filter=parse-html.lua \
--resource-path=.:/resources \
--data-dir=/resources \
--top-level-division=section \
Expand All @@ -310,7 +312,7 @@ if [ -n "${latex_output}" ]; then
--metadata=titlepage-rule-height:0 \
--metadata=colorlinks:true \
--metadata=contact:[email protected] \
--from=markdown+implicit_figures+grid_tables+table_captions-citations \
--from=markdown+implicit_figures+grid_tables+table_captions-citations-markdown_in_html_blocks \
${extra_pandoc_options} \
--to=latex \
"${build_dir}/${input_file}.3" \
Expand All @@ -327,9 +329,10 @@ if [ -n "${docx_output}" ]; then
--filter=/resources/filters/info.py \
--filter=mermaid-filter \
--filter=pandoc-crossref \
--lua-filter=parse-html.lua \
--resource-path=.:/resources \
--data-dir=/resources \
--from=markdown+implicit_figures+grid_tables+table_captions-citations \
--from=markdown+implicit_figures+grid_tables+table_captions-citations-markdown_in_html_blocks \
--reference-doc=/resources/templates/tcg_template.docx \
${extra_pandoc_options} \
--to=docx \
Expand Down
8 changes: 8 additions & 0 deletions filter/parse-html.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- https://tex.stackexchange.com/questions/631243/how-to-render-html-tables-in-markdown-using-pandoc

function RawBlock (raw)
return raw.format:match 'html'
and pandoc.read(raw.text, 'html').blocks
or raw
end

40 changes: 40 additions & 0 deletions sample3.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,46 @@ This section contains a Grid Table.
| Earth | -89.2 | 14 | 56.7 |
+---------------------+-------+-------+-------+

### HTML Table

This section contains an HTML Table.

<table>
<colgroup>
<col style="width: 13%" />
<col style="width: 86%" />
</colgroup>
<thead>
<tr>
<th>A || B</th>
<th>concatenation of B to A</th>
</tr>
</thead>
<tbody>
<tr>
<td>CEIL(x)</td>
<td>the smallest integer not less than x</td>
</tr>
<tr>
<td><strong>FLOOR(</strong>x<strong>)</strong></td>
<td>the largest integer not greater than x</td>
</tr>
<tr>
<td>A $\coloneqq$ B</td>
<td>assignment of the results of the expression on the right (B) to the
parameter on the left</td>
</tr>
<tr>
<td>A = B</td>
<td>equivalence (A is the same as B)</td>
</tr>
<tr>
<td>{ A }</td>
<td>an optional element</td>
</tr>
</tbody>
</table>

## Code

```c++
Expand Down

0 comments on commit e5b2708

Please sign in to comment.