Skip to content

Commit

Permalink
feat: Suppor kbd element.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 8, 2021
1 parent a9d2230 commit 622f84d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const rehypeAttrs: Plugin<[RehypeAttrsOptions?]> = (options): Transformer => {
}
}
}
if (/^(em|strong|b|a|i|p|pre|blockquote|h(1|2|3|4|5|6)|code|table|img|del|ul|ol)$/.test(node.tagName as string) && Array.isArray(parent.children)) {
if (/^(em|strong|b|a|i|p|pre|kbd|blockquote|h(1|2|3|4|5|6)|code|table|img|del|ul|ol)$/.test(node.tagName as string) && Array.isArray(parent.children)) {
const child = nextChild(parent.children, index)
if (child) {
const attr = getCommentObject(child)
Expand Down
5 changes: 5 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ describe('rehype-attr test case', () => {
markdown: '<i>Title</i><!--rehype:style=color:pink;-->',
expected: '<i style="color:pink;">Title</i><!--rehype:style=color:pink;-->',
},
{
title: 'options="attr" - <kbd>',
markdown: '<kbd>R</kbd><!--rehype:style=color:pink;-->',
expected: '<kbd style="color:pink;">R</kbd><!--rehype:style=color:pink;-->',
},
{
title: 'options="attr" - <strong>',
markdown: 'This is a <strong>Unicorn</strong><!--rehype:style=color: grey-->',
Expand Down

0 comments on commit 622f84d

Please sign in to comment.