Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prismjs string template literal regex #2719

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/playground",
"comment": "Add `noopener noreferrer` to footer external links",
"type": "none"
}
],
"packageName": "@typespec/playground"
}
2 changes: 2 additions & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ words:
- multis
- munge
- mylib
- noopener
- noreferrer
- nostdlib
- oapi
- oneof
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/src/react/footer/footer-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface FooterItemProps {
export const FooterItem: FunctionComponent<FooterItemProps> = ({ children, link, className }) => {
const resolvedClassName = mergeClasses(style["footer-item"], className);
return link ? (
<a className={resolvedClassName} href={link} target="_blank">
<a className={resolvedClassName} href={link} target="_blank" rel="noopener noreferrer">
{children}
</a>
) : (
Expand Down
7 changes: 3 additions & 4 deletions packages/website/src/theme/typespec-lang-prism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,22 @@ const lang = {
},

string: [
// https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html
{
pattern: new RegExp(
/(^|[^"#])/.source +
"(?:" +
// multi-line string
/"""(?:\\(?:\$\{(?:[^{}]|\$\{[^{}]*\})*\}|[^(])|[^\\"]|"(?!""))*"""/.source +
/"""(?:\$(?:\{(?:[^{}]|\{[^{}]*\})*\}|[^{])|[^$"]|"(?!""))*"""/.source +
"|" +
// single-line string
/"(?:\\(?:\$\{(?:[^{}]|\$\{[^{}]*\})*\}|\r\n|[^(])|[^\\\r\n"])*"/.source +
/"(?:\$(?:\{(?:[^{}]|\{[^{}]*\})*\}|\r\n|[^{])|[^$\r\n"])*"/.source +
")"
),
lookbehind: true,
greedy: true,
inside: {
interpolation: {
pattern: /(\$\{)(?:[^{}]|\$\{[^{}]*\})*(?=\})/,
pattern: /(\$\{)(?:[^{}]|\{[^{}]*\})*(?=\})/,
lookbehind: true,
inside: null, // see below
},
Expand Down