Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 618 Bytes

README.md

File metadata and controls

29 lines (22 loc) · 618 Bytes

marked-tex-extension

A tex extension for markedjs.

Usage

const texExtension = require('../index')
const marked = require('marked')
const katex = require('katex')

function texRender(tex, level) {
  let html = katex.renderToString(tex, {displayMode: level === 'block'})
  if (level === 'block') {
    html = `<p class="block-tex">${html}</p>`
  }
  return html
}

const {blockTexExtension, inlineTexExtension} = texExtension(texRender)
marked.use({
  extensions: [blockTexExtension, inlineTexExtension]
})

let html = marked.parse('your Markdown')
// ...

There is a complete example in test/test.js