LaTeX2Markdown 0.2.1

An AMS-LaTeX compatible converter that maps a subset of LaTeX to Markdown/MathJaX
LaTeX2Markdown is an AMS-LaTeX compatible converter from (a subset of) LaTeX to MathJaX compatible Markdown.

Who should use this?

Anyone who writes LaTeX documents using the AMS-LaTeX packages (amsmath, amsthm, amssymb) and wants to convert these documents to Markdown format to use with MathJaX. The outputted Markdown files can then be easily added to any web platform - Jekyll blogs, Wordpress, basic HTML sites, etc.

In short, if you seek to use MathJaX to view your LaTeX documents online, then you might be interested in this.

Demonstration

Check out tullo.ch/projects/LaTeX2Markdown for a live demonstration of the converter.

Getting Started

Installation

The project is available on PyPI, so getting it is as simple as using

pip install latex2markdown

or

easy_install latex2markdown

Usage

The utility can be called from the command line, or from within a Python script.

For the command line, the syntax to convert a LaTeX file to a Markdown file is as follows:

python latex2markdown.py path/to/latex/file path/to/output/markdown/file

For example, to compile the example LaTeX document, call

python latex2markdown.py examples/latex_sample.tex markdown_example.tex


To use it within a Python script, use it as follows:

import latex2markdown
with open("latex_file.tex", "r") as f:
 latex_string = f.read()

l2m = latex2markdown.LaTeX2Markdown(latex_string)

markdown_string = l2m.to_markdown()

with open("markdown_file.md", "w") as f:
 f.write(markdown_string)


Finally, add the following snippet to your HTML when loading this document.

< script type="text/x-mathjax-config" >
 MathJax.Hub.Config({
 extensions: ["tex2jax.js", "AMSmath.js"],
 jax: ["input/TeX", "output/HTML-CSS"],
 tex2jax: {
 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
 displayMath: [ ['$$','$$'], ["\[","\]"] ],
 processEscapes: true
 },
 });
< /scrip t>
< script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" >
< /script >


For a working example, have a look at the source of the tullo.ch homepage here.

last updated on:
April 2nd, 2012, 23:23 GMT
price:
FREE!
homepage:
github.com
license type:
Other/Proprietary License
developed by:
Andrew Tulloch
category:
ROOT \ Text Editing&Processing \ Markup
LaTeX2Markdown
Download Button

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT