Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-html

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-html - npm Package Compare versions

Comparing version 13.0.1 to 14.0.0

index.d.ts

74

index.js

@@ -1,21 +0,44 @@

'use strict'
/**
* @typedef {import('mdast').Root} Root
* @typedef {import('hast-util-sanitize').Schema} Schema
* @typedef {import('mdast-util-to-hast').Handlers} Handlers
*
* @typedef Options
* Configuration.
* @property {boolean|Schema|null} [sanitize]
* How to sanitize the output.
* @property {Handlers} [handlers={}]
* Object mapping mdast nodes to functions handling them.
*/
var toHast = require('mdast-util-to-hast')
var toHtml = require('hast-util-to-html')
var sanitize = require('hast-util-sanitize')
import {toHtml} from 'hast-util-to-html'
import {sanitize} from 'hast-util-sanitize'
import {toHast} from 'mdast-util-to-hast'
module.exports = plugin
/**
* Plugin to serialize markdown as HTML.
*
* @type {import('unified').Plugin<[Options?]|void[], Root, string>}
*/
export default function remarkHtml(options = {}) {
const handlers = options.handlers || {}
const schema =
options.sanitize && typeof options.sanitize === 'object'
? options.sanitize
: undefined
function plugin(options) {
var settings = options || {}
var clean = settings.sanitize
var schema = clean && typeof clean === 'object' ? clean : null
var handlers = settings.handlers || {}
Object.assign(this, {Compiler: compiler})
this.Compiler = compiler
/**
* @type {import('unified').CompilerFunction<Root, string>}
*/
function compiler(node, file) {
var root = node && node.type && node.type === 'root'
var hast = toHast(node, {allowDangerousHtml: !clean, handlers: handlers})
var result
const hast = toHast(node, {allowDangerousHtml: !options.sanitize, handlers})
// @ts-expect-error: assume root.
const cleanHast = options.sanitize ? sanitize(hast, schema) : hast
const result = toHtml(
// @ts-expect-error: assume root.
cleanHast,
Object.assign({}, options, {allowDangerousHtml: !options.sanitize})
)

@@ -26,18 +49,11 @@ if (file.extname) {

if (clean) {
hast = sanitize(hast, schema)
}
result = toHtml(
hast,
Object.assign({}, settings, {allowDangerousHtml: !clean})
)
// Add an eof eol.
if (root && result && /[^\r\n]/.test(result.charAt(result.length - 1))) {
result += '\n'
}
return result
return node &&
node.type &&
node.type === 'root' &&
result &&
/[^\r\n]/.test(result.charAt(result.length - 1))
? result + '\n'
: result
}
}
{
"name": "remark-html",
"version": "13.0.1",
"version": "14.0.0",
"description": "remark plugin to compile Markdown to HTML",

@@ -31,50 +31,48 @@ "license": "MIT",

],
"types": "types/index.d.ts",
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"types/index.d.ts",
"index.d.ts",
"index.js"
],
"dependencies": {
"hast-util-sanitize": "^3.0.0",
"hast-util-to-html": "^7.0.0",
"mdast-util-to-hast": "^10.0.0"
"@types/mdast": "^3.0.0",
"hast-util-sanitize": "^4.0.0",
"hast-util-to-html": "^8.0.0",
"mdast-util-to-hast": "^11.0.0",
"unified": "^10.0.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"commonmark.json": "^0.29.0",
"dtslint": "^4.0.0",
"is-hidden": "^1.0.0",
"not": "^0.1.0",
"nyc": "^15.0.0",
"@types/tape": "^4.0.0",
"c8": "^7.0.0",
"commonmark.json": "^0.30.0",
"is-hidden": "^2.0.0",
"prettier": "^2.0.0",
"rehype-parse": "^7.0.0",
"rehype-stringify": "^8.0.0",
"remark": "^13.0.0-alpha.0",
"remark-cli": "^8.0.0",
"remark-github": "^9.0.0",
"remark-preset-wooorm": "^7.0.0",
"rehype-parse": "^8.0.0",
"rehype-stringify": "^9.0.0",
"remark": "^14.0.0",
"remark-cli": "^10.0.0",
"remark-footnotes": "^4.0.0",
"remark-frontmatter": "^4.0.0",
"remark-gfm": "^1.0.0",
"remark-github": "^10.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark-slug": "^6.0.0",
"remark-toc": "^7.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"to-vfile": "^6.0.0",
"unified": "^9.0.0",
"xo": "^0.33.0"
"to-vfile": "^7.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.43.0"
},
"scripts": {
"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-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
"build": "rimraf \"test/**/*.d.ts\" \"*.d.ts\" && tsc && type-coverage",
"format": "remark . -qfo --ignore-pattern test/ && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test/index.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {

@@ -89,12 +87,3 @@ "tabWidth": 2,

"xo": {
"prettier": true,
"esnext": false,
"rules": {
"unicorn/no-fn-reference-in-iterator": "off",
"unicorn/prefer-includes": "off",
"unicorn/prefer-optional-catch-binding": "off"
},
"ignores": [
"remark-html.js"
]
"prettier": true
},

@@ -105,3 +94,9 @@ "remarkConfig": {

]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -28,2 +28,5 @@ # remark-html

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
[npm][]:

@@ -47,15 +50,17 @@

And our script, `example.js`, looks as follows:
And our module, `example.js`, looks as follows:
```js
var fs = require('fs')
var unified = require('unified')
var markdown = require('remark-parse')
var html = require('remark-html')
import fs from 'node:fs'
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkHtml from 'remark-html'
const buf = fs.readFileSync('example.md')
unified()
.use(markdown)
.use(html)
.process(fs.readFileSync('example.md'), function (err, file) {
if (err) throw err
.use(remarkParse)
.use(remarkHtml)
.process(buf)
.then((file) => {
console.log(String(file))

@@ -79,4 +84,7 @@ })

### `remark().use(html[, options])`
This package exports no identifiers.
The default export is `remarkHtml`.
### `unified().use(remarkHtml[, options])`
Serialize Markdown as HTML.

@@ -141,3 +149,3 @@

— Transform math to HTML with KaTeX
* [`remark-math`](https://github.com/rokt33r/remark-math)
* [`remark-math`](https://github.com/remarkjs/remark-math)
— Math support for Markdown (inline and block)

@@ -205,5 +213,5 @@ * [`remark-midas`](https://github.com/ben-eb/remark-midas)

[build-badge]: https://img.shields.io/travis/remarkjs/remark-html/main.svg
[build-badge]: https://github.com/remarkjs/remark-html/workflows/main/badge.svg
[build]: https://travis-ci.org/remarkjs/remark-html
[build]: https://github.com/remarkjs/remark-html/actions

@@ -210,0 +218,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-html.svg

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc