0.3.2 • Published 5 years ago
mdheadline v0.3.2
MdHeadline
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 keyid) - Class attributes
# Chapter 1 { .highlighted .pivot }(are mapped as an array to the keyclasses) - 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.