
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
rehype-template
Advanced tools
Rehype plugin to wrap contents with htm template
npm install remark-frontmatter remark-extract-frontmatter rehype-template
Say example.md
looks as follows;
---
title: Example
---
# Example
This is example
...and example.js
like this:
const vfile = require("to-vfile")
const report = require("vfile-report")
const unified = require("unified")
const remark = require("remark-parse")
const remark2rehype = require("remark-rehype")
const frontmatter = require("remark-frontmatter")
const extract = require("remark-extract-frontmatter")
const stringify = require("rehype-stringify")
const { parse } = require("yaml")
const { html, template, doctype } = require("rehype-template")
const t = (node, frontmatter) => html`
${doctype}
${comment("example")}
<html>
<head>
<title>${frontmatter.title}</title>
</head>
<body>${node}</body>
</html>
`
unified()
.use(remark)
.use(frontmatter)
.use(extract, {yaml: parse})
.use(remark2rehype)
.use(template, {template: t})
.use(stringify)
.process(vfile.readSync("example.md"), (err, file) => {
console.error(report(err || file))
console.log(String(file))
})
Now, running node example
yields:
<!doctype html><!--example--><html><head><title>Example</title></head><body><h1>Example</h1>
<p>This is example</p></body></html>
rehype().use(template[, options])
Wrap the content with options.template
, which uses template literal.
options.template(node, frontmatter)
node
Syntax treefrontmatter
Object as frontmatter parsed by remark-frontmatter
and remark-extract-frontmatter
.doctype
Insert a doctype element into a template like the above.
comment(value)
Insert a comment element into a template like the above.
html
Template literal function defined as htm.bind(h)
where h
is hastscript.
> const name = "world"
> html`<p>hello, ${name}</p>`
The above code yields:
{
type: 'element',
tagName: 'p',
properties: {},
children: [
{ type: 'text', value: 'hello, ' },
{ type: 'text', value: 'world' }
]
}
Use of rehype-template
should be safe to use as htm
should be safe to use. When in doubt, use rehype-sanitize
.
MIT © TANIGUCHI Masaya
FAQs
Rehype plugin to wrap contents with htm template
The npm package rehype-template receives a total of 5 weekly downloads. As such, rehype-template popularity was classified as not popular.
We found that rehype-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.