Socket
Book a DemoInstallSign in
Socket

asciidoctor-katex

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asciidoctor-katex

Asciidoctor extension that converts latexmath to HTML using KaTeX at build-time

latest
Source
npmnpm
Version
0.4.1
Version published
Weekly downloads
38
111.11%
Maintainers
1
Weekly downloads
 
Created
Source

This project provides an Asciidoctor extension for converting block and inline STEM in TeX notation (latexmath) to HTML using KaTeX library right during document conversion (instead of in browser on client-side).

Requirements

Installation

Install asciidoctor-katex from npmjs.com:

npm install --save asciidoctor-katex

Usage

// Load asciidoctor.js and asciidoctor-katex.
const asciidoctor = require('@asciidoctor/core')()
const asciidoctorKatex = require('asciidoctor-katex')

// See documentation at the end of this section.
const options = {
  katexOptions: {
    macros: {
      "\\RR": "\\mathbb{R}",
    },
  },
}

// Configure the extension and register it into global registry.
asciidoctorKatex.register(asciidoctor.Extensions, options)

// Convert the content to HTML.
const content = `
:stem: latexmath

Do some math: stem:[E = mc^2]
`
const html = asciidoctor.convert(content)
console.log(html)

You may also register the extension into a custom extensions registry:

const registry = asciidoctor.Extensions.create()
asciidoctorKatex.register(registry, options)

katex
The katex object to use for rendering. Defaults to require('katex').

requireStemAttr
Whether to require stem attribute to be defined (Asciidoctor’s standard behaviour). Set to false to process latexmath even when stem attribute is not defined. Default is true.
Note that the default stem type hard-coded by Asciidoctor is asciimath (not latexmath), so [stem] block and stem:[...] macro will not be rendered anyway (only [latexmath] block and latexmath:[...] macro).

katexOptions
The default options for katex.render(). Defaults to empty object.

License

This project is licensed under MIT License. For the full text of the license, see the LICENSE file.

Keywords

asciidoctor

FAQs

Package last updated on 08 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts