A plug-in style renderer to produce TeX output for marked
.
var marked = require('marked');
var TexRenderer = require('marked-tex-renderer');
marked.setOptions({
renderer: new TexRenderer()
});
console.log(marked('I am using __markdown__.'));
marked-tex-renderer
tries to be agnostic to LaTeX packages. As a result, in cannot convert some Markdown features to TeX in a straightforward manner (simply because you need packages to implement them). Therefore, marked-tex-renderer
relies on external functions for rendering these features:
- Deleted text:
~~Deleted text~~
- Hyperlinks:
Click [here](https://github.com)
- Images:
![An example image](example.png)
You can supply rendering functions for these feature in following manner:
marked.setOptions({
renderer: new TexRenderer(),
gfm: true,
failOnUnsupported: false,
delRenderer: function (text) {
// return TeX source to render deleted text
},
linkRenderer: function (href, title, text) {
// return TeX source to render hyperlinks
},
imageRenderer: function (href, title, text) {
// return TeX source to render images
}
});
However, marked-tex-renderer
provide some useful functions. You can use them, but you will have to include some \usepackage
commands in your tex files manually:
marked.setOptions({
renderer: new TexRenderer(),
gfm: true,
failOnUnsupported: false,
// requires \usepackage{ulem}
delRenderer: TexRenderer.delImpl,
// requires \usepackage{hyperref}
linkRenderer: TexRenderer.linkImpl,
// requires \usepackage{graphicx}
imageRenderer: TexRenderer.imageImpl
});
Options for marked-tex-renderer
is passed alongside with options to marked
:
marked.setOptions(options);
Following are the options for marked-tex-renderer
:
failOnUnsupported
: If set to true, an error is thrown when plain-TeX-unsupported features are used. Possible values aretrue
,false
. Default istrue
.delRenderer
: Renderer function for deleted text. Should have the signaturefunction (text)
, and should return TeX source for deleted text.linkRenderer
: Renderer function for hyperlinks. Should have the signaturefunction (href, title, text)
, and should return TeX source for hyperlink.imageRenderer
: Renderer function for images. Should have the signaturefunction (href, title, text)
, and should return TeX source for image.