GitXplorerGitXplorer
g

marked-it

public
4 stars
5 forks
7 issues

Commits

List of commits on branch master.
Verified
96b6aded70d9c62fb50a1e699ab1e4a2731a073c

Merge pull request #10 from stacyped/master

ggrant-g committed 5 years ago
Verified
088b0c53adb776642bb731b91b34d7a90d941e4c

Merge pull request #1 from stacyped/stacyped-patch-1

sstacyped committed 5 years ago
Verified
00721b842ee9306abcb4442c1860e70d9420efe8

Removing unnecessary "

sstacyped committed 5 years ago
Unverified
35664d9fa16824cb16d09d7bed02e99c8ec72384

test commit 1

ggrant-g committed 5 years ago
Unverified
607f1a98f01f548bb15f44e9bdede00aea98dfa9

Bumped up to marked v0.3.9 and introduced option to auto-fix headers with invalid syntax.

ggrant-g committed 6 years ago
Unverified
d415b00f3446a689958ab89957fbb83276f8f500

IBM/marked-it#4: attribute detection can be thrown off by non-typical space chars

ggrant-g committed 6 years ago

README

The README file for this repository.

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>
		}
	},
	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.onLinebreak 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