Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: remarkjs/remark-html
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 11.0.2
Choose a base ref
...
head repository: remarkjs/remark-html
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 12.0.0
Choose a head ref
  • 6 commits
  • 7 files changed
  • 3 contributors

Commits on Jun 23, 2020

  1. Change master in links

    wooorm committed Jun 23, 2020
    Copy the full SHA
    2d05989 View commit details
  2. Update dev-dependencies

    wooorm committed Jun 23, 2020
    Copy the full SHA
    f59c15d View commit details

Commits on Jul 11, 2020

  1. Add docs for handlers to readme.md

    Closes GH-33.
    
    Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
    Reviewed-by: Titus Wormer <tituswormer@gmail.com>
    muescha authored Jul 11, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    timyates Tim Yates
    Copy the full SHA
    3806b30 View commit details

Commits on Jul 14, 2020

  1. Refactors docs on options.sanitize in readme.md

    Closes GH-35.
    
    Reviewed-by: Titus Wormer <tituswormer@gmail.com>
    muescha authored Jul 14, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3126be4 View commit details

Commits on Jul 23, 2020

  1. Add types

    Closes GH-28.
    Closes GH-32.
    
    Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
    Reviewed-by: Jonathan Haines <jonno.haines@gmail.com>
    Reviewed-by: Junyoung Choi <fluke8259@gmail.com>
    Reviewed-by: Titus Wormer <tituswormer@gmail.com>
    TaylorBeeston authored Jul 23, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    timyates Tim Yates
    Copy the full SHA
    87d88f7 View commit details
  2. 12.0.0

    wooorm committed Jul 23, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    60841bf View commit details
Showing with 88 additions and 21 deletions.
  1. +3 −0 .prettierignore
  2. +11 −6 package.json
  3. +27 −15 readme.md
  4. +21 −0 types/index.d.ts
  5. +9 −0 types/remark-html-tests.ts
  6. +10 −0 types/tsconfig.json
  7. +7 −0 types/tslint.json
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
coverage/
remark-html.js
remark-html.min.js
*.html
*.json
*.md
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remark-html",
"version": "11.0.2",
"version": "12.0.0",
"description": "remark plugin to compile Markdown to HTML",
"license": "MIT",
"keywords": [
@@ -28,18 +28,21 @@
"Junyoung Choi <fluke8259@gmail.com>",
"Jonathan Soeder <jonathan.soeder@gmail.com>"
],
"types": "types/index.d.ts",
"files": [
"types/index.d.ts",
"index.js"
],
"dependencies": {
"hast-util-sanitize": "^2.0.0",
"hast-util-sanitize": "^3.0.0",
"hast-util-to-html": "^7.0.0",
"mdast-util-to-hast": "^8.2.0",
"mdast-util-to-hast": "^9.0.0",
"xtend": "^4.0.1"
},
"devDependencies": {
"browserify": "^16.0.0",
"commonmark.json": "^0.29.0",
"dtslint": "^3.0.0",
"is-hidden": "^1.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
@@ -51,16 +54,18 @@
"tape": "^5.0.0",
"tinyify": "^2.0.0",
"to-vfile": "^6.0.0",
"xo": "^0.30.0"
"unified": "^9.0.0",
"xo": "^0.32.0"
},
"scripts": {
"format": "remark *.md -qfo && prettier --write \"**/*.js\" && xo --fix",
"format": "remark . -qfo --ignore-pattern test/ && prettier . --write && xo --fix",
"build-bundle": "browserify . -s remarkHtml > remark-html.js",
"build-mangle": "browserify . -s remarkHtml -p tinyify > remark-html.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test/index.js",
"test": "npm run format && npm run build && npm run test-coverage"
"test-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"nyc": {
"check-coverage": true,
42 changes: 27 additions & 15 deletions readme.md
Original file line number Diff line number Diff line change
@@ -73,18 +73,26 @@ Serialize Markdown as HTML.

##### `options`

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

###### `options.sanitize`
###### `options.handlers`

Object mapping [mdast][] [nodes][mdast-node] to functions handling them.
This option is passed to [`mdast-util-to-html`][to-mdast-handlers].

How to sanitize the output (`Object` or `boolean`, default: `true`).
###### `options.sanitize`

If `false`, no HTML is sanitized, and dangerous HTML is left unescaped.
How to sanitize the output (`Object` or `boolean`, default: `true`):

If `true` or an `object`, sanitation is done by [`hast-util-sanitize`][sanitize]
If an object is passed in, it’s given as a schema to `hast-util-sanitize`.
If `true`, input is sanitized according to [GitHub’s sanitation rules][github].
* `false`
— HTML is not sanitized, dangerous HTML persists
* `true`
— HTML is [`hast-util-sanitize`][sanitize] according to [GitHub’s sanitation
rules][github], dangerous HTML is dropped
* `Object`
— the object is treated as a `schema` for how to sanitize with
[`hast-util-sanitize`][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][]
@@ -129,7 +137,7 @@ which do not often occur in the real world.
— Highlight code blocks
* [`remark-html-emoji-image`](https://github.com/jackycute/remark-html-emoji-image)
— Transform emoji unicodes into html images
* [`remark-html-katex`](https://github.com/rokt33r/remark-math/blob/master/packages/remark-html-katex/readme.md)
* [`remark-html-katex`](https://github.com/remark/remark-math/blob/HEAD/packages/remark-html-katex/readme.md)
— Transform math to HTML with KaTeX
* [`remark-math`](https://github.com/rokt33r/remark-math)
— Math support for Markdown (inline and block)
@@ -194,7 +202,7 @@ abide by its terms.

<!-- Definitions -->

[build-badge]: https://img.shields.io/travis/remarkjs/remark-html/master.svg
[build-badge]: https://img.shields.io/travis/remarkjs/remark-html/main.svg

[build]: https://travis-ci.org/remarkjs/remark-html

@@ -224,36 +232,40 @@ abide by its terms.

[health]: https://github.com/remarkjs/.github

[contributing]: https://github.com/remarkjs/.github/blob/master/contributing.md
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md

[support]: https://github.com/remarkjs/.github/blob/master/support.md
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md

[coc]: https://github.com/remarkjs/.github/blob/master/code-of-conduct.md
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md

[license]: license

[author]: https://wooorm.com

[remark]: https://github.com/remarkjs/remark

[remark-options]: https://github.com/remarkjs/remark/tree/master/packages/remark-parse#options
[remark-options]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-parse#options

[remark-plugins]: https://github.com/remarkjs/remark/blob/master/doc/plugins.md#list-of-plugins
[remark-plugins]: https://github.com/remarkjs/remark/blob/HEAD/doc/plugins.md#list-of-plugins

[remark2rehype]: https://github.com/remarkjs/remark-rehype

[rehype]: https://github.com/rehypejs/rehype

[rehype-stringify]: https://github.com/rehypejs/rehype/tree/master/packages/rehype-stringify
[rehype-stringify]: https://github.com/rehypejs/rehype/tree/HEAD/packages/rehype-stringify

[raw]: https://github.com/rehypejs/rehype-raw

[mdast]: https://github.com/syntax-tree/mdast

[mdast-node]: https://github.com/syntax-tree/mdast#nodes

[hast]: https://github.com/syntax-tree/hast

[to-html]: https://github.com/syntax-tree/hast-util-to-html

[to-mdast-handlers]: https://github.com/syntax-tree/mdast-util-to-hast#optionshandlers

[sanitize]: https://github.com/syntax-tree/hast-util-sanitize

[github]: https://github.com/syntax-tree/hast-util-sanitize#schema
21 changes: 21 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// TypeScript Version: 3.5

import {Plugin} from 'unified'
import {HastUtilToHtmlOptions} from 'hast-util-to-html'
import {Schema} from 'hast-util-sanitize'
import {Handlers} from 'mdast-util-to-hast'

interface htmlOptions extends HastUtilToHtmlOptions {
/**
* How to sanitize the output
*/
sanitize?: boolean | Schema

/**
* Object mapping mdast nodes to functions handling them
*/
handlers?: Handlers
}

declare const html: Plugin<[htmlOptions?]>
export = html
9 changes: 9 additions & 0 deletions types/remark-html-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import unified = require('unified')
import html = require('remark-html')

unified().use(html)
unified().use(html, {preferUnquoted: true})
unified().use(html, {sanitize: false})
unified().use(html, {sanitize: false})
unified().use(html, {sanitize: {allowComments: false}})
unified().use(html, {handlers: {hr: (h, node) => h(node, 'hr')}})
10 changes: 10 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"lib": ["es2015"],
"strict": true,
"baseUrl": ".",
"paths": {
"remark-html": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"semicolon": false,
"whitespace": false
}
}