summaryrefslogtreecommitdiff
path: root/paper/lua-filters/table-short-captions
diff options
context:
space:
mode:
Diffstat (limited to 'paper/lua-filters/table-short-captions')
-rw-r--r--paper/lua-filters/table-short-captions/Makefile24
-rw-r--r--paper/lua-filters/table-short-captions/README.md66
-rw-r--r--paper/lua-filters/table-short-captions/expected-sample.native68
-rw-r--r--paper/lua-filters/table-short-captions/expected-sample.tex291
-rw-r--r--paper/lua-filters/table-short-captions/sample.md84
-rw-r--r--paper/lua-filters/table-short-captions/table-short-captions.lua160
6 files changed, 0 insertions, 693 deletions
diff --git a/paper/lua-filters/table-short-captions/Makefile b/paper/lua-filters/table-short-captions/Makefile
deleted file mode 100644
index 3df47b1..0000000
--- a/paper/lua-filters/table-short-captions/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-LF = --lua-filter=table-short-captions.lua
-F = -F pandoc-crossref
-
-test: sample.md
- @pandoc -s $(LF) -t native $< | \
- diff -u expected-sample.native -
-
-test-with-crossref: sample.md
- @pandoc -s $(LF) $(F) -t latex $< | \
- diff -u expected-sample.tex -
-
-README.pdf: README.md
- @pandoc $(LF) $(F) $< -o $@
-
-sample.tex: sample.md
- @pandoc -s $(LF) $(F) -t latex $< -o $@
-
-sample.pdf: sample.md
- @pandoc -s $(LF) $(F) -t latex $< -o $@
-
-clean:
- rm -v *.aux *.dvi *.fdb_latexmk *.fls *.log *.lot *.ps *.pdf sample.tex | true
-
-.PHONY: test test-with-crossref clean
diff --git a/paper/lua-filters/table-short-captions/README.md b/paper/lua-filters/table-short-captions/README.md
deleted file mode 100644
index 853b809..0000000
--- a/paper/lua-filters/table-short-captions/README.md
+++ /dev/null
@@ -1,66 +0,0 @@
----
-title: "table-short-captions.lua"
----
-
-# Short captions in \LaTeX\ tables output
-
-For LaTeX output, this filter enables use of the attribute
-`short-caption` for tables. The attribute value will appear in the List
-of Tables.
-
-This filter also enables the class `.unlisted` for tables. This will
-prevent the table caption from appearing in the List of Tables.
-
-# Usage
-
-In Pandoc Markdown, you can add a caption to a table with
-
- Table: This is the *italicised long caption* of my table, which has
- a very long caption.
-
-If the document metadata includes `lot:true`, then the List of Tables
-will be inserted at the beginning of the document.
-
-The [pandoc-crossref](http://lierdakil.github.io/pandoc-crossref/)
-filter extends this, and enables you to specify a custom label for the
-table.
-
- Table: This is the *italicised long caption* of my table, which has
- a very long caption. {#tbl:full-of-juicy-data}
-
-This filter, when run _before_ pandoc-crossref, allows you to add short
-captions to the table as a `short-caption` attribute. What is between
-the quotes will be parsed as Markdown.
-
-**Important!:** You _must_ use empty square brackets before the
-attributes tag.
-
- Table: This is the *italicised long caption* of my table, which has
- a very long caption.
- []{#tbl:full-of-juicy-data short-caption="Short caption for *juicy* data table."}
-
-Alternatively, if you wish to create a table which is unlisted in the
-List of Tables, you can use the `.unlisted` class in the attributes tag.
-
- Table: This is the *italicised long caption* of my table, which will
- not appear in the List of Tables. []{#tbl:full-of-juicy-data .unlisted}
-
-This filter should prove useful for students writing dissertations, who
-often have to include a List of Tables in the front matter, but where
-table captions themselves can be quite lengthy.
-
- pandoc --lua-filter=table-short-captions.lua \
- --filter pandoc-crossref \
- article.md -o article.tex
-
- pandoc --lua-filter=table-short-captions.lua \
- --filter pandoc-crossref \
- article.md -o article.pdf
-
-
-# Limitations
-
-- The filter will process the `short-caption` attribute value as pandoc
- markdown, regardless of the input format.
-- pandoc-crossref should be run after it.
-- I have only tested this from a Markdown source.
diff --git a/paper/lua-filters/table-short-captions/expected-sample.native b/paper/lua-filters/table-short-captions/expected-sample.native
deleted file mode 100644
index c387ebe..0000000
--- a/paper/lua-filters/table-short-captions/expected-sample.native
+++ /dev/null
@@ -1,68 +0,0 @@
-Pandoc (Meta {unMeta = fromList [("lot",MetaBool True),("title",MetaInlines [Str "Tests",Space,Str "for",Space,Str "table-short-captions.lua"])]})
-[Para [Str "These",Space,Str "tests",Space,Str "are",Space,Str "written",Space,Str "so",Space,Str "that",Space,Str "if",Space,Strong [Str "bold",Space,Str "font"],Space,Str "appears",Space,Str "in",Space,Str "the",Space,Str "LOT,",Space,Str "something",Space,Str "is",Space,Str "wrong."]
-,Para [Str "The",Space,Str "tests",Space,Str "are",Space,Str "split",Space,Str "into",Space,Str "two:",Space,Str "expected",Space,Str "uses,",Space,Str "and",Space,Str "non-standard",Space,Str "uses/errors.",LineBreak,Str "The",Space,Str "non-standard",Space,Str "uses",Space,Str "are",Space,Str "presented",Space,Str "in",Space,Str "this",Space,Str "document",Space,Str "for",Space,Str "troubleshooting",Space,Str "purposes,",Space,Str "and",Space,Str "to",Space,Str "ensure",Space,Str "the",Space,Str "filter",Space,Str "doesn\8217t",Space,Str "crash",Space,Str "in",Space,Str "corner",Space,Str "cases."]
-,Header 1 ("standard-usage",[],[]) [Str "Standard",Space,Str "usage"]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl1,",Space,Str "which",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "label."] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl2,",Space,Str "in",Space,Str "standard",Space,Code ("",[],[]) "pandoc-crossref",Space,Str "form.",Space,Str "{#tbl:tbl-label2}"] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl3,",Space,Str "which",Space,Str "is",Space,Strong [Str "unlisted"],Str ".",Space,Span ("tbl:tbl-label3",["unlisted"],[]) []] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl4,",Space,Str "which",Space,Str "has",Space,Str "an",Space,Strong [Str "overriding"],Space,Str "short-caption.",Space,Str "This",Space,Str "is",Space,Str "the",Space,Str "expected",Space,Str "usage.",Space,Span ("tbl:tbl-label4",[],[("short-caption","Table 4 *short* capt.")]) []] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Header 1 ("non-standard-usageerrors",[],[]) [Str "Non-standard",Space,Str "usage/errors"]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl5,",Space,Str "which",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "label,",Space,Str "but",Space,Str "does",Space,Str "have",Space,Str "empty",Space,Str "braces",Space,Str "at",Space,Str "the",Space,Str "end.",Space,Str "{}"] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl6,",Space,Str "which",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "label,",Space,Str "but",Space,Str "does",Space,Str "have",Space,Str "an",Space,Str "empty",Space,Str "span",Space,Str "at",Space,Str "the",Space,Str "end.",Space,Span ("",[],[]) []] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl7,",Space,Str "which",Space,Str "is",Space,Str "improperly",Space,Str "formatted,",Space,Str "and",Space,Str "will",Space,Str "appear",Space,Str "in",Space,Str "the",Space,Str "list",Space,Str "of",Space,Str "tables.",Space,Str "This",Space,Str "filter",Space,Str "requires",Space,Str "that",Space,Code ("",[],[]) ".unlisted",Space,Str "is",Space,Str "placed",Space,Str "in",Space,Str "a",Space,Str "span.",Space,Str "{#tbl:tbl-label7",Space,Str ".unlisted}"] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl8,",Space,Str "which",Space,Str "has",Space,Str "an",Space,Str "empty",Space,Str "short-caption.",Space,Str "An",Space,Str "empty",Space,Str "short-caption",Space,Str "does",Space,Str "nothing.",Space,Str "The",Space,Str "long",Space,Str "caption",Space,Str "will",Space,Str "still",Space,Str "be",Space,Str "used.",Space,Span ("tbl:tbl-label8",[],[("short-caption","")]) []] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]
-,Table [Str "This",Space,Str "is",Space,Str "the",Space,Emph [Str "italicised",Space,Str "long",Space,Str "caption"],Space,Str "of",Space,Str "tbl9,",Space,Str "which",Space,Str "is",Space,Strong [Str "unlisted"],Str ",",Space,Str "yet",Space,Str "has",Space,Str "a",Space,Str "short-caption.",Space,Span ("tbl:tbl-label9",["unlisted"],[("short-caption","Table 9 **unlisted** *short* capt.")]) []] [AlignDefault,AlignDefault] [0.0,0.0]
- [[Plain [Str "cola"]]
- ,[Plain [Str "colb"]]]
- [[[Plain [Str "a1"]]
- ,[Plain [Str "b1"]]]
- ,[[Plain [Str "a2"]]
- ,[Plain [Str "b2"]]]]]
diff --git a/paper/lua-filters/table-short-captions/expected-sample.tex b/paper/lua-filters/table-short-captions/expected-sample.tex
deleted file mode 100644
index 65a2073..0000000
--- a/paper/lua-filters/table-short-captions/expected-sample.tex
+++ /dev/null
@@ -1,291 +0,0 @@
-% Options for packages loaded elsewhere
-\PassOptionsToPackage{unicode=true}{hyperref}
-\PassOptionsToPackage{hyphens}{url}
-%
-\documentclass[
-]{article}
-\usepackage{lmodern}
-\usepackage{amssymb,amsmath}
-\usepackage{ifxetex,ifluatex}
-\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
- \usepackage[T1]{fontenc}
- \usepackage[utf8]{inputenc}
- \usepackage{textcomp} % provides euro and other symbols
-\else % if luatex or xelatex
- \usepackage{unicode-math}
- \defaultfontfeatures{Scale=MatchLowercase}
- \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
-\fi
-% Use upquote if available, for straight quotes in verbatim environments
-\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
-\IfFileExists{microtype.sty}{% use microtype if available
- \usepackage[]{microtype}
- \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
-}{}
-\makeatletter
-\@ifundefined{KOMAClassName}{% if non-KOMA class
- \IfFileExists{parskip.sty}{%
- \usepackage{parskip}
- }{% else
- \setlength{\parindent}{0pt}
- \setlength{\parskip}{6pt plus 2pt minus 1pt}}
-}{% if KOMA class
- \KOMAoptions{parskip=half}}
-\makeatother
-\usepackage{xcolor}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
-\hypersetup{
- pdftitle={Tests for table-short-captions.lua},
- hidelinks,
-}
-\urlstyle{same} % disable monospaced font for URLs
-\usepackage{longtable,booktabs}
-% Allow footnotes in longtable head/foot
-\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
-\makesavenoteenv{longtable}
-\setlength{\emergencystretch}{3em} % prevent overfull lines
-\providecommand{\tightlist}{%
- \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
-\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
-% Redefines (sub)paragraphs to behave more like sections
-\ifx\paragraph\undefined\else
- \let\oldparagraph\paragraph
- \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
-\fi
-\ifx\subparagraph\undefined\else
- \let\oldsubparagraph\subparagraph
- \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
-\fi
-
-% Set default figure placement to htbp
-\makeatletter
-\def\fps@figure{htbp}
-\makeatother
-
-% -- begin:latex-table-short-captions --
-\makeatletter\AtBeginDocument{%
-\def\LT@c@ption#1[#2]#3{% % Overwrite the workhorse macro used in formatting a longtable caption.
- \LT@makecaption#1\fnum@table{#3}%
- \ifdefined\pandoctableshortcapt % If pandoctableshortcapt is defined (even if blank), we should override default behaviour.
- \let\@tempa\pandoctableshortcapt% % (Use let, we don't want to expand pandoctableshortcapt!)
- \else % If not, fall back to default behaviour
- \def\@tempa{#2}% % (Use the argument in square brackets)
- \fi
- \ifx\@tempa\@empty\else % If @tempa is blank, no lot entry! Otherwise, @tempa becomes the lot title.
- {\let\\\space
- \addcontentsline{lot}{table}{\protect\numberline{\thetable}{\@tempa}}}%
- \fi}
-}\makeatother
-% -- end:latex-table-short-captions --
-\makeatletter
-\@ifpackageloaded{subfig}{}{\usepackage{subfig}}
-\@ifpackageloaded{caption}{}{\usepackage{caption}}
-\captionsetup[subfloat]{margin=0.5em}
-\AtBeginDocument{%
-\renewcommand*\figurename{Figure}
-\renewcommand*\tablename{Table}
-}
-\AtBeginDocument{%
-\renewcommand*\listfigurename{List of Figures}
-\renewcommand*\listtablename{List of Tables}
-}
-\@ifpackageloaded{float}{}{\usepackage{float}}
-\floatstyle{ruled}
-\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
-\floatname{codelisting}{Listing}
-\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
-\makeatother
-
-\title{Tests for table-short-captions.lua}
-\date{}
-
-\begin{document}
-\maketitle
-
-\listoftables
-These tests are written so that if \textbf{bold font} appears in the
-LOT, something is wrong.
-
-The tests are split into two: expected uses, and non-standard
-uses/errors.\\
-The non-standard uses are presented in this document for troubleshooting
-purposes, and to ensure the filter doesn't crash in corner cases.
-
-\hypertarget{standard-usage}{%
-\section{Standard usage}\label{standard-usage}}
-
-\begin{longtable}[]{@{}ll@{}}
-\caption{This is the \emph{italicised long caption} of tbl1, which does
-not have a label.}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\hypertarget{tbl:tbl-label2}{}
-\begin{longtable}[]{@{}ll@{}}
-\caption{\label{tbl:tbl-label2}This is the \emph{italicised long
-caption} of tbl2, in standard \texttt{pandoc-crossref}
-form.}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\def\pandoctableshortcapt{} % .unlisted
-
-\hypertarget{tbl:tbl-label3}{}
-\begin{longtable}[]{@{}ll@{}}
-\caption{\label{tbl:tbl-label3}This is the \emph{italicised long
-caption} of tbl3, which is \textbf{unlisted}.}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\undef\pandoctableshortcapt
-
-\def\pandoctableshortcapt{Table 4 \emph{short} capt.}
-
-\hypertarget{tbl:tbl-label4}{}
-\begin{longtable}[]{@{}ll@{}}
-\caption{\label{tbl:tbl-label4}This is the \emph{italicised long
-caption} of tbl4, which has an \textbf{overriding} short-caption. This
-is the expected usage.}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\undef\pandoctableshortcapt
-
-\hypertarget{non-standard-usageerrors}{%
-\section{Non-standard usage/errors}\label{non-standard-usageerrors}}
-
-\begin{longtable}[]{@{}ll@{}}
-\caption{This is the \emph{italicised long caption} of tbl5, which does
-not have a label, but does have empty braces at the end.
-\{\}}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\begin{longtable}[]{@{}ll@{}}
-\caption{This is the \emph{italicised long caption} of tbl6, which does
-not have a label, but does have an empty span at the end.
-}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\begin{longtable}[]{@{}ll@{}}
-\caption{This is the \emph{italicised long caption} of tbl7, which is
-improperly formatted, and will appear in the list of tables. This filter
-requires that \texttt{.unlisted} is placed in a span. \{\#tbl:tbl-label7
-.unlisted\}}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\hypertarget{tbl:tbl-label8}{}
-\begin{longtable}[]{@{}ll@{}}
-\caption{\label{tbl:tbl-label8}This is the \emph{italicised long
-caption} of tbl8, which has an empty short-caption. An empty
-short-caption does nothing. The long caption will still be
-used.}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\def\pandoctableshortcapt{} % .unlisted
-
-\hypertarget{tbl:tbl-label9}{}
-\begin{longtable}[]{@{}ll@{}}
-\caption{\label{tbl:tbl-label9}This is the \emph{italicised long
-caption} of tbl9, which is \textbf{unlisted}, yet has a
-short-caption.}\tabularnewline
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endfirsthead
-\toprule
-cola & colb\tabularnewline
-\midrule
-\endhead
-a1 & b1\tabularnewline
-a2 & b2\tabularnewline
-\bottomrule
-\end{longtable}
-
-\undef\pandoctableshortcapt
-
-\end{document}
diff --git a/paper/lua-filters/table-short-captions/sample.md b/paper/lua-filters/table-short-captions/sample.md
deleted file mode 100644
index 74c27fb..0000000
--- a/paper/lua-filters/table-short-captions/sample.md
+++ /dev/null
@@ -1,84 +0,0 @@
----
-title: "Tests for table-short-captions.lua"
-lot: true
----
-
-These tests are written so that if **bold font** appears in the LOT, something is wrong.
-
-The tests are split into two: expected uses, and non-standard uses/errors.
-The non-standard uses are presented in this document for troubleshooting purposes, and to ensure the filter doesn't crash in corner cases.
-
-# Standard usage
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl1, which does not have a label.
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl2, in standard `pandoc-crossref` form. {#tbl:tbl-label2}
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl3, which is **unlisted**. []{#tbl:tbl-label3 .unlisted}
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl4, which has an **overriding** short-caption. This is the expected usage. []{#tbl:tbl-label4 short-caption="Table 4 *short* capt."}
-
-
-# Non-standard usage/errors
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl5, which does not have a label, but does have empty braces at the end. {}
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl6, which does not have a label, but does have an empty span at the end. []{}
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl7, which is improperly formatted, and will appear in the list of tables. This filter requires that `.unlisted` is placed in a span. {#tbl:tbl-label7 .unlisted}
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl8, which has an empty short-caption. An empty short-caption does nothing. The long caption will still be used. []{#tbl:tbl-label8 short-caption=""}
-
-
-| cola | colb |
-| ---- | ---- |
-| a1 | b1 |
-| a2 | b2 |
-
-Table: This is the *italicised long caption* of tbl9, which is **unlisted**, yet has a short-caption. []{#tbl:tbl-label9 .unlisted short-caption="Table 9 **unlisted** *short* capt."}
diff --git a/paper/lua-filters/table-short-captions/table-short-captions.lua b/paper/lua-filters/table-short-captions/table-short-captions.lua
deleted file mode 100644
index 6f4970b..0000000
--- a/paper/lua-filters/table-short-captions/table-short-captions.lua
+++ /dev/null
@@ -1,160 +0,0 @@
----LaTeXTableShortCapts – enable `.unlisted` and `short-caption=""` properties
--- for Pandoc conversion to LaTeX
-
---[[
-Copyright (c) 2019 Blake Riley
-
-Permission to use, copy, modify, and/or distribute this software for any purpose
-with or without fee is hereby granted, provided that the above copyright notice
-and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-THIS SOFTWARE.
-]]
-local List = require 'pandoc.List'
-
--- don't do anything unless we target latex
-if FORMAT ~= "latex" then
- return {}
-end
-
---- Code for injection into the LaTeX header,
--- to overwrite a macro in longtable captions.
-longtable_caption_mod = [[
-% -- begin:latex-table-short-captions --
-\makeatletter\AtBeginDocument{%
-\def\LT@c@ption#1[#2]#3{% % Overwrite the workhorse macro used in formatting a longtable caption.
- \LT@makecaption#1\fnum@table{#3}%
- \@ifundefined{pandoctableshortcapt}
- {\def\@tempa{#2}} % Use default behaviour: argument in square brackets
- {\let\@tempa\pandoctableshortcapt} % If defined (even if blank), use to override
- \ifx\@tempa\@empty\else % If @tempa is blank, no lot entry! Otherwise, @tempa becomes the lot title.
- {\let\\\space
- \addcontentsline{lot}{table}{\protect\numberline{\thetable}{\@tempa}}}%
- \fi}
-}\makeatother
-% -- end:latex-table-short-captions --
-]]
-
---- Creates a def shortcaption block to be placed before the table
--- @tparam ?string sc : The short-caption property value
--- @treturn Plain : The def shortcaption block
-local function defshortcapt(sc)
- local scblock = List:new{}
- scblock:extend {pandoc.RawInline('tex', "\\def\\pandoctableshortcapt{")}
- if sc then
- scblock:extend (pandoc.read(sc).blocks[1].c)
- end
- scblock:extend {pandoc.RawInline('tex', "}")}
- if not sc then
- scblock:extend {pandoc.RawInline('tex', " % .unlisted")}
- end
- return pandoc.Plain(scblock)
-end
-
---- The undef shortcaption block to be placed after the table
-local undefshortcapt = pandoc.RawBlock('tex', "\\let\\pandoctableshortcapt\\relax")
-
---- Parses a mock "Table Attr".
--- We use the Attr of an empty Span as if it were Table Attr.
--- This function extracts what is needed to build a short-caption.
--- @tparam Attr attr : The Attr of the property Span in the table caption
--- @treturn ?string : The identifier
--- @treturn ?string : The "short-caption" property, if present.
--- @treturn bool : Whether ".unlisted" appeared in the classes
-local function parse_table_attrs(attr)
- -- Find label
- local label = nil
- if attr.identifier and (#attr.identifier > 0) then
- label = attr.identifier
- end
-
- -- Look for ".unlisted" in classes
- local unlisted = false
- if attr.classes:includes("unlisted") then
- unlisted = true
- end
-
- -- If not unlisted, then find the property short-caption.
- local short_caption = nil
- if not unlisted then
- if (attr.attributes["short-caption"]) and
- (#attr.attributes["short-caption"] > 0) then
- short_caption = attr.attributes['short-caption']
- end
- end
-
- return label, short_caption, unlisted
-end
-
---- Wraps a table with shortcaption code
--- @tparam Table tbl : The table with {}-wrapped properties in the caption
--- @treturn List[Blocks] : The table with {label} in the caption,
--- optionally wrapped in shortcaption code
-function rewrite_longtable_caption(tbl)
- -- Escape if there is no caption present.
- if not tbl.caption then
- return nil
- end
-
- -- Try find the properties block
- local is_properties_span = function (inl)
- return (inl.t) and (inl.t == "Span") -- is span
- and (inl.content) and (#inl.content == 0) -- is empty span
- end
- local propspan, idx = tbl.caption:find_if(is_properties_span)
-
- -- If we couldn't find properties, escape.
- if not propspan then
- return nil
- end
-
- -- Otherwise, parse it all
- local label, short_caption, unlisted = parse_table_attrs(propspan.attr)
-
- -- Excise the span from the caption
- tbl.caption[idx] = nil
-
- -- Put label back into caption for pandoc-crossref
- if label then
- tbl.caption:extend {pandoc.Str("{#"..label.."}")}
- end
-
- -- Place new table
- local result = List:new{}
- if short_caption or unlisted then
- result:extend {defshortcapt(short_caption)}
- end
- result:extend {tbl}
- if short_caption or unlisted then
- result:extend {undefshortcapt}
- end
- return result
-end
-
---- Inserts longtable_caption_mod into the header_includes
--- @tparam Meta meta : The document metadata
--- @treturn Meta : The document metadata, with replacement LaTeX macro
--- in header_includes
-function add_longtable_caption_mod(meta)
- local header_includes = -- test ? a : b
- (meta['header-includes'] and meta['header-includes'].t == 'MetaList')
- and meta['header-includes']
- or pandoc.MetaList{meta['header-includes']}
- header_includes[#header_includes + 1] =
- pandoc.MetaBlocks{pandoc.RawBlock('tex', longtable_caption_mod)}
- meta['header-includes'] = header_includes
- return meta
-end
-
-return {
- {
- Meta = add_longtable_caption_mod,
- Table = rewrite_longtable_caption,
- }
-}