rebber is a LaTeX stringifier for remark
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 |
npm:
npm install rebber
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}
Stringify the given MDAST node.
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')
}
})
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}
.
(text) => ``,
() => ``,
(textCode, lang) => ``,
(options, identifier, url, title) => ``,
(identifier, text, protect) => ``,
(identifier, text) => ``,
(identifier) => ``,
[
(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
],
(node) => ``,
(displayText, url, title) => ``,
(reference, content) => ``,
(content, isOrdered) => ``,
(content) => ``,
(text) => ``,
() => ``,
(ctx, node) => ``,
Table stringification can be configured with some advanced options:
`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.
(tableRows) => 1
Function that counts the number of header rows (rows that should be emphasized).
`font=\bfseries`
LaTeX properties added to header rows, follows the syntax of the underlying LaTeX package.
(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]|
.
-
rebber-plugins
- A collection of rebber plugins able to stringify custom Remark node types.