All Projects → remarkjs → Remark Html

remarkjs / Remark Html

Licence: mit
plugin to compile Markdown to HTML

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Remark Html

Formd
A Markdown formatting tool
Stars: ✭ 141 (-5.37%)
Mutual labels:  markdown
Hedgedoc
HedgeDoc - The best platform to write and share markdown.
Stars: ✭ 2,498 (+1576.51%)
Mutual labels:  markdown
Markdown readme
Markdown - you can mark up titles, lists, tables, etc., in a much cleaner, readable and accurate way if you do it with HTML.
Stars: ✭ 146 (-2.01%)
Mutual labels:  markdown
Yn
Yank Note 一款面向程序员的 Markdown 笔记应用。支持加密文档,代码片段运行,内置终端,图表嵌入,HTML 小工具。
Stars: ✭ 143 (-4.03%)
Mutual labels:  markdown
Europa
Pure JavaScript library for converting HTML into valid Markdown
Stars: ✭ 143 (-4.03%)
Mutual labels:  markdown
Markdown It
Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
Stars: ✭ 12,638 (+8381.88%)
Mutual labels:  markdown
Markwon
Android markdown library (no WebView)
Stars: ✭ 1,949 (+1208.05%)
Mutual labels:  markdown
Hads
📚 Markdown superpowered documentation for Node.js
Stars: ✭ 147 (-1.34%)
Mutual labels:  markdown
Markdown Toc
🎄Generate toc for github markdown file.(为 markdown 文件生成 toc 目录)
Stars: ✭ 144 (-3.36%)
Mutual labels:  markdown
Commonmark
Create, parse, and render Markdown text according to the CommonMark specification
Stars: ✭ 147 (-1.34%)
Mutual labels:  markdown
Markdownd
simple markdown server (optional indexing, no symlinks) report bugs: https://github.com/aerth/markdownd/issues (Heroku takes a couple seconds to load. Patience...)
Stars: ✭ 142 (-4.7%)
Mutual labels:  markdown
Vditor
♏ 一款浏览器端的 Markdown 编辑器。
Stars: ✭ 1,742 (+1069.13%)
Mutual labels:  markdown
Mpeditor
微信markdown编辑器
Stars: ✭ 146 (-2.01%)
Mutual labels:  markdown
Remarkdown
Styling HTML as if it were raw Markdown text.
Stars: ✭ 141 (-5.37%)
Mutual labels:  markdown
Sonar Cnes Report
Generates analysis reports from SonarQube web API.
Stars: ✭ 145 (-2.68%)
Mutual labels:  markdown
Proton
A stand-alone application to quickly preview and edit Markdown files using Electron.
Stars: ✭ 140 (-6.04%)
Mutual labels:  markdown
Remark
A simple, in-browser, markdown-driven slideshow tool.
Stars: ✭ 11,709 (+7758.39%)
Mutual labels:  markdown
Westwind.aspnetcore.markdown
An ASP.NET Core Markdown support library that provides Markdown parsing, a Markdown TagHelper and Markdown Page Handler Middleware
Stars: ✭ 148 (-0.67%)
Mutual labels:  markdown
Rdoc
⚛️📄🚀 Fast static site generator for React, Just write Markdown file. @react-doc
Stars: ✭ 147 (-1.34%)
Mutual labels:  markdown
Markdown Viewer
Firefox add-on to view markdown files
Stars: ✭ 146 (-2.01%)
Mutual labels:  markdown

remark-html

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to serialize Markdown as HTML.

⚠️ This package essentially packs remark-rehype and rehype-stringify, and although it does support some customisation, it isn’t very pluggable. It’s probably smarter to use remark-rehype directly and benefit from the rehype ecosystem.

Note!

This plugin is ready for the new parser in remark (remarkjs/remark#536). The current and previous version of the plugin works with the current and previous version of remark.

Install

npm:

npm install remark-html

Use

Say we have the following file, example.md:

# Hello & World

> A block quote.

* Some _emphasis_, **importance**, and `code`.

And our script, example.js, looks as follows:

var fs = require('fs')
var unified = require('unified')
var markdown = require('remark-parse')
var html = require('remark-html')

unified()
  .use(markdown)
  .use(html)
  .process(fs.readFileSync('example.md'), function (err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

<h1>Hello &#x26; World</h1>
<blockquote>
<p>A block quote.</p>
</blockquote>
<ul>
<li>Some <em>emphasis</em>, <strong>importance</strong>, and <code>code</code>.</li>
</ul>

API

remark().use(html[, options])

Serialize Markdown as HTML.

options

All options except for sanitize and handlers are passed to hast-util-to-html.

options.handlers

Object mapping mdast nodes to functions handling them. This option is passed to mdast-util-to-hast.

options.sanitize

How to sanitize the output (Object or boolean, default: true):

  • false — HTML is not sanitized, dangerous HTML persists
  • true — HTML is sanitized according to GitHub’s sanitation rules, dangerous HTML is dropped
  • Object — the object is treated as a schema for how to sanitize with hast-util-sanitize, dangerous HTML is dropped

Note that raw HTML in Markdown cannot be sanitized, so it’s removed. A schema can still be used to allow certain values from integrations though. To support HTML in Markdown, use rehype-raw.

For example, to add strict sanitation but allowing classNames, use something like:

// ...
var merge = require('deepmerge')
var github = require('hast-util-sanitize/lib/github')

var schema = merge(github, {attributes: {'*': ['className']}})

remark()
  .use(html, {sanitize: schema})
  .processSync(/* … */)

Integrations

remark-html works great with:

All mdast nodes can be compiled to HTML. Unknown mdast nodes are compiled to div nodes if they have children or text nodes if they have value.

In addition, remark-html can be told how to compile nodes through three data properties (more information):

  • hName — Tag name to compile as
  • hChildren — HTML content to add (instead of children and value), in hast
  • hProperties — Map of properties to add

For example, the following node:

{
  type: 'emphasis',
  data: {
    hName: 'i',
    hProperties: {className: 'foo'},
    hChildren: [{type: 'text', value: 'bar'}]
  },
  children: [{type: 'text', value: 'baz'}]
}

…would yield:

<i class="foo">bar</i>

Security

Use of remark-html is unsafe by default and opens you up to a cross-site scripting (XSS) attack. Pass sanitize: true to prevent attacks. Settings sanitize to anything else may be unsafe.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].