Giter Club home page Giter Club logo

parse-latex's Introduction

Parse LaTeX – a Lua filter

GitHub build status

A filter to use when the input contains raw LaTeX that should be included in other output formats. The filter uses pandoc's LaTeX reader to parse raw snippets.

Functionality

The intended use for this filter are cases in which a Markdown document contains LaTeX snippets that are not just formatting additions, but a part of the content. Any raw LaTeX snippet, such as \textcolor{red}{lorem ipsum}, will be parsed as LaTeX. The result is then re-inserted into the document, replacing the snippet. The above will yield <span style="color: red">lorem ipsum</span> when converting to HTML.

The snippets will be passed through unchanged when converting to LaTeX/PDF.

The filter is particularly useful with tables: it becomes possible to use some of extra power of LaTeX, while still getting sensible output with other formats. E.g.:

```{=latex}
\begin{tabular}{|l|l|}
 \hline
 one & two \\
 \hline
 three & four \\
 \hline
\end{tabular}
```

The PDF output will have horizontal and vertical table lines, something that's otherwise difficult to accomplish with pandoc.¹

The filter uses pandoc's LaTeX parser, so if pandoc cannot parse a LaTeX snippet, then neither can this filter.

¹ The reason for this is that vertical lines in tables are considered as ugly and bad style by most typographers.

Usage

Pass the filter to pandoc via the --lua-filter (or -L) command line option.

pandoc --lua-filter parse-latex.lua ...

Raw LaTeX blocks and inlines will be parsed by pandoc and inserted back into the document. The filter does nothing when converting to LaTeX, and the original snippets are passed through in this case.

Users of Quarto can install this filter as an extension with

quarto install extension tarleb/parse-latex

and use it by adding parse-latex to the filters entry in their YAML header.

---
filters:
  - parse-latex
---

License

This pandoc Lua filter is published under the MIT license, see file LICENSE for details.

parse-latex's People

Contributors

ifitrains avatar tarleb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

parse-latex's Issues

Harmonize Hyperlinks

Is there perhaps a way to reach the same style of hyperlinks using your filter, i.e. get the same output using \ref as using quarto's @?

MWE:

---
filters:
  - parse-latex
---

\section{First Section}     \label{first section}

Reference to \ref{first section}.


# Second Section {#sec-second-section}

Reference to @sec-second-section.

image

Problem installing extension

I operate on quarto 1.2. and downloaded the most recent quarto version from here. I can install other extensions. I get the following error when trying to run quarto install extension tarleb/parse-latex:

[>] Downloading
parse-latex-main/parse-latex.lua: Can't create '\\?\C:\Users\xxx\AppData\Local\Temp\quarto-session7f3e7ca9\71bfff44\2878763e\archive\parse-latex-main\parse-latex.lua'
tar.exe: Error exit delayed from previous errors.
[>] Unzipping
ERROR: Failed to unzip extension.
parse-latex-main/parse-latex.lua: Can't create '\\?\C:\Users\xxx\AppData\Local\Temp\quarto-session7f3e7ca9\71bfff44\2878763e\archive\parse-latex-main\parse-latex.lua'
tar.exe: Error exit delayed from previous errors.

Use with crossref

Hello, thanks for the awesome plugin, I just have a question to format tables, when I Run pandoc-crossref and create a docx document is well displayed, but it's not using the numbering system created by crossref, is there a way to set up using it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.