Skip to content

a CLI parser from Markdown and LaTeX to HTML

License

Notifications You must be signed in to change notification settings

andreafra/MathMD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MathMD

Markdown + LaTeX = HTML

JavaScript Style Guide

Attention: If you're looking for a fast web library, you'll probably love KaTeX! This one is just a CLI to make HTML files from Markdown and LaTeX!

What is it?

MathMD is a simple npm package with a CLI that compiles a file written in Markdown with LaTeX expression into a single HTML file.

It's useful if you need to read math stuff on a ebook read or tablet, without messing with PDFs written too small.

Installation

  • Install Node
  • Install MathMD by pasting npm install -g mathmd in your terminal
  • Done 😃!

Usage

CLI

  • Run mathmd to start the interactive setup.

  • Run mathmd --help for details about the parameters.

Flags Description
-a, --author <string> specify an author (wrap it in quotes!)
-s, --stylesheet <path/to/file> load a custom CSS for the file
-M, --mml export with formulae in MathML
-S, --svg, export with formulae as SVG
-w, --watch, automatically compile when you save the file
-i, --interactive Run in interactive mode

By loading an external CSS stylesheet, you can customize the look of the resulting HTML file!

Programmatically

If you prefer to use it in your own program, you can use

// Import the package
const mathMD = require('mathmd')

/* ... */

// Call it
mathmd(files, options, callback)
  • files is an array of paths
  • options is the following object
let options = {
    stylesheet: 'path/to/stylesheet.css',
    author: 'John Doe',
    mathjax: { /* MathJax npm options */ },
    watch: false // Set to true to watch for changes
}

See "node options" on this page for more informations about mathjax object, or see it here below:

{
  ex: 6, // ex-size in pixels
  width: 100, // width of math container (in ex) for linebreaking and tags
  useFontCache: true, // use <defs> and <use> in svg output?
  useGlobalCache: false, // use common <defs> for all equations?
  state: mjstate, // track global state
  linebreaks: false, // do linebreaking?
  equationNumbers: "none", // or "AMS" or "all"
  math: "", // the math to typeset
  html: false, // generate HTML output?
  css: false, // generate CSS for HTML output?
  mml: false, // generate mml output?
  svg: false, // generate svg output?
  speakText: true, // add spoken annotations to output?
  timeout: 10 * 1000, // 10 second timeout before restarting MathJax
}
  • callback is a function which takes nothing as parameter.

Syntax

I recommend installing an extension like mdmath for Visual Studio Code as syntax highlighter, since it's the same one MathMD uses.

For the Markdown part, it's standard Markdown, and I used Marked as parser.

For the LaTeX part, it's standard expressions and symbol, with support of AMS Math, thanks to MathJax.

Functionalities

  • Watcher and live reload ✔︎
  • Integrated CSS with high readability ✔︎
  • Ebook friendly ✔︎
  • SVG or MathML for your expressions ✔︎
  • Expression reference ✘
  • Figure captioning ✘

About

a CLI parser from Markdown and LaTeX to HTML

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published