1
0
mirror of synced 2026-01-07 00:01:39 -05:00

Allow code annotations to have hashbangs (#48995)

This commit is contained in:
Peter Bengtsson
2024-02-05 08:41:15 -05:00
committed by GitHub
parent 08add3f4fb
commit d517b22cf0
5 changed files with 104 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ import { header } from './code-header.js'
const languages = yaml.load(fs.readFileSync('./data/code-languages.yml', 'utf8'))
const commentRegexes = {
number: /^\s*#\s*/, // also known has hash or sharp; but the unicode name is "number sign"
number: /^\s*#[^!]\s*/, // also known has hash or sharp; but the unicode name is "number sign"
slash: /^\s*\/\/\s*/,
xml: /^\s*<!--\s*/,
percent: /^\s*%%?\s*/,
@@ -71,6 +71,13 @@ function createAnnotatedNode(node) {
// Group groups into rows
const rows = chunk(groups, 2)
for (const [, note] of rows) {
if (note === undefined) {
throw new Error(
"Unbalanced code meaning there's a comment (note) that is not followed by any code.",
)
}
}
// Render the HTML
return template({ lang, code, rows })