1.2.14 • Published 3 years ago

remark-align v1.2.14

Weekly downloads
1,067
License
MIT
Repository
github
Last release
3 years ago

remark-align Build Status Coverage Status

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

AST node (see mdast specification)

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

LeftAligned

interface LeftAligned <: Parent {
  type: "leftAligned";
  data: {
    hName: "div";
    hProperties: {
      class: string;
    }
  }
}

CenterAligned

interface CenterAligned <: Parent {
  type: "centerAligned";
  data: {
    hName: "div";
    hProperties: {
      class: string;
    }
  }
}

RightAligned

interface RightAligned <: Parent {
  type: "rightAligned";
  data: {
    hName: "div";
    hProperties: {
      class: string;
    }
  }
}

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

1.2.14

3 years ago

1.2.13

4 years ago

1.2.12

4 years ago

1.2.10

4 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago