From LaTeX to Jekyll markdown: towards faster post compilation

Recently, I updated my texlive distribution to 2019. I think I am experiencing a huge boost in compilation speed, though I have not yet done some serious comparison. As I start to take notes with Jekyll in this semester, a problem gradually stands out: speed. Writing with Jekyll are slow in two ways. Firstly, its compilation speed is slow. Secondly, it does not provide any navigation functionality. Therefore, if I am able to write my posts in \(\LaTeX\) and convert them into Jekyll markdown afterwards, I can potentially save a lot of time.



Just like how I used the HTMLParser class of Python to convert HTML into \(\LaTeX\), I can also use a \(\LaTeX\) parser to achieve this conversion. TexSoup is a wonderful \(\LaTeX\) parser in Python that makes everything much easier. The major difference between \(\LaTeX\) and Jekyll markdown are in the following ways:

The sample LaTeX input

A sample LaTeX input for this code is shown as below.


\newcommand{\header}[2]{{\vspace*{1em}\par\noindent\Large #2}} % dummy command for specifying header in html


\header{2}{Header 1}

\header{3}{Header 1.1}

\item \textbf{Hello}
            S=\pi r^2
\item \textit{World} $E=mc^2$

\href{}{A link}


It generates the following markdown output:

## Header 1
### Header 1.1
<ul markdown="1">
<li markdown="1">**Hello**

            S=\pi r^2

<li markdown="1">*World* $$E=mc^2$$

<a href="">A link</a>

Pasted into this page, we have the content below:

Header 1

Header 1.1

A link