npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mvasilkov/cmark-gfm

v0.29.0

Published

GitHub Flavored Markdown ¦ Native bindings for cmark-gfm, GitHub's fork of cmark, a CommonMark parsing and rendering library

Downloads

60

Readme

cmark-gfm

GitHub Flavored Markdown ¦ Native bindings for cmark-gfm, GitHub's fork of cmark, a CommonMark parsing and rendering library

npm dependencies travis appveyor


Installation

npm add @mvasilkov/cmark-gfm

Usage

const { renderHtmlSync } = require('@mvasilkov/cmark-gfm')

const html = renderHtmlSync('# hello, world')
// returns <h1>hello, world</h1>

Asynchronous usage

const { renderHtml } = require('@mvasilkov/cmark-gfm')

// With async/await
const html = await renderHtml('# hello, world')

// With Promises
renderHtml('# hello, world').then(html => {})

// With node-style callbacks
renderHtml('# hello, world', (err, html) => {})

Passing options

renderHtmlSync('# hello, world', { sourcepos: true })
// returns <h1 data-sourcepos="1:1-1:14">hello, world</h1>

await renderHtml('# hello, world', { sourcepos: true })
// equivalent to the above

All available options are listed below.

Using extensions

renderHtmlSync('# hello, https://sr.ht/', {
  extensions: { autolink: true }
})
// returns <h1>hello, <a href="https://sr.ht/">https://sr.ht/</a></h1>

await renderHtml('# hello, https://sr.ht/', {
  extensions: { autolink: true }
})
// equivalent to the above

Supported extensions are listed below.

Usage with streams

const fs = require('fs')
const { StreamingParser } = require('@mvasilkov/cmark-gfm')

fs.createReadStream('README.md')
  .pipe(new StreamingParser({ extensions: { table: true } }))
  .pipe(fs.createWriteStream('README.html'))

Options

All of the following options are boolean, and off by default.

Options affecting rendering

| Option | Što | --- | --- | sourcepos | Include a data-sourcepos attribute on all block elements. | hardbreaks | Render softbreak elements as hard line breaks. | unsafe | Render raw HTML and unsafe links. | nobreaks | Render softbreak elements as spaces. | react | Produce React-compatible output (JSX).

Options affecting parsing

| Option | Što | --- | --- | validateUtf8 | Validate UTF-8 in the input before parsing, replacing illegal sequences with the replacement character U+FFFD. | smart | Convert straight quotes to curly, --- to em dashes, -- to en dashes. | githubPreLang | Use GitHub-style <pre lang="x"> tags for code blocks instead of <pre><code class="language-x">. | liberalHtmlTag | Be liberal in interpreting inline HTML tags. | footnotes | Parse footnotes. | strikethroughDoubleTilde | Only parse strikethroughs if surrounded by exactly 2 tildes. Gives some compatibility with redcarpet. | tablePreferStyleAttributes | Use style attributes to align table cells instead of align attributes. | fullInfoString | Include the remainder of the info string in code blocks in a separate attribute.

Extensions

| Extension | Što | --- | --- | autolink | Output web addresses and emails as hyperlinks. | strikethrough | Enable the ~~strikethrough~~ syntax. | table | Enable tables. | tagfilter | Escape the following HTML tags: title, textarea, style, xmp, iframe, noembed, noframes, script, and plaintext. | tasklist | Enable task lists.

Authors

This is a fork of Michelle Tilley's repo. It's entirely compatible with the upstream, and brings the following improvements:

  • Convert to TypeScript
  • Update the underlying C library to the latest master
  • Exclude dead code from compilation
  • Reduce dev dependencies' footprint
  • Optional React (JSX) support

Maintained by Mark Vasilkov.

License

MIT