Skip to content

debatem1/Markdown-LaTeX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Markdown-LaTeX

This Markdown extension adds support for inline LaTeX expressions.

Modes

Markdown-LaTeX can technically allow for any sort of LaTeX expression, but there are three main modes that make writing everything much easier.

%TEXT% mode

The most basic of the modes is %TEXT% mode. Any expression within %TEXT% will be parsed in a basic LaTeX text-mode, e.g. plain. For example, %"Justin Bruce Van Horne"% will output: �klzzwxh:0000��klzzwxh:0001�My�klzzwxh:0002�name�klzzwxh:0003�is�klzzwxh:0004�Justin�klzzwxh:0005�Bruce�klzzwxh:0006�Van�klzzwxh:0007�Horne. Expressions may also be multiline.

$MATH$ mode

Math mode is our second basic functinality of Markdown-LaTeX. It automatically puts LaTeX into math mode and allows for inline and multiline expressions. Let's say that we wanted to write Euler's formula: We would then write $e^{\imath x} = \cos{x} + \imath\sin{x}$ which outputs e�klzzwxh:0097��klzzwxh:0098��klzzwxh:0099�math�klzzwxh:0100�x�klzzwxh:0101��klzzwxh:0102��klzzwxh:0103��klzzwxh:0104��klzzwxh:0105�os�klzzwxh:0106�x�klzzwxh:0107��klzzwxh:0108��klzzwxh:0109��klzzwxh:0110��klzzwxh:0111�math�klzzwxh:0112�in�klzzwxh:0113�x�klzzwxh:0114�.

%%PREAMBLE%% mode

Preamble mode is the only "complex" mode. It allows you to add to the preamble of the LaTeX template. So, if there are specific packages or commands you want for the HTML page, then this is where to do it. This is a global modifier and will affect the entire document. I haven't come up with an intuitive design for a per-expression basis.

Dependencies

Markdown-LaTeX depends on:

  • LaTeX
  • dvipng
  • Python Markdown

Installation

You can either copy it into the extensions sub-directory in your markdown folder (ex: /usr/lib/python2.7/site-packages/markdown/extensions/latex.py) or use it locally with the mdx_ prefix. See Markdown Extensions for more details.

Usage

markdown -x latex somefile.markdown > somefile.html

How does it work?

The LaTex extension will search for either $text$ or %text% expressions. For each expression, it generates a tex file that is parsed by latex and then run through dvipng. The data is encoded via base64 and then inlined.

A cache file (latex.cache) is used to store all expressions and their base64 counterparts. This is to prevent latex from being run each time.

Issues

If you screw up the LaTeX in the document, chances are you are going to get a funny output or even nothing at all. This is due to the way LaTeX handles errors. For the most part hitting "q" at a broken terminal and then consulting the resulting logfile is your best bet for sanity.


Thanks to:

About

This Markdown extension adds support for LaTeX.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%