Gathering detailed insights and metrics for rehype-attr
Gathering detailed insights and metrics for rehype-attr
Gathering detailed insights and metrics for rehype-attr
Gathering detailed insights and metrics for rehype-attr
esquery
A query library for ECMAScript AST using a CSS selector like query language.
rehype-external-links
rehype plugin to automatically add `target` and `rel` attributes to external links
remark-rehype
remark plugin that turns markdown into HTML to support rehype
rehype-slug
rehype plugin to add `id` attributes to headings
npm install rehype-attr
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
31 Stars
196 Commits
1 Forks
3 Watching
3 Branches
2 Contributors
Updated on 31 Oct 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
4%
21,300
Compared to previous day
Last week
4.9%
108,506
Compared to previous week
Last month
17.7%
440,055
Compared to previous month
Last year
93.6%
4,098,895
Compared to previous year
2
New syntax to add attributes to Markdown. rehype-attr
like remark-attr
This package is ESM only: Node 12+ is needed to use it and it must be import
instead of require
.
1npm install rehype-attr
Links
HTML Example
1<a href="https://github.com">github</a><!--rehype:rel=external&style=color:pink;&data-name=kenny-->
Output:
1<a href="https://github.com" rel="external" style="color:pink;" data-name="kenny">github</a>
1import { rehype } from 'rehype'; 2import rehypeAttrs from 'rehype-attr'; 3 4const htmlStr = rehype() 5 .data('settings', { fragment: true }) 6 .use(rehypeAttrs, { properties: 'attr' }) 7 .processSync(`<a href="https://github.com">github</a><!--rehype:rel=external-->`) 8 .toString()
Markdown Example
1[github](https://github.com)<!--rehype:rel=external-->
Output:
1<p> 2 <a href="https://github.com" rel="external">github</a> 3 <!--rehype:rel=external--> 4</p>
1import { unified } from 'unified'; 2import stringify from 'rehype-stringify'; 3import rehypeRaw from 'rehype-raw'; 4import remark2rehype from 'remark-rehype'; 5import remarkParse from 'remark-parse'; 6import rehypeAttrs from 'rehype-attr'; 7 8const htmlStr = unified() 9 .use(remarkParse) 10 .use(remark2rehype, { allowDangerousHtml: true }) 11 .use(rehypeRaw) 12 .use(rehypeAttrs, { properties: 'attr' }) 13 .use(stringify) 14 .processSync(`[github](https://github.com)<!--rehype:rel=external-->`) 15 .toString()
Header
HTML Example
1<h1>This is a title</h1><!--rehype:style=color:pink;-->
Output:
1<h1 style="color:pink;">This is a title</h1>
1import { rehype } from 'rehype'; 2import rehypeAttrs from 'rehype-attr'; 3 4const htmlStr = rehype() 5 .data('settings', { fragment: true }) 6 .use(rehypeAttrs, { properties: 'attr' }) 7 .processSync(`<h1>This is a title</h1><!--rehype:style=color:pink;-->`) 8 .toString()
Markdown Example
1This is a title 2==== 3<!--rehype:style=color:pink;-->
Output:
1<h1 style="color:pink;">This is a title</h1>
1# This is a title 2<!--rehype:style=color:pink;-->
Output:
1<h1 style="color:pink;">This is a title</h1>
Strong
HTML Example
1This is a <strong>Unicorn</strong><!--rehype:style=color: grey-->
Output:
1This is a <strong style="color: grey">Unicorn</strong>
Markdown Example
1This is a **Unicorn**<!--rehype:style=color: grey-->
Output:
1<p>This is a <strong style="color: grey">Unicorn</strong> <!--rehype:style=color: grey--></p>
Emphasis
HTML Example
1Npm stand for <em>node</em><!--rehype:style=color: red--> packet manager.
Output:
1Npm stand for <em style="color: red">node</em> packet manager.
Markdown Example
1Npm stand for *node* <!--rehype:style=color: red--> packet manager.
Output:
1<p>Npm stand for <em style="color: red">node</em><!--rehype:style=color: red--> packet manager.</p>
Code
1<!--rehype:title=Rehype Attrs&abc=1&hello=2-->
2\```js
3console.log('')
4\```
Output:
1<pre data-type="rehyp"> 2 <code class="language-js" data-config="[object Object]"> 3 console.log('') 4 </code> 5</pre>
Inlne Code
HTML Example
1This is the <code>content</code><!--rehype:style=color:pink;-->
Output:
1This is the <code style="color:pink;">content</code>
Markdown Example
1This is the `content`<!--rehype:style=color:pink;-->
Output:
1<p>This is the <code style="color:pink;">content</code><!--rehype:style=color:pink;--></p>
List
1- list 2<!--rehype:style=width:100px;-->
Output:
1<ul style="width:100px;"> 2 <li>list</li> 3</ul> 4<!--rehype:style=width:100px;-->
HTML Example
1import { rehype } from 'rehype'; 2import rehypeAttrs from 'rehype-attr'; 3 4const htmlStr = rehype() 5 .data('settings', { fragment: true }) 6 .use(rehypeAttrs, { properties: 'attr' }) 7 .processSync(`<a href="https://github.com">github</a><!--rehype:rel=external-->`) 8 .toString()
Output:
1<h1 style="color:pink;">This is a title</h1>
Markdown Example
1import { unified } from 'unified'; 2import stringify from 'rehype-stringify'; 3import rehypeRaw from 'rehype-raw'; 4import remarkParse from 'remark-parse'; 5import remark2rehype from 'remark-rehype'; 6import rehypeAttrs from 'rehype-attr'; 7 8const mrkStr = `[github](https://github.com)<!--rehype:rel=external-->` 9const htmlStr = unified() 10 .use(remarkParse) 11 .use(remark2rehype, { allowDangerousHtml: true }) 12 .use(rehypeRaw) 13 .use(rehypeAttrs, { properties: 'attr' }) 14 .use(stringify) 15 .processSync(mrkStr) 16 .toString()
Output:
1<p> 2 <a href="https://github.com" rel="external">github</a> 3 <!--rehype:rel=external--> 4</p>
properties
Default Value:
data
Value:data
,string
,attr
codeBlockParames
Code block passing parameters
Default Value:
true
rehype-video
Add improved video syntax: links to .mp4
and .mov
turn into videos.rehype-rewrite
Rewrite element with rehype.rehype-ignore
Ignore content display via HTML comments, Shown in GitHub readme, excluded in HTML.remark-github-blockquote-alert
Remark plugin to add support for GitHub AlertAs always, thanks to our amazing contributors!
Made with github-action-contributors.
MIT © Kenny Wong
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More