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

support html tables #41

Merged
merged 2 commits into from
Dec 3, 2023
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
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