node package manager

remark-align

remark-align Build Status Coverage Status

This plugin parses custom Markdown syntax to center- or right-align elements.

It adds three new node types to the mdast produced by remark:

  • LeftAligned
  • CenterAligned
  • RightAligned

If you are using rehype, the stringified HTML result will be divs with configurable CSS classes.

It is up to you to have CSS rules producing the desired result for these three classes.

Syntax

Alignment is done by wrapping something in arrows indicating the alignment:

->paragraph<-
 
->paragraph->

produces:

<div class="some-class"><p>paragraph</p></div>
<div class="some-other-class"><p>paragraph</p></div>

Installation

npm:

npm install remark-align

Usage

Dependencies:

const unified = require('unified')
const remarkParse = require('remark-parse')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')
 
const remarkAlign = require('remark-align')

Usage:

unified()
  .use(remarkParse)
  .use(remarkAlign, {
    left: 'align-left',
    center: 'align-center',
    right: 'align-right',
  })
  .use(remark2rehype)
  .use(stringify)

License

MIT © Zeste de Savoir