The marked markdown processor for Node.js with a simple metadata system added on.
Just a quick extension I needed for processing markdown in Node. Props to Christopher Jeffrey for his excellent markdown processor 'marked'.
The meta-marked
function behaves exactly the same as marked
, except for the following:
- Instead of returning a parsed string,
meta-marked
returns an object with two properties:meta
, which contains the metadata object, andhtml
, which contains the parsed HTML. metaMarked.noMeta
is a reference to themarked
function, so it can be used to avoid parsing metadata.
The metadata system used here is based on MultiMarkdown. It consists of key: value pairs at the top of the document, followed by a blank line. A line starting with whitespace is treated as a list item for the previous key. For example, running metaMarked(...)
on this text:
Title: My awesome markdown file
Author: Me
Scripts: js/doStuff.js
js/doMoreStuff.js
##Header
Regular text and stuff goes here.
will result in the following output:
{
"meta": {
"Title": "My awesome markdown file",
"Author": "Me",
"Scripts": [
"js/doStuff.js",
"js/doMoreStuff.js"
]
},
"html": "<h2>Header</h2>\n<p>Regular text and stuff goes here.</p>\n"
}
Note that only string->string and non-nested string->array pairs are supported. Any whitespace before and after the colon and at end of the line is ignored.
Licensed under the MIT License. © 2013 j201