0.3.2 • Published 3 years ago

mdheadline v0.3.2

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

MdHeadline

npm package dependency status build status

helper functions for processing Markdown headlines

Functions

To use a function require MdHeadline and call the function as a member of the module.

// require MdHeadline
var mdheadline = require('mdheadline');

// call a function from the module
var href = '#' + mdheadline.anchor('## 1. Einführung'); // -> '#einführung'

anchor(title)

Derives an HTML anchor for a headline. Uses the same rules as Pandoc.

getAttributes(title)

Parses the attributes of a headline and returnes a map with the found attributes. Supportes the PHP Markdown Extra syntax,

The following attribute types are supported:

  • ID attributes like # Chapter 1 { #ch_1 } (is mapped to the key id)
  • Class attributes # Chapter 1 { .highlighted .pivot } (are mapped as an array to the key classes)
  • Explicit key value pairs ## Section 1. 2. { level=2 number="1. 2." } (are mapped under thier given name)

Example:

var title = '## Chapter 1 { #ch_1 level=2 .highlighted .pivot }';
var attributes = mdheadline.getAttributes(title);

Result:

{
  "id": "ch_1",
  "classes": [ "highlighted", "pivot" ],
  "level": "2"
} 

removeFormat(title)

Strippes a headline from all formatting and optional attributes.

License

MdHeadline is published under MIT license.

0.3.2

3 years ago

0.3.1

5 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

7 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago