npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rebber

v5.5.0

Published

Stringifies MDAST to LaTeX

Downloads

327

Readme

rebber Build Status Coverage Status

rebber is a LaTeX stringifier for remark

remark-rebber version compatibility

Starting from version 8.0.0, remark dropped support for footnotes; hence, rebber also dropped it's support starting from version 6.0.0.

Therefore, we have the following compatibility table for remark-rebber versions:

| remark | rebber | | ------- | ------- | | < 8.0.0 | < 6.0.0 | | > 8.0.0 | any |

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) => ``,
options.link
(displayText, url, title) => ``,
options.linkReference
(reference, content) => ``,
options.list
(content, isOrdered) => ``,
options.listItem
(content) => ``,
options.text
(text) => ``,
options.thematicBreak
() => ``,
options.table
(ctx, node) => ``,

Table stringification can be configured with some advanced options:

options.tableEnvName
`longtblr`

Name of the environment to be used for tables. Allows defining custom environments in LaTeX with \NewTblrEnviron. To ensure a flexible rendering, the longtblr environment is used by default.

options.headerCounter: (node) => 1
(tableRows) => 1

Function that counts the number of header rows (rows that should be emphasized).

options.headerProperties
`font=\bfseries`

LaTeX properties added to header rows, follows the syntax of the underlying LaTeX package.

options.headerParse
(tableRows) => ``

Function that computes the "latex header" part of the table environment, this generates strings such as |c|c|r|. It gets an array of all the tableRow mdast nodes for the table as argument. Default function extracts the number of columns for each row and uses the X[-1] handler ("find the best available width"). The result for a 3 column-table is |X[-1]|X[-1]|X[-1]|.

Related

  • rebber-plugins
    • A collection of rebber plugins able to stringify custom Remark node types.

License

MIT © Zeste de Savoir