Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rebber

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rebber

Stringifies MDAST to LaTeX

  • 2.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66
increased by94.12%
Maintainers
2
Weekly downloads
 
Created
Source

rebber Build Status Coverage Status

rebber is a LaTeX stringifier for remark

Installation

npm:

npm install rebber

Usage

const unified = require('unified')
const remarkParser = require('remark-parse')
const rebber = require('rebber')

const {contents} = unified()
  .use(remarkParser)
  .use(rebber)
  .processSync('### foo')

console.log(contents);

Yields:

\section{foo}

API

toLaTeX(node[, options])

Stringify the given MDAST node.

options.overrides

Overrides are named that way because they can override any MDAST node type to latex stringifier. Their other use is to use custom latex stringifier for custom MDAST node type.

Examples:

const {contents} = unified()
  .use(remarkParser)
  .use(remarkFoobarElementsParser) // creates MDAST nodes of type 'foobar'
  .use(rebber, {
    overrides: {
      // override rebber's method to turn MDAST link nodes into latex
      link: require('./your-own-link-latexifier')
      // tell rebber what to use to turn MDAST foobar nodes into latex
      foobar: require('./your-foobar-latexifier')
    }
  })

options.<mdastNodeType>

MDAST nodes are stringified to LaTeX using sensible default LaTeX commands. However, you can customize most of the LaTeX command corresponding to MDAST nodes. Here are documented the function signatures of these customizable commands. Note that the keys of the options object are named after the corresponding MDAST node type.

For example, by default, ![](/foo.png) will get compiled to \includegraphics{/foo.png}.

Setting

options.image = (node) => `[inserted image located at "${node.url}"]`

will stringify our example Markdown to [inserted image located at "/foo.png"] instead of \includegraphics{/foo.png}.

options.blockquote
(text) => ``,
options.break
() => ``,
options.code
(textCode, lang) => ``,
options.definition
(options, identifier, url, title) => ``,
options.footnote
(identifier, text, protect) => ``,
options.footnoteDefinition
(identifier, text) => ``,
options.footnoteReference
(identifier) => ``,
options.headings
[
  (text) => ``, // level 1 heading
  (text) => ``, // level 2 heading
  (text) => ``, // level 3 heading
  (text) => ``, // level 4 heading
  (text) => ``, // level 5 heading
  (text) => ``, // level 6 heading
  (text) => ``, // level 7 heading
],
options.image
(node) => ``,
(displayText, url, title) => ``,
options.linkReference
(reference, content) => ``,
options.list
(content, isOrdered) => ``,
options.listItem
(content) => ``,
options.text
(text) => ``,
options.thematicBreak
() => ``,
  • rebber-plugins — A collection of rebber plugins able to stringify custom Remark node types.

License

MIT © Zeste de Savoir

Keywords

FAQs

Package last updated on 22 Jul 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc