This is an unsupported preprocessing markdown table hack. It adds `mdtbl` and `mdtblio` codeblocks. (An `mdtblio` prints the code in a verbatim text area first, before printing it in the `mdtbl`.) An `mdtbl` has within tablecell alignments based on distances to left and right separators. Consecutive right separators indicate multicolumns. The tables can be requested to be smart about numbers (e.g., negative signs instead of hyphens, proper rounding) within specific columns. They can be smart about adding stars. The processor also adds a "today" facility. Use 'backquote backslash today backquote'. See this input md file for the following example use: This file was created on `\today`. The input file for this document is `pandoctbl.md`. These table formats have been modestly tested under [pandoc 2.7](https://pandoc.org) (by John MacFarlane). Because this preprocessor is primarily for personal use, I can fix bugs as they raise their heads. --- \clearpage ## Setup 1. Download the [pandoctbl](http://www.ivo-welch.info/computers/pandoctbl) perl code and this [pandoctbl.md sample](http://www.ivo-welch.info/computers/pandoctbl.md) 2. Install the cpan module [Perl6::Slurp](https://metacpan.org/pod/Perl6::Slurp). 4. Run the program: $ pandoctbl pandoctbl.md pandoctbl.html $ pandoctbl pandoctbl.md pandoctbl.tex $ pandoctbl pandoctbl.md pandoctbl.pdf 5. Install the preamble files into ~/.pandoc/templates: [preamble.latex](preamble.latex.txt) and [preamble.html](preamble.html.txt) files. These can reflect your desired style changes. My own are linked here. You must remove the .txt extension, though. --- \clearpage ## Feature: Cell Alignment ```{=mdtblio 1A} caption: Cell Alignment Example ---t ^ h1-very-left ^ h1-very-center ^ h1-very-right ^ ---m | l1 | c1 | r3 | | l1 | c1 | r3 | | l1 | c1 | r3 | ---m ^ right ^ right | right | ^ left ^ left | left | ^ center ^ center | center | ---b ``` Alignment is determined as follows: * 2 or more spaces at the end and only 1 space at the start: left-justified * 2 or more spaces at the start and only 1 space at the end: right-justified * 2 or more spaces at the start and 2 or more space at the end: centered * Fewer start/end spaces --- undefined/ignored. Column header cells can use alignments just like body cells. \clearpage ## Feature: Colspans ```{=mdtblio 1A} caption: Multi-Column Spanning Text Example ---t ^ h1-left-3col ^^^ h1-center-3col ^^^ h1-right-3col ^^^ ---m | ctr4 | ctr5 | ctr6 | ctr7 | ctr8 | ctr9 | ctr10 | ctr11 | ctr12 | | ****ctr4-6***** ||| ****ctr7-9**** ||| ****ctr10-12**** ||| | lft4 | --ctr5-6-- || rght7 | ---rght8-9 || rght10 | left11-12--- ||| | ----rght4-6-tres-cols ||| -----rght7-9-tres-cols ||| left10-12-tres-cols--- ||| ---b ``` --- \clearpage ## Feature: Cell Content Number Preprocessing When a table contains a special format line (preceded by ^^), columns with numbers are preprocesed. Negative numbers then receive proper dashes (and not hyphens). The number of digits to round can be specified. Cells can have stars with some modicum of attempted alignment. (In html, this relies on the width of a star being about the width of one enspace. One issue may be that numbers are now not always fully right justified---but all such numbers are equally shifted left just a little to make space for alignment. LaTeX has no such issues, because it knows about zero-width boxes. There may be a way to coax html+css into zero-width boxes, too, but I have not investigated this.) ```{=mdtblio 1A} caption: Numeric Processing Example ---t ^ ^ *Roots* ^^^^ ^ From X ^ squaron ^ cubismo ^ teterony ^ not ^ ---m | For 2.0 | 1.41421 | 1.25992 | 1.189207 | -1.1487 | | For 3.0 | 1.73205 | 1.44224* | 1.316074 | 1.24573 | | For 4.0 | 2 | 1.58740** | 1.414213 | -1.31607 | | For 5.0 | -2.23 | 1.70997*** | 1.495348 | 0.0 | ---m | left | right | ----both are centered---- || right | ---b ^^ ^ bgyellow 1 ^ blue 2 ^ 3 ^ cond 4 ^ ---b ``` 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. * column 2: bgyellow, one digits. * column 3: blue, two digits. * column 4: three digits. * column 5: conditional (pos=blue,neg=red,zero=black), four digit. There is one bug: the second trailing '---b' is ignored, presumably because of the preceding format line. --- \clearpage ## Notes ### Good Abuse * The table format can be abused, which makes it even more flexible. - You can abuse the left/center/right spacing to format individual cells in individual ways. Just redefine the latex macro and the html css. For example, you could define `cellr` not only to text-justify right, but also to italicize and overstrike and this would apply only in those cells that start with at least two spaces and end with exactly one space. - You could define a column style of 'overstrike' and have every number in such columns be overstruck via css. ### Missing * Horizontal rules in tables: - There is no support for clines. The obvious markdown code equivalent would be `---2-4` in a table. The problem is deciding how many dashes should be added in html for such cases. - In html output, the table rules are simply replaced by emdashes according to the largest entry in all cells in this column. There is no intelligent colspan merging. - latex tables increase tabcolsep from the default 6pt to 12pt. * We want a tabular realignment utility (to improve readability, either of md inputs or tex/html output) * I am uncertain whether tabs should be expanded into spaces first. * A csv table input format * LaTeX tables could be more intelligent in terms of nice output formatting. This would make them more suitable for input into latex. * HTML output tables do not know about thead and tbody. LaTeX table output is not nice-optimized. ### Bugs * Bottomrule bug above