Skip to content

Commit 1abec29

Browse files
committed
Create files
1 parent 47ea5cd commit 1abec29

File tree

4 files changed

+149
-0
lines changed

4 files changed

+149
-0
lines changed

tables-vrules/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DIFF ?= diff --strip-trailing-cr -u
2+
3+
.PHONY: test
4+
5+
test: test_latex
6+
7+
test_latex: sample.md expected.tex tables-vrules.lua
8+
@pandoc --lua-filter tables-vrules.lua --to=latex $< \
9+
| $(DIFF) expected.tex -
10+
11+
expected.tex: sample.md tables-vrules.lua
12+
pandoc --lua-filter tables-vrules.lua --output $@ $<

tables-vrules/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: "tables-vrules - Pandoc filter to add vertical rules to tables"
3+
author: "Christophe Agathon"
4+
---
5+
6+
Tables VRules
7+
=======
8+
9+
Add vertical rules to tables.
10+
11+
v1.0. Copyright: © 2021 Christophe Agathon
12+
13+
License: MIT - see LICENSE file for details.
14+
15+
Introduction
16+
------------
17+
18+
Since pandoc has a strong policy against vertical rules in tables, peole have been looking for solutions to get those, especially when rendering PDF files via Latex.
19+
20+
For more information you can refer to :
21+
22+
* This Pandoc issue [https://github.com/jgm/pandoc/issues/922](https://github.com/jgm/pandoc/issues/922)
23+
* This discussion on StackExchange [https://tex.stackexchange.com/questions/595615/how-can-i-reformat-a-table-using-markdown-pandoc-pdf/596005](https://tex.stackexchange.com/questions/595615/how-can-i-reformat-a-table-using-markdown-pandoc-pdf/596005)
24+
25+
marjinshraagen proposed a solution based on a patch of `\LT@array` in Latex. It used to work pretty well. It doesn't anymore for Multiline Tables and Pipes Tables since Pandoc changed the Latex code it generates for those kind of tables. Don't know exactly when it changed but sometime between Pandoc version 2.9.2.1 and version 2.16.
26+
27+
Since patching in Latex is tricky and I am not a Latex guru, I didn't manage to make it work again, so I made this filter which change the call to `longtable` to add vertical rules in a more "natural" whay.
28+
29+
30+
Usage
31+
-----
32+
33+
### Formating the document
34+
35+
Simply use on of the table synthax allowed by Pandoc (details in
36+
[Pandoc's manual](https://pandoc.org/MANUAL.html#tables).
37+
38+
39+
### Rendering the document
40+
41+
Copy `tables-vrules.lua` in your document folder or in your pandoc
42+
data directory (details in
43+
[Pandoc's manual](https://pandoc.org/MANUAL.html#option--lua-filter)).
44+
Run it on your document with a `--luafilter` option:
45+
46+
```bash
47+
pandoc --luafilter tables-vrules.lua SOURCE.md -o OUTPUT.pdf
48+
49+
```
50+
51+
or specify it in a defaults file (details in
52+
[Pandoc's manual](https://pandoc.org/MANUAL.html#option--defaults)).
53+
54+
This will generate Tables with vertical rules in Latex and PDF documents from Pandoc markdown source files.
55+
56+
### Limitations
57+
58+
This filter is active only for Latex and PDF output.
59+
60+
Vertical rules in HTML documents should be handled via css styling.
61+
62+
Contributing
63+
------------
64+
65+
PRs welcome.
66+

tables-vrules/sample.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
# Simple Table
3+
4+
Right Left Center Default
5+
------- ------ ---------- -------
6+
12 12 12 12
7+
123 123 123 123
8+
1 1 1 1
9+
10+
Table: Demonstration of simple table syntax.
11+
12+
# Multiline Tables
13+
14+
-------------------------------------------------------------
15+
Centered Default Right Left
16+
Header Aligned Aligned Aligned
17+
----------- ------- --------------- -------------------------
18+
First row 12.0 Example of a row that
19+
spans multiple lines.
20+
21+
Second row 5.0 Here's another one. Note
22+
the blank line between
23+
rows.
24+
-------------------------------------------------------------
25+
26+
Table: Here's the caption. It, too, may span
27+
multiple lines.
28+
29+
# Grid Tables
30+
31+
: Sample grid table.
32+
33+
+---------------+---------------+--------------------+
34+
| Fruit | Price | Advantages |
35+
+===============+===============+====================+
36+
| Bananas | $1.34 | - built-in wrapper |
37+
| | | - bright color |
38+
+---------------+---------------+--------------------+
39+
| Oranges | $2.10 | - cures scurvy |
40+
| | | - tasty |
41+
+---------------+---------------+--------------------+
42+
43+
# Pipes Tables
44+
45+
| Right | Left | Default | Center |
46+
|------:|:-----|---------|:------:|
47+
| 12 | 12 | 12 | 12 |
48+
| 123 | 123 | 123 | 123 |
49+
| 1 | 1 | 1 | 1 |
50+
51+
: Demonstration of pipe table syntax.

tables-vrules/tables-vrules.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--[[
2+
tables-vrules - adds vertical rules to tables for latex output
3+
4+
Copyright: © 2021 Christophe Agathon <[email protected]>
5+
License: MIT – see LICENSE file for details
6+
7+
Credits: marijnschraagen for the original Latex hack
8+
9+
Output: latex, pdf.
10+
11+
Usage: See README.md for details
12+
13+
--]]
14+
local List = require 'pandoc.List'
15+
16+
17+
function Table(table)
18+
local returned-list
19+
20+
end

0 commit comments

Comments
 (0)