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
rehype-sort-attributes
rehype plugin to reorder attributes based on how often they occur
rehype-sort-attribute-values
rehype plugin to sort attribute values
rehype-minify-attribute-whitespace
rehype plugin to minify whitespace in attributes
rehype-attr2
New syntax to add attributes to Markdown.
npm install rehype-attr
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
32 Stars
202 Commits
1 Forks
2 Watchers
2 Branches
2 Contributors
Updated on Mar 04, 2025
Latest Version
4.0.2
Package Id
rehype-attr@4.0.2
Unpacked Size
30.55 kB
Size
7.69 kB
File Count
11
NPM Version
10.8.2
Node Version
20.18.2
Published on
Feb 20, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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
commentStart
Optional start delimiter for comments @example \\{\\*
Default Value:
<!--
commentEnd
Optional end delimiter for comments @example \\*\\}
Default Value:
-->
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
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/22 approved changesets -- 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 2025-07-07
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