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

marked-it-core-ie

v0.13.1

Published

A Marked-backed Markdown->HTML generator. Supports extended attribute and front matter syntaxes, and provides hooks for modifying the generated HTML.

Downloads

6

Readme

marked-it

A marked-backed Markdown->HTML generator. Supports extended attribute and front matter syntaxes, and provides hooks for modifying the generated HTML.

Install

npm install marked-it-core

Example Usage

var markedIt = require("marked-it-core");
var result = markedIt.generate("#Welcome to marked-it\n{: #welcomeId .title}\n");
console.log(result.html.text);

/* Output:
	<h1 id="welcomeId" class="title">Welcome to marked-it</h1>
*/

API

marked-it.generate(markdownText [,options])

options (default values shown)

{
	extensions: {},
	markedOptions: {tables: true, gfm: true, headerPrefix: "", xhtml: true, langPrefix: "lang-"},
	processAttributes: true,
	processFrontMatter: true,
	variablesMap: {},
	
	/* the following TOC generation options are subject to change */
	tocJSON: false,
	tocDepth: Infinity
	filePath: ""
}

returns:

{
	html: {
		text: <string>,
		errors: <array>
	},
	properties: {
		document: {
			title: <string>,
			frontMatterMap: <object>
		}
	},
	jsonToc: {
		text: <string>,
		errors: <array>
	},
	xmlToc: {
		text: <string>,
		errors: <array>
	}
}

Extensions

Extensions are functions that can hook into well-defined points in the HTML generation process. A client can provide an array of extensions to the marked-it.generate() options object.

All extension functions receive two arguments:

  • value: the default value that has been generated
  • data: additional data and functions that may be helpful for generating a replacement value

If the extension function returns any string, including "", then that string will replace the initially-generated value in the end document. If a non-string value is returned then the initially-generated value is preserved.

For an example of an extension that adds elements to generated elements see ./examples/extension-tableCaptions.js.

HTML Generation extensions

All extensions in this section receive a data object containing:

htmlToDom(string, options)

A function that returns the HTML string for a DOM object. See options.

domToHtml(dom, options)

A function that returns a DOM representation of an HTML string.

options:

xmlMode:
decodeEntities:

domToInnerHtml(string, options)

A function to convert a DOM object to its inner HTML string. It takes the same options as the domToHtml function.

domUtils

An object with functions for manipulating DOM objects. The functions are defined in the various files here.

HTML Generation extension points

html.onHeading
html.onCode
html.onBlockquote
html.onHtml
html.onHr
html.onList
html.onListItem
html.onParagraph
html.onTable
html.onTablerow
html.onTablecell
html.onStrong
html.onEmphasis
html.onCodespan
html.onDel
html.onLink
html.onImage

TOC Generation extensions

(Note that TOC generation is being re-thought and therefore this extension is subject to change)

This extension receives a data object containing:

header

The source header string that this TOC entry would point to.

htmlToDom(string, options)

A function that returns the HTML string for a DOM object. See options.

domToHtml(dom, options)

A function that returns a DOM representation of an HTML string.

options:

xmlMode:
decodeEntities:

domToInnerHtml(string, options)

A function to convert a DOM object to its inner HTML string. It takes the same options as the domToHtml function.

domUtils

An object with functions for manipulating DOM objects. The functions are defined in the various files found here.

TOC Generation extension points

json.toc.onTopic
xml.toc.onTopic