Socket
Book a DemoInstallSign in
Socket

markdown-symbols

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-symbols

Easily add and create custom symbols to use in markdown, and then compile them to HTML.

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

markdown-symbols

Easily add and create custom symbols to use in markdown, and then compile them to HTML.

If you find a bug or have a feature request, please create an issue.

Inspired by @Vinz243 from this issue on marked-extras.

Install

Install with npm:

npm i markdown-symbols --save

Usage

var symbols = require('markdown-symbols');
symbols.process( String );

Add Custom Symbols

An array of replacement patterns for custom symbols can be passed as a second parameter

symbols.process( String, patterns );

Replacement patterns follow this format:

var patterns = [
  {
    pattern: /foo/, // the pattern to replace
    replacement: 'bar' // the replacement. can be a string or a function.
  }
];

Example

This is the pattern and replacement used to for alerts:

var patterns = [
  {
    pattern: symbols.makeDelims(['!!', '!!']),
    replacement: function (match, inner) {
      var arr = inner.split('|');
      var text = arr[0];
      var modifier = arr[1] ? ' alert-' + arr[1] : '';
      return '<span class="alert' + modifier + '">' + text + '</span>';
    }
  }
];

Take a look at index.js to see how the others are created.

.makeDelims()

For patterns, the makeDelims utility method is a convenience for more easily creating custom symbols:

symbols.makeDelims(['!!', '!!'])

The delims library is used to create delimiters, visit that project to learn about usage and available options.

Examples

To build the examples, run npm i && node examples/example

Labels

||This is a label!||
||This is a label!|warning||
||This is a label!|success||

Spoiler

> and captcha protected spoilers:

\{{Simple spoiler|info}}

!\{{Write me at <john.doe@example.com>|info}}

Progress bars

=====0%=====
=====10%|error=====
=====40%|warning=====
=====80%|success=====

Glyphicons

::|search::

Badges

[[42]]
[[42|danger]]

Jumbotrons

////
Hello, world|small
////

Alerts

!!New update released! !!
!!New update released!|info!!

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license

Keywords

convert markdown

FAQs

Package last updated on 27 May 2014

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