Constructor
new MdFence()
- Source:
Example
var md = fs.readFileSync('README.md', {encoding: 'utf8'});
var fence = new MdFence(['vg', 'vega', 'vega-lite', 'vl']);
console.log(fence.eat(md).blocks); // prints parsed blocks
Members
blocks
A internal list of `block` that has been parsed but not been transformed yet.
- Source:
Methods
(static) block2String(block) → {String}
Convert a `Block` back to its String form.
Parameters:
Name | Type | Description |
---|---|---|
block |
Block |
- Source:
Returns:
- Type
- String
(static) getFenceLang(feed) → {String}
Extract the language string after the code block.
Parameters:
Name | Type | Description |
---|---|---|
feed |
TextFeed |
- Source:
Returns:
- Type
- String
(static) isFence(feed, symbol) → {Object}
Peek and check if it is a fence. If so return the symbol used, and the
String used to open or close the fence.
Return false if not a fence.
Parameters:
Name | Type | Description |
---|---|---|
feed |
TextFeed | |
symbol |
String |
- Source:
Returns:
- Type
- Object
eat(str) → {MdFence}
Consume a String and update the internal `Blocks`. You can call `eat`
multiple times as the internal state will be updated. Return a reference
to itself.
Parameters:
Name | Type | Description |
---|---|---|
str |
String | Markdown string to parse. |
- Source:
Returns:
- Type
- MdFence
flush() → {MdFence}
Flush any unfinished blocks. Will close any `fence` if not closed.
- Source:
Returns:
- Type
- MdFence
transform(fnopt) → {Promise}
Resolve all the current `Blocks` and transform them. Will empty the current
`Block` queue. Return a `Promise` as the transform function can be async.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fn |
function |
<optional> |
({content, lang}) => content | Transform function that takes in a `Block` object and output a String. |
- Source:
Returns:
- Type
- Promise