pandoctbl

Personal Preprocessor

IAW

May 15, 2019

This is an unsupported table hack. It adds mdtbl and mdtblio codeblocks. The mdtblio prints the code in a text area first before processing. mdtbls are easier to write than to read.

These table formats have been tested under pandoc 2.7 (by John MacFarlane).

The input file for this document is pandoctbl.md, which also includes the required CSS.


Setup

  1. Download the pandoctbl perl code and this pandoctbl.md sample

  2. Install the cpan module Perl6::Slurp.

  3. Run pandoctbl pandoctbl.md -s -o pandoctbl.html (or pandoctbl pandoctbl.md -s --template ~/.pandoc/default.html4 -o pandoctbl.html).

CSS Used Here

<style>
  th { text-align:center; }
  .celll { text-align:left; }
  .cellc { text-align:center; }
  .cellr { text-align:right; }

  span.red { color:red; }
  span.blue { color:blue; }
  span.bgyellow { background-color:yellow; }
</style>

Feature: Cell Alignment and Colspans

caption: table 1

---t
^ h1-left  ^  h1-center  ^  h1-right ^ h1-left-3col            ^^^     h1-center-3col     ^^^             h1-right-3col ^^^
---m
| l1       |      c1     |        r3 |  ctr4  |  ctr5  |  ctr6  |  ctr7  |  ctr8  |  ctr9  |  ctr10  |  ctr11  |  ctr12  |
| l1       |      c1     |        r3 |           ctr4-6        |||        ctr7-9          |||           ctr10-12        |||
| l1       |      c1     |        r3 | lft4-6-tres-cols        |||      rght7-9-tres-cols |||   ctr10-12-tres-cols      |||
---b
table 1
——————— ————————— ———————— ———— ———— ———— ———— ———— ———— ————— ————— —————
h1-left h1-centerh1-right h1-left-3col h1-center-3col h1-right-3col
——————— ————————— ———————— ———— ———— ———— ———— ———— ———— ————— ————— —————
l1c1 r3 ctr4 ctr5 ctr6 ctr7 ctr8 ctr9 ctr10 ctr11 ctr12
l1c1 r3 ctr4-6 ctr7-9 ctr10-12
l1c1 r3 lft4-6-tres-cols rght7-9-tres-cols ctr10-12-tres-cols
——————— ————————— ———————— ———— ———— ———— ———— ———— ———— ————— ————— —————

Feature: Cell Content Preprocessing

caption: table 2

---t
^                 ^                *Roots*                                      ^^^^
^ From X          ^    square    ^      cube       ^     tetra       ^      not    ^
---m
| For 2.0         |  1.414213562 |  1.259921050    |  1.189207115    |     -1.1487 |
| For 3.0         |  1.732050808 |  1.442249570    |  1.316074013    |     1.24573 | 
| For 4.0         |            2 |  1.587401052    |  1.414213562    |    -1.31607 |
| For 5.0         |     -2.23607 |  1.587401052    |  1.414213562    |         0.0 |
---m
| left            |        right |            both centered         ||       right |
^^                ^  bgyellow 2  ^     blue 1      ^       3         ^     cond 1  ^
---b
table 2
——————— ——————————— ——————————— ——————————— ————————
*Roots*
From X squarecubetetranot
——————— ——————————— ——————————— ——————————— ————————
For 2.01.41    1.3    1.189    –1.1   
For 3.01.73    1.4    1.316    1.2   
For 4.02.00    1.6    1.414    –1.3   
For 5.0–2.24    1.6    1.414    0.0   
——————— ——————————— ——————————— ——————————— ————————
leftright both centered right

A format string, applied only to numbers in cells (strings are ignored), can be attached by starting a line with two carets (^^). A standalone number in the field is interpreted as digits after the decimal point. A string of at least two characters is interpreted as css. The “cond” string has special meaning: It attaches “blue” to positives, “red” to negatives, and “black to zero.


Notes and Bugs