Skip to content

shi-yan/markdown-it-texmath

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License npm npm

markdown-it-texmath

Add TeX math equations to your Markdown documents rendered by markdown-it parser. KaTeX is used as a fast math renderer.

Features

Simplify the process of authoring markdown documents containing math formulas. This extension is a comfortable tool for scientists, engineers and students with markdown as their first choice document format.

  • Macro support
  • Simple formula numbering
  • Inline math with tables, lists and blockquote.
  • User setting delimiters:
    • 'dollars' (default)
      • inline: $...$
      • display: $$...$$
      • display + equation number: $$...$$ (1)
    • 'brackets'
      • inline: \(...\)
      • display: \[...\]
      • display + equation number: \[...\] (1)
    • 'gitlab'
      • inline: $`...`$
      • display: ```math ... ```
      • display + equation number: ```math ... ``` (1)
    • 'kramdown'
      • inline: $$...$$
      • display: $$...$$
      • display + equation number: $$...$$ (1)

Show me

View a test table.

try it out ...

Use with node.js

Install the extension. Verify having markdown-it and katex already installed .

npm install markdown-it-texmath

Use it with JavaScript.

let kt = require('katex'),
    tm = require('markdown-it-texmath').use(kt),
    md = require('markdown-it')().use(tm,{delimiters:'dollars',macros:{"\\RR": "\\mathbb{R}"}});

md.render('Euler\'s identity \(e^{i\pi}+1=0\) is a beautiful formula in $\\RR 2$.')

Use in Browser

<html>
<head>
  <meta charset='utf-8'>
  <link rel="stylesheet" href="katex.min.css">
  <link rel="stylesheet" href="texmath.css">
  <script src="markdown-it.min.js"></script>
  <script src="katex.min.js"></script>
  <script src="texmath.js"></script>
</head>
<body>
  <div id="out"></div>
  <script>
    let md;
    document.addEventListener("DOMContentLoaded", () => {
        const tm = texmath.use(katex);
        md = markdownit().use(tm,{delimiters:'dollars',macros:{"\\RR": "\\mathbb{R}"}});
        out.innerHTML = md.render('Euler\'s identity $e^{i\pi}+1=0$ is a beautiful formula in //RR 2.');
    })
  </script>
</body>
</html>

CDN

Use following links for texmath.js and texmath.css

  • https://gitcdn.xyz/cdn/goessner/markdown-it-texmath/master/texmath.js
  • https://gitcdn.xyz/cdn/goessner/markdown-it-texmath/master/texmath.css

Dependencies

  • markdown-it: Markdown parser done right. Fast and easy to extend.
  • katex: This is where credits for fast rendering TeX math in HTML go to.

ToDo

nothing yet

CHANGELOG

[0.5.3] on November 11, 2018

[0.5.2] on September 07, 2018

[0.5.0] on August 15, 2018

  • Fatal blockquote bug investigated. Implemented workaround to vscode bug, which has finally gone with vscode 1.26.0 .

[0.4.6] on January 05, 2018

  • Escaped underscore bug removed.

[0.4.5] on November 06, 2017

  • Backslash bug removed.

[0.4.4] on September 27, 2017

  • Modifying the block mode regular expression with gitlab delimiters, so removing the newline bug.

License

markdown-it-texmath is licensed under the MIT License

© Stefan Gössner

About

Support TeX math equations with your Markdown documents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 81.1%
  • JavaScript 18.4%
  • CSS 0.5%