Skip to content

Latest commit

 

History

56 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gitter Build status Test coverage NPM version Dependency Status License Downloads

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'));
// <p>test</p>

// 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](#44)\n* [commit 750945c](@750945c)'));
// <p>test</p>\n<ul><li><a href='/case/44'>case #44</a></li><li><a href='/commit/750945c'>commit 750945c</a></li></ul>

// 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'));
// <h1 id='header_text'>Header text</h1>

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);
    }

About

1894 bytes of minified code. Supports heading, paragraphs, lists, horizontal rules, bold/italic/del, links and images.

Topics

Resources

Stars

46 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages