Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nano-markdown

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-markdown

A minimal markdown to html converter

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
decreased by-2.55%
Maintainers
1
Weekly downloads
 
Created
Source

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")
  • [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);
    }

Keywords

FAQs

Package last updated on 07 Mar 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc