![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
rehype-format
Advanced tools
Readme
rehype plugin to format HTML.
npm:
npm install rehype-format
Say we have the following file, index.html
:
<!doCTYPE HTML><html>
<head>
<title>Hello!</title>
<meta charset=utf8>
</head>
<body><section> <p>hi there</p>
</section>
</body>
</html>
And our script, example.js
, looks as follows:
var vfile = require('to-vfile')
var report = require('vfile-reporter')
var rehype = require('rehype')
var format = require('rehype-format')
rehype()
.use(format)
.process(vfile.readSync('index.html'), function(err, file) {
console.error(report(err || file))
console.log(String(file))
})
Now, running node example
yields:
index.html: no issues found
<!doctype html>
<html>
<head>
<title>Hello!</title>
<meta charset="utf8">
</head>
<body>
<section>
<p>hi there</p>
</section>
</body>
</html>
rehype().use(format[, options])
Format white space in the processed tree.
All superfluous white space is removed. However, as newlines are kept (and later properly indented), your code will still line-wrap as expected.
options
options.indent
Indentation per level (number
, string
, default: 2
).
When number, uses that amount of spaces.
When string
, uses that per indentation level.
options.indentInitial
Whether to indent the first level (boolean
, default: true
).
This is usually the <html>
, thus not indenting head
and body
.
options.blanks
List of tag names to join with a blank line (Array.<string>
, default: []
).
These tags, when next to each other, are joined by a blank line (\n\n
).
For example, when ['head', 'body']
is given, a blank line is added between
these two.
Use of rehype-format
changes white space in the syntax tree.
White space in <script>
, <style>
, <pre>
, or <textarea>
is not modified.
If the tree is already safe, use of this plugin does not open you up for a
cross-site scripting (XSS) attack.
When in doubt, use rehype-sanitize
.
rehype-minify
— Minify HTMLrehype-document
— Wrap a document around a fragmentrehype-sanitize
— Sanitize HTMLrehype-toc
— Add a table of contents (TOC)rehype-section
— Wrap headings and their contents in sectionsSee contributing.md
in rehypejs/.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.
FAQs
rehype plugin to format HTML
The npm package rehype-format receives a total of 58,155 weekly downloads. As such, rehype-format popularity was classified as popular.
We found that rehype-format demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.