New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

marked-tex-renderer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-tex-renderer

A plug-in style renderer to produce TeX output for marked

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

marked-tex-renderer

A plug-in style renderer to produce TeX output for marked.

Usage

var marked = require('marked');
var TexRenderer = require('marked-tex-renderer');

marked.setOptions({
  renderer: new TexRenderer()
});

console.log(marked('I am using __markdown__.'));

Unsupported features of plain TeX

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

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 are true, false. Default is true.
  • delRenderer: Renderer function for deleted text. Should have the signature function (text), and should return TeX source for deleted text.
  • linkRenderer: Renderer function for hyperlinks. Should have the signature function (href, title, text), and should return TeX source for hyperlink.
  • imageRenderer: Renderer function for images. Should have the signature function (href, title, text), and should return TeX source for image.

Keywords

markdown

FAQs

Package last updated on 12 Oct 2017

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