diff options
Diffstat (limited to 'paper/lua-filters/short-captions')
-rw-r--r-- | paper/lua-filters/short-captions/Makefile | 18 | ||||
-rw-r--r-- | paper/lua-filters/short-captions/README.md | 52 | ||||
-rw-r--r-- | paper/lua-filters/short-captions/expected-1.tex | 67 | ||||
-rw-r--r-- | paper/lua-filters/short-captions/expected-2.tex | 67 | ||||
-rw-r--r-- | paper/lua-filters/short-captions/fig.pdf | bin | 56971 -> 0 bytes | |||
-rw-r--r-- | paper/lua-filters/short-captions/short-captions.lua | 37 |
6 files changed, 0 insertions, 241 deletions
diff --git a/paper/lua-filters/short-captions/Makefile b/paper/lua-filters/short-captions/Makefile deleted file mode 100644 index 756cf2b..0000000 --- a/paper/lua-filters/short-captions/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -LF = --lua-filter=short-captions.lua -F = -F pandoc-crossref - -test: - @pandoc $(LF) README.md -w latex | diff --strip-trailing-cr expected-1.tex - - -crossref: - @echo testing short-captions.lua after pandoc-crossref - @pandoc $(F) $(LF) README.md -w latex | diff --strip-trailing-cr expected-2.tex - - @echo testing short-captions.lua before pandoc-crossref - @pandoc $(LF) $(F) README.md -w latex | diff --strip-trailing-cr expected-2.tex - - -readme: - @pandoc -s $(F) $(LF) README.md -o README.pdf - -latex: - @pandoc -s $(F) $(LF) README.md -o README.tex - diff --git a/paper/lua-filters/short-captions/README.md b/paper/lua-filters/short-captions/README.md deleted file mode 100644 index 2721004..0000000 --- a/paper/lua-filters/short-captions/README.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: "short-captions.lua" -lof: true ---- - -# Short captions in \LaTeX\ output - -For latex output, this filter uses the attribute `short-caption` for -figures so that the attribute value appears in the List of Figures, if -one is desired. - -# Usage - -Where you would have a figure in, say, markdown as - - ![The caption](foo.png ) - -You can now specify the figure as - - ![The long caption](foo.png){short-caption="a short caption"} - -If the document metadata includes `lof:true`, then the List of Figures -will use the short caption. This is particularly useful for students -writing dissertations, who often have to include a List of Figures in -the front matter, but where figure captions themselves can be quite -lengthy. - - pandoc --lua-filter=short-captions.lua article.md -o article.tex - - pandoc --lua-filter=short-captions.lua article.md -o article.pdf - - - -# Example - -@Fig:shortcap is an interesting figure with a long caption, but a short -caption in the List of Figures. - -![This is an *extremely* interesting figure that has a lot of detail I -will need to describe in a few sentences. This figure has a short -caption that will appear in the list of figures. Other attributes are -preserved](fig.pdf){#fig:shortcap short-caption="A short caption with -math $x^n + y^n = z^n$" width="50%"} - - -# Limitations - -- The filter will process the `short-caption` attribute value as pandoc - markdown, regardless of the input format. -- It does not work for tables and listings yet. -- But it works with pandoc-crossref, regardless of the order of - application. diff --git a/paper/lua-filters/short-captions/expected-1.tex b/paper/lua-filters/short-captions/expected-1.tex deleted file mode 100644 index a28bb7e..0000000 --- a/paper/lua-filters/short-captions/expected-1.tex +++ /dev/null @@ -1,67 +0,0 @@ -\hypertarget{short-captions-in-output}{% -\section{\texorpdfstring{Short captions in -\LaTeX~output}{Short captions in ~output}}\label{short-captions-in-output}} - -For latex output, this filter uses the attribute \texttt{short-caption} -for figures so that the attribute value appears in the List of Figures, -if one is desired. - -\hypertarget{usage}{% -\section{Usage}\label{usage}} - -Where you would have a figure in, say, markdown as - -\begin{verbatim} -![The caption](foo.png ) -\end{verbatim} - -You can now specify the figure as - -\begin{verbatim} -![The long caption](foo.png){short-caption="a short caption"} -\end{verbatim} - -If the document metadata includes \texttt{lof:true}, then the List of -Figures will use the short caption. This is particularly useful for -students writing dissertations, who often have to include a List of -Figures in the front matter, but where figure captions themselves can be -quite lengthy. - -\begin{verbatim} -pandoc --lua-filter=short-captions.lua article.md -o article.tex - -pandoc --lua-filter=short-captions.lua article.md -o article.pdf -\end{verbatim} - -\hypertarget{example}{% -\section{Example}\label{example}} - -@Fig:shortcap is an interesting figure with a long caption, but a short -caption in the List of Figures. - -\hypertarget{fig:shortcap}{% -\begin{figure} -\centering -\includegraphics[width=0.5\textwidth,height=\textheight]{fig.pdf} -\caption[{A short caption with math \(x^n + y^n = z^n\)}]{This is an -\emph{extremely} interesting figure that has a lot of detail I will need -to describe in a few sentences. This figure has a short caption that -will appear in the list of figures. Other attributes are preserved} -\label{fig:shortcap} -\end{figure} -} - -\hypertarget{limitations}{% -\section{Limitations}\label{limitations}} - -\begin{itemize} -\tightlist -\item - The filter will process the \texttt{short-caption} attribute value as - pandoc markdown, regardless of the input format. -\item - It does not work for tables and listings yet. -\item - But it works with pandoc-crossref, regardless of the order of - application. -\end{itemize} diff --git a/paper/lua-filters/short-captions/expected-2.tex b/paper/lua-filters/short-captions/expected-2.tex deleted file mode 100644 index 95444b3..0000000 --- a/paper/lua-filters/short-captions/expected-2.tex +++ /dev/null @@ -1,67 +0,0 @@ -\hypertarget{short-captions-in-output}{% -\section{\texorpdfstring{Short captions in -\LaTeX~output}{Short captions in ~output}}\label{short-captions-in-output}} - -For latex output, this filter uses the attribute \texttt{short-caption} -for figures so that the attribute value appears in the List of Figures, -if one is desired. - -\hypertarget{usage}{% -\section{Usage}\label{usage}} - -Where you would have a figure in, say, markdown as - -\begin{verbatim} -![The caption](foo.png ) -\end{verbatim} - -You can now specify the figure as - -\begin{verbatim} -![The long caption](foo.png){short-caption="a short caption"} -\end{verbatim} - -If the document metadata includes \texttt{lof:true}, then the List of -Figures will use the short caption. This is particularly useful for -students writing dissertations, who often have to include a List of -Figures in the front matter, but where figure captions themselves can be -quite lengthy. - -\begin{verbatim} -pandoc --lua-filter=short-captions.lua article.md -o article.tex - -pandoc --lua-filter=short-captions.lua article.md -o article.pdf -\end{verbatim} - -\hypertarget{example}{% -\section{Example}\label{example}} - -Fig.~\ref{fig:shortcap} is an interesting figure with a long caption, -but a short caption in the List of Figures. - -\hypertarget{fig:shortcap}{% -\begin{figure} -\centering -\includegraphics[width=0.5\textwidth,height=\textheight]{fig.pdf} -\caption[{A short caption with math \(x^n + y^n = z^n\)}]{This is an -\emph{extremely} interesting figure that has a lot of detail I will need -to describe in a few sentences. This figure has a short caption that -will appear in the list of figures. Other attributes are preserved} -\label{fig:shortcap} -\end{figure} -} - -\hypertarget{limitations}{% -\section{Limitations}\label{limitations}} - -\begin{itemize} -\tightlist -\item - The filter will process the \texttt{short-caption} attribute value as - pandoc markdown, regardless of the input format. -\item - It does not work for tables and listings yet. -\item - But it works with pandoc-crossref, regardless of the order of - application. -\end{itemize} diff --git a/paper/lua-filters/short-captions/fig.pdf b/paper/lua-filters/short-captions/fig.pdf Binary files differdeleted file mode 100644 index cac7f39..0000000 --- a/paper/lua-filters/short-captions/fig.pdf +++ /dev/null diff --git a/paper/lua-filters/short-captions/short-captions.lua b/paper/lua-filters/short-captions/short-captions.lua deleted file mode 100644 index 9aaf309..0000000 --- a/paper/lua-filters/short-captions/short-captions.lua +++ /dev/null @@ -1,37 +0,0 @@ -if FORMAT ~= "latex" then - return -end - -local function latex(str) - return pandoc.RawInline('latex', str) -end - -function figure_image (elem) - local image = elem.content and elem.content[1] - return (image.t == 'Image' and image.title == 'fig:') - and image - or nil -end - -function Para (para) - local img = figure_image(para) - if not img or not img.caption or not img.attributes['short-caption'] then - return nil - end - - local short_caption = pandoc.Span( - pandoc.read(img.attributes['short-caption']).blocks[1].c - ) - local hypertarget = "{%%\n" - local label = "\n" - if img.identifier ~= img.title then - hypertarget = string.format("\\hypertarget{%s}{%%\n",img.identifier) - label = string.format("\n\\label{%s}",img.identifier) - end - return pandoc.Para { - latex(hypertarget .. "\\begin{figure}\n\\centering\n"), - img, - latex("\n\\caption["), short_caption, latex("]"), pandoc.Span(img.caption), - latex(label .."\n\\end{figure}\n}\n") - } -end |