Skip to content

Commit

Permalink
fix: allow more codeblock languages (#2441)
Browse files Browse the repository at this point in the history
* fix: allow rego codeblocks

* fix: allow shell-session#

* fix: allow env

* feat: fallback to plaintext
  • Loading branch information
dstaley authored May 13, 2024
1 parent fe58a3e commit 20e317d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/rehype-code-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ export const rehypeCodePlugins: Pluggable[] = [
options.lang = 'hcl'
break
case 'shell-session':
case 'shell-session#':
case 'sell-session':
case 'terminal':
options.lang = 'shellsession'
break
case 'shell-script':
case 'env':
options.lang = 'sh'
break
case 'patch':
Expand All @@ -70,9 +72,19 @@ export const rehypeCodePlugins: Pluggable[] = [
case 'log':
case 'plain-text':
case 'ebnf':
case 'rego':
options.lang = 'text'
break
}

// Finally, if the language is still unknown, default
// to plaintext.
if (!defaultShikiOptions.langs.includes(options.lang)) {
console.error(
`ShikiError: Language \`${options.lang}\` not found, you may need to load it first`
)
options.lang = 'text'
}
},
} satisfies ShikiTransformer,
],
Expand Down

0 comments on commit 20e317d

Please sign in to comment.