MarTeX-Cpp

MarTeX-Cpp is a flexable, extendable and fast TeX-to-HTML converter by fully tokenizing-lexing-parsing-interpreting the TeX source. It can be compiled to serve as a module for different languages, like PHP or JavaScript. It's goal is to provide a way to allow users to write TeX they are familiar with to produce nice looking pages like this one, but without allowing code injection.

Styling

Special Characters

Just throw any old unicode into martex and it will work. You can also use these escape codes:

Command Result Command Result
\& & \"AaEeIiOoUuy ÄäËëÏïÖöÜüÿ
\% % \'AaEeIiOoUuZ ÁáÉéÍíÓóÚúŹ
\$ $ \`AaEeIiOoUu ÀàÈèÌìÒòÙù
\copy © \^AaEeIiOoUu ÂâÊêÎîÔôÛû
\> > \^AaEeIiOoUu ÂâÊêÎîÔôÛû
\< < \~AaIiOoNnUu ÃãĨĩÕõÑñŨũ
\} } \.AaUu ÅåŮů
\{ { \-Oo Øø
\cdot · \ss ß
\pm ± \func ƒ
\tm \reg ®
\euro \Alpha\alpha Αα
\pound £ \Beta\beta Ββ
\deg ° ...
\backslash \ \Omega\omega Ωω

Images

Images are pretty. Normally the images try to fill the page width, you can control this behaviour with the provided sizing options. If you add a caption to an image it will put "Figure 1: caption" under it. You can change "Figure" to , for example, "Picture" by setting the header with a \define{header}{Picture }.

\begin{figure}
    \includegraphics{test.png}
    \caption{This is a test image}
    \label{testimage}
    \width{120px}
    \height{30}
    \alttext{A mouse!}
\end{figure}

Lists

Note that there are two different list environments: enumerate and itemize with a different default markers, respectively numbers and bullets.

Example
Code Rendered
\begin{itemize}
    \item{Akcie}
    \item{Ambicie}
    \item{Batavieren}
    \item{Boson}
\end{itemize}
\begin{itemize}
    \setmarker{square}
    \item Brouwcommissie
    \item Colloquiumcommissie
    \item Excurcie
\end{itemize}
\begin{enumerate}
    \item{Impuls}
    \item{Lustrumcie}
    \item{Münchencie}
\end{enumerate}
\begin{enumerate}
    \setmarker{letters}
    \item{Ouderdagcie}
    \item{Particie}
    \item{PR-cie}
    \item{Reunistencie}
\end{enumerate}
\begin{enumerate}
    \setmarker{ROMAN}
    \item Sponsorcommissie
    \item Symposiumcie
    \item Vakancie
    \item Weekendcommissie
    \item WWW-cie
    \item Coördinatiecommissie
\end{enumerate}
  • Akcie
  • Ambicie
  • Batavieren
  • Boson
  • Brouwcommissie
  • Colloquiumcommissie
  • Excurcie
  1. Impuls
  2. Lustrumcie
  3. Münchencie
  1. Ouderdagcie
  2. Particie
  3. PR-cie
  4. Reunistencie
  1. Sponsorcommissie
  2. Symposiumcie
  3. Vakancie
  4. Weekendcommissie
  5. WWW-cie
  6. Coördinatiecommissie

Tables

Tables are a good way to represent content in a neat way. In MarTeX they behave pretty similar to the LaTeX tabulars. The tabular format accepts '|' for vertical lines, 'l' for left aligned column, 'c' for a centered column and 'r' for a right aligned column.

\begin{tabular}[|| l | c | r ||]
    \hline \hline
    1 & 2 & 3 \\\hline
    4 & 5 & 6 \\\hline
    7 & 8 & 9 \\\hline
    \multicolumn{3}{| c |}{0} \\
    \hline
\end{tabular}

Textual

Paragraphs

You can use double enters in the main document environment to make paragraphs but you can also do it manually:
\begin{paragraph}
    Paragraph text
\end{paragraph}

Paragraph text

Center

You can center text:

\begin{center}
    Center text
\end{center}
Center text

Details

Hide and show text using details.

\begin{details}[Summary]
    Details text
\end{details}

Summary Details text

Marie-Curie Specific functionality

Contributing

Please feel free to submit anything! The only thing I ask is that you include at least one test that verifies the behaviour of your change.

Bug Bounty Program

If you find a way insert arbitrary html tags and/or get javascript execution from a certain input string then first I'd like to congratualate you on a job well done! Please contact me privately with said input and we'll work on pushing out a fix as quickly as possible.

links

Authors

Acknowledgments

Thanks to my committee for their endless patience and enthusiasm while listening to me whining on about this.
Thanks to Diego Perini for writing a nifty regex-based URL validator.

License

This project is licensed under the MIT License - see the file for details