DevServer: source map and error modal improvements (#17476)

This commit is contained in:
chloe caruso
2025-02-20 16:40:57 -08:00
committed by GitHub
parent 275a34b014
commit b082572dcb
37 changed files with 2283 additions and 697 deletions

View File

@@ -562,6 +562,24 @@ export class DraculaSyntaxHighlighter {
return this.buildHtmlElement("pre", { "class": classAttr }, result);
}
public highlightLine() {
let lineContent = "";
for (const token of this.tokenize()) {
if (token.type === TokenType.Newline) {
continue;
}
if (token.tokenClass) {
lineContent += this.wrap(token.value, token.tokenClass);
} else {
lineContent += this.escapeHtml(token.value);
}
}
return lineContent;
}
private escapeHtml(str: string): string {
return str
.replace(/&/g, "&")
@@ -794,3 +812,7 @@ export class DraculaSyntaxHighlighter {
return false;
}
}
export function syntaxHighlight(code: string) {
return new DraculaSyntaxHighlighter(code).highlightLine();
}