Publican v0.7.0 update

By Craig Buckler

325 words, 2-minute read

plugin
Image courtesy of Alexandre Debiève

Publican v0.7.0 was released on .

There are no breaking changes, but you can now use markdown-it plugins to provide greater control over HTML conversion.

markdown-it plugin support #

Publican offers custom event hooks such as processContent to alter the rendered HTML. This can involve complex regular expression functions such as adding semantic markdown blocks.

Publican uses markdown-it for markdown to HTML conversion. The module offers hundreds of plugins which you can now use in Publican v0.7.0.

For example, the markdown-it-attrs plugin allows you to add HTML attributes, e.g.

markdown input

# Heading {#my-heading .custom-style}
Some text. {style="color:red;"}

results in:

HTML output

<h1 id="my-heading" class="custom-style">Heading</h1>
<p style="color:red;">Some text.</p>

To use it, install the plugin in your project:

terminal

npm install markdown-it-attrs

then .add() an array to the publican.config.markdownOptions.use Set which defines the module and any required parameters:

publican.config.js excerpt

import markdownItAttrs from 'markdown-it-attrs';

// add markdown-it-attrs plugin
publican.config.markdownOptions.use.add(
  [ markdownItAttrs, { leftDelimiter: '{', rightDelimiter: '}' } ]
);

You can .add() any number of markdown-it plugins using similar code.

Get started #

The Publican documentation provides a quick start guide, a detailed set-up guide, API references, and common recipes you can use and adapt for your own projects.