nano-markdown
1894 bytes of minified code. Supports heading, paragraphs, code, lists, horizontal rules, bold/italic/del, links and images.
Usage
var nmd = require('nano-markdown');
console.log(nmd('test'));
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](#44)\n* [commit 750945c](@750945c)'));
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
### foo
#### foo
##### foo
###### foo
# foo ############################
## foo ###########################
### foo ##########################
#### foo #########################
##### foo ########################
###### foo #######################
Images
![image alt text](/images/picture.jpg)
![image alt text](/images/picture.jpg "image title text")
Links
[link text](http://github.com)
[open link in new window](+http://github.com)
[link with title](http://github.com "title text")
Bold/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);
}