Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
Signed-off-by: Titus <tituswormer@gmail.com>
  • Loading branch information
wooorm committed Nov 26, 2023
1 parent 93560ed commit 83bcecf
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ import {visit} from 'unist-util-visit'
/**
* Highlight code with `starry-night`.
*
* @param {Options | null | undefined} options
* @param {Options | null | undefined} [options]
* Configuration (optional).
* @returns
* Transform.
Expand All @@ -828,18 +828,13 @@ export default function rehypeStarryNight(options) {
const starryNight = await starryNightPromise

visit(tree, 'element', function (node, index, parent) {
if (!parent || index === null || node.tagName !== 'pre') {
if (!parent || index === undefined || node.tagName !== 'pre') {
return
}

const head = node.children[0]

if (
!head ||
head.type !== 'element' ||
head.tagName !== 'code' ||
!head.properties
) {
if (!head || head.type !== 'element' || head.tagName !== 'code') {
return
}

Expand Down

0 comments on commit 83bcecf

Please sign in to comment.