-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remark-parse: add list of inline-, block-methods to docs
Related to zestedesavoir/zmarkdown#125.
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
var zone = require('mdast-zone'); | ||
var u = require('unist-builder'); | ||
var proto = require('../packages/remark-parse').Parser.prototype; | ||
|
||
module.exports = listOfMethods; | ||
|
||
function listOfMethods() { | ||
return transformer; | ||
} | ||
|
||
function transformer(tree) { | ||
zone(tree, 'methods-block', replace('blockMethods')); | ||
zone(tree, 'methods-inline', replace('inlineMethods')); | ||
} | ||
|
||
function replace(name) { | ||
var list = proto[name]; | ||
|
||
return replace; | ||
|
||
function replace(start, nodes, end) { | ||
return [ | ||
start, | ||
u('list', {ordered: false}, list.map(function (name) { | ||
return u('listItem', [ | ||
u('paragraph', [ | ||
u('inlineCode', name) | ||
]) | ||
]); | ||
})), | ||
end | ||
]; | ||
} | ||
} |