A minimal markdown to html converter
npm install nano-markdown[![Gitter][gitter-image]][gitter-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![NPM version][npm-image]][npm-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
1894 bytes of minified code. Supports heading, paragraphs, code, lists, horizontal rules, bold/italic/del, links and images.
``js
var nmd = require('nano-markdown');
console.log(nmd('test'));
//
test
// customizable links
nmd.href = function (ref) {
switch (ref.charAt(0)) {
case '#':
return '/case/'+ref.substr(1);
case '@':
return '/commit/'+ref.substr(1);
}
return ref;
};
console.log(nmd('test\n case #44\n commit 750945c'));
//
test
\n// customizable headers attributes
nmd.headAttrs = function (level, text) {
return ' id=\''+text.replace(/[^a-z0-9]/ig, '_').replace(/_{2,}/g, '_').replace(/^_(.?)_*$/, '$1').toLowerCase()+'\'';
};
console.log(nmd('# Header text'));
//
Heading
`
foo
foo
$3
#### foo
##### foo
###### foo
foo ############################
foo ###########################
$3
#### foo #########################
##### foo ########################
###### foo #######################
`Images
* !image alt text
* !image alt textLinks
* link text
* open link in new window
* link with titleBold/Italic/Del
* __bold__, bold
_italic_, italic*
* ~~deleted text~~Horizontal Rules
`
---
- - - -
-- -- -- -- --
------------------------
`Lists
`
* unordered list
1. ordered list
1. ordered list
1. ordered list
1. ordered list
* unordered list
`Code
`
// Four spaces indented text
var count = 1000;
while (--count) {
console.log('Wow %d!', count);
}
``[gitter-image]: https://badges.gitter.im/Holixus/nano-markdown.svg
[gitter-url]: https://gitter.im/Holixus/nano-markdown
[npm-image]: https://img.shields.io/npm/v/nano-markdown.svg
[npm-url]: https://npmjs.org/package/nano-markdown
[github-tag]: http://img.shields.io/github/tag/Holixus/nano-markdown.svg
[github-url]: https://github.com/Holixus/nano-markdown/tags
[travis-image]: https://travis-ci.org/Holixus/nano-markdown.svg?branch=master
[travis-url]: https://travis-ci.org/Holixus/nano-markdown
[coveralls-image]: https://img.shields.io/coveralls/Holixus/nano-markdown.svg
[coveralls-url]: https://coveralls.io/r/Holixus/nano-markdown
[bithound-image]: https://www.bithound.io/github/Holixus/nano-markdown/badges/score.svg
[bithound-url]: https://www.bithound.io/github/Holixus/nano-markdown
[david-image]: http://img.shields.io/david/Holixus/nano-markdown.svg
[david-url]: https://david-dm.org/Holixus/nano-markdown
[license-image]: http://img.shields.io/npm/l/nano-markdown.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/nano-markdown.svg
[downloads-url]: https://npmjs.org/package/nano-markdown