Skip to content

Commit

Permalink
fix: throw an error if text block contains HTML comment markup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispcampbell committed Dec 11, 2024
1 parent 71e9187 commit 749b463
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/docs-builder/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ export class Context {
}
}

// Fail the build if a block contains an HTML comment; usually when a comment appears
// it is the result of a misconfigured command block (like for a `section` or `def`),
// and those should never appear in the translation files, so we trap them here
if (text.includes('<!--')) {
throw new Error(
this.getScopedMessage(
`Block for '${fullId}' contains an unexpected HTML comment, which should not be included in translation files`
)
)
}

this.blocks.set(fullId, {
id: fullId,
text,
Expand Down

0 comments on commit 749b463

Please sign in to comment.