Fix // in URLs triggering comment highlighting

Only match // comments at line start, not inside URLs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-22 04:19:06 -04:00
parent 1f4a131a61
commit b22aabe2c3
+2 -2
View File
@@ -591,8 +591,8 @@
// Python class names (class ClassName)
html = html.replace(/(\bclass\s+)([A-Za-z_][A-Za-z0-9_]*)/g, '$1<span style="font-weight: bold;">$2</span>');
// JavaScript/C++/Java comments (// comment)
html = html.replace(/(\s*\/\/.*)$/gm, '<span style="color: #888; font-style: italic;">$1</span>');
// JavaScript/C++/Java comments (// comment) - only at line start, not in URLs
html = html.replace(/^(\s*\/\/.*)$/gm, '<span style="color: #888; font-style: italic;">$1</span>');
// CSS/C/Java block comments (/* comment */)
html = html.replace(/(\/\*[\s\S]*?\*\/)/g, '<span style="color: #888; font-style: italic;">$1</span>');