chdemko / pandoc-latex-environment

Pandoc filter for adding LaTeX environement on specific div
https://pandoc-latex-environment.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
34 stars 9 forks source link

Labels and titles for latex environments #4

Closed jefelino closed 6 years ago

jefelino commented 6 years ago

I've added two features to your script that I found useful. I've created this PR in case you think they'd be generally useful.

  1. If a converted div has an id attribute, then use that as a \label within the latex environment.
  2. If a converted div has a title attribute, then pass that as an optional argument to the latex environment.

For example:

---
pandoc-latex-environment:
    theorem: [theorem]
---
<div id="thm:cantor" title="Cantor's Theorem" class="theorem">
Every set has more subsets than elements.
</div>

This converts to:

\begin{theorem}[Cantor's Theorem] \label{thm:cantor}

Every set has more subsets than elements.

\end{theorem}

I'm using this together with another filter that converts certain internal links to latex cross-references, which is why the \label{thm:cantor} is useful.

One other note: in the tests, you had the same metadata construction repeated in multiple tests. I copied this style in the new tests I added, since I didn't know if you had a reason for it, but I think it would probably make sense to factor that out to simplify the testing code. I'm happy to make that minor change if you'd like me to do it.

Thanks for sharing your helpful filters!

Best, Jeff

coveralls commented 6 years ago

Coverage Status

Coverage increased (+1.4%) to 94.286% when pulling fadf434095b46875b0e56c784a5ab3f79519f4f3 on jefelino:label-title into 372e09b6e07f8c50b5bbb212f1df2999ec3c638e on chdemko:master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+1.4%) to 94.286% when pulling fadf434095b46875b0e56c784a5ab3f79519f4f3 on jefelino:label-title into 372e09b6e07f8c50b5bbb212f1df2999ec3c638e on chdemko:master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+1.4%) to 94.286% when pulling fadf434095b46875b0e56c784a5ab3f79519f4f3 on jefelino:label-title into 372e09b6e07f8c50b5bbb212f1df2999ec3c638e on chdemko:master.

chdemko commented 6 years ago

Thanks for this usefull PR.