You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

flavormark

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

flavormark

TypeScript Markdown parser


Version published
Weekly downloads
437
decreased by-19.07%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

flavormark

Based on commonmark.js

FlavorMark is a Markdown parser, made in TypeScript, with emphasis placed on modularizing element parsing logic, making it easy(-ish) to add/remove syntax for your favorite Markdown flavors.

Parsers

There are a lot of classes with the word Parser in them.

  • Parser

    The main parser, parses block elements. Then, parses inline content.

  • BlockParser

    Each block element will generally be parsed by one BlockParser.

  • InlineContentParser

    Parses inline content, using InlineParser.

  • InlineParser

    Each inline element will generally be parsed by one InlineParser.

  • DelimitedInlineParser

    This parser makes it easier to parse inline elements that behave like emphasis elements.

  • DelimitedInlineSubParser

    If using DelimitedInlineParser, each sub-parser will parse one emphasis-like element. (Emphasis, smart quotes, superscript, strikethrough, etc.)

Usage

  1. Instantiate all BlockParser classes and add them to a BlockParserCollection.
  2. Instantiate all InlineParser classes and add them to an array.
  3. Instantiate an InlineContentParser and pass it the array of InlineParser.
  4. Instantiate a Parser and pass it the BlockParserCollection, and InlineContentParser.
  5. Call Parser.parse(str).

See the tests in src/test for more examples.

Notes

Each Node constructor is used to uniquely identify BlockParser, and HtmlSubRenderer instances.

When trying to parse a block, instanceof checks are used to find the BlockParser associated with a Node. The first matching BlockParser in the array is used.

For this reason, each unique block type should have its own Node sub-class.

License

See LICENSE file (copy-pasted from commonmark.js). Also, since this is just a glorified port of commonmark.js, I guess the BSD-license carries over. I have no idea how this works. I don't really care, personally. I just don't want to step on anyone's toes.

FAQs

Package last updated on 02 May 2020

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc