
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
helper-markdown
Advanced tools
Markdown template helper. Uses remarkable to render markdown in templates. Should work with Handlebars, Lo-Dash or any template engine that supports helper functions.
Markdown template helper. Uses remarkable to render markdown in templates. Should work with Handlebars, Lo-Dash or any template engine that supports helper functions.
(TOC generated by verb using markdown-toc)
Install with npm:
$ npm install --save helper-markdown
var markdown = require('helper');
Returns a function that returns the helper, allowing an options object to be passed:
var hbs = require('handlebars');
hbs.registerHelper('markdown', markdown([options]));
Example
Pass a custom highlight
function for syntax highlighting to [Remarkable][], the markdown renderer:
var hljs = require('highlight.js');
var markdown = require('helper-markdown');
function highlight(code, lang) {
try {
try {
return hljs.highlight(lang, code).value;
} catch (err) {
if (!/Unknown language/i.test(err.message)) {
throw err;
}
return hljs.highlightAuto(code).value;
}
} catch (err) {
return code;
}
}
hbs.registerHelper('markdown', markdown({
highlight: highlight
}));
With Handlebars:
<div>
{{#markdown}}
# Heading
> this is markdown
foo bar baz
{{/markdown}}
</div>
Results in:
<h1>Heading</h1>
<blockquote>
<p>this is markdown</p>
</blockquote>
<p>foo bar baz</p>
This should work with any engine, here are a few examples
The templates
library supports any templates engine supported by consolidate. To register the helper with templates:
var templates = require('templates');
var app = templates();
app.helper('markdown', require('helper-markdown'));
To register the helper for use with assemble v0.6.0 and higher:
assemble.helper('markdown', require('helper-markdown'));
Register the helper for use with verb:
var verb = require('verb');
verb.helper('markdown', require('helper-markdown'));
To register the helper with handlebars:
var handlebars = require('handlebars');
handlebars.registerHelper('markdown', require('helper-markdown'));
To register the helper with [Lo-Dash][] or underscore:
var markdown = require('helper-markdown');
// as a mixin
_.mixin({markdown: markdown});
_.template('<%= _.markdown("# heading") %>', {});
//=> '<h1>heading</h1>\n'
// passed on the context
_.template('<%= markdown("# heading") %>', {markdown: markdown});
//=> '<h1>heading</h1>\n'
// as an import
var settings = {imports: {markdown: markdown}};
_.template('<%= markdown("# heading") %>', {}, settings);
//=> '<h1>heading</h1>\n'
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
14 | jonschlinkert |
5 | doowb |
2 | almeidap |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on July 08, 2017.
FAQs
Markdown template helper. Uses remarkable to render markdown in templates. Should work with Handlebars, Lo-Dash or any template engine that supports helper functions.
The npm package helper-markdown receives a total of 81,788 weekly downloads. As such, helper-markdown popularity was classified as popular.
We found that helper-markdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.