Skip to content

Commit

Permalink
Website: Update flags in regex used to find Vue templates in markdown…
Browse files Browse the repository at this point in the history
… content. (#25316)

Changes:
- Updated the flags on the regex used to detect Vue templates in
MArkdown content. The regex was incorrectly matching double curly
bracket-wrapped variables in markdown code blocks when it should not.
  • Loading branch information
eashaw authored Jan 9, 2025
1 parent 64cd457 commit aab3203
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions website/scripts/build-static-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ module.exports = {
throw new Error(`A Markdown file (${pageSourcePath}) contains an HTML comment directly after a list that will cause rendering issues when converted to HTML. To resolve this error, add a blank newline before the start of the HTML comment in this file.`);
}
// Look for anything outside of code blocks in markdown content that could be interpreted as a Vue template when converted to HTML (e.g. {{ foo }}). If any are found, throw an error.
if (mdString.match(/(?<!```.*)(?<!`){{([^}]+)}}(?!`)/gi)) {
throw new Error(`A Markdown file (${pageSourcePath}) contains a Vue template (${mdString.match(/(?<!```.*)(?<!`){{([^}]+)}}(?!`)/gi)[0]}) that will cause client-side JavaScript errors when converted to HTML. To resolve this error, change or remove the double curly brackets in this file.`);
if (mdString.match(/(?<!```.*)(?<!`){{([^}]+)}}(?!`)/gis)) {
throw new Error(`A Markdown file (${pageSourcePath}) contains a Vue template (${mdString.match(/(?<!```.*)(?<!`){{([^}]+)}}(?!`)/gis)[0]}) that will cause client-side JavaScript errors when converted to HTML. To resolve this error, change or remove the double curly brackets in this file.`);
}

mdString = mdString.replace(/(<call-to-action[\s\S]+[^>\n+])\n+(>)/g, '$1$2'); // « Removes any newlines that might exist before the closing `>` when the <call-to-action> compontent is added to markdown files.
Expand Down

1 comment on commit aab3203

@mikermcneil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good commit message

Please sign in to comment.