Skip to content

bmathews/meta-remarkable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meta-remarkable

The remarkable markdown processor for Node.js with support for YAML metadata

Dependency Status

The render function behaves exactly the same as remarkable, except it instead returns an object with two properties: meta, which contains the metadata object or null if metadata isn't found, and html, which contains the parsed HTML.

In order to include metadata in a document, insert YAML at the top of the document surrounded by --- and .... Note that if the given string doesn't start with ---, it will not be interpreted as having metadata.

Example

---
Title:   My awesome markdown file
Author:  Me
Scripts:
    - js/doStuff.js
    - js/doMoreStuff.js
...

##Header
Regular text and stuff goes here.

You can also use the approach below, which will result in a very nice data table at the top of your markdown when viewing the file GitHub:

---
Title:   My awesome markdown file
Author:  Me
Scripts:
    - js/doStuff.js
    - js/doMoreStuff.js
---

##Header
Regular text and stuff goes here.

Both of the above 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"
}

###Usage

Call render with the src text:

var metaRemarkable = require('meta-remarkable');
var md = new metaRemarkable();
var text = fs.readFileSync('myfile.md', 'utf8');
var res = md.render();
console.log(res.meta); // the parsed yaml->json
console.log(res.html); // the parsed md->html

All options are passed through to remarkable:

var metaRemarkable = require('meta-remarkable');
var md = new metaRemarkable('full', {
    html: false,
    linkify: true
});

Use remarkable directly:

var metaRemarkable = require('meta-remarkable');
var md = new metaRemarkable('full', {
    html: false,
    linkify: true
});
md.remarkable.set({
    html: true
});
md.remarkable.render('# some markdown'); // bypass meta-remarkable.

###Install With npm do:

npm install meta-remarkable

###Testing

npm test

###License

Licensed under the MIT License.

Derived from meta-marked.

About

The 'remarkable' markdown processor for Node.js with a yaml metadata system added on.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%