-
Notifications
You must be signed in to change notification settings - Fork 37
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
Multiline strings on C# breaks highlighting #275
Comments
I think I figured it out. In the highlight directive, we are using the Could be the code you provided has a syntax error or the parser on highlight.js side has a bug for CS language! When I tired the other function Here is a reproduction https://stackblitz.com/edit/ngx-highlightjs-fqcvkn?file=src%2Fmain.ts As a workaround, I would suggest that you load the full hljs library instead of the core and the language, then use the function: ngAfterViewInit() {
setTimeout(() => {
document.querySelectorAll('code').forEach((el: HTMLElement) => {
this.hljs.highlightElement(el).subscribe();
});
}, 500)
} Or workaround stackblitz: https://stackblitz.com/edit/ngx-highlightjs-dissgd?file=src%2Fmain.ts I will need to refactor the directive to use the |
Thank you for the quick reply and the workaround. The C# code is syntactically correct, it might be a bug in highlight.js. For my use case - a demo for training purposes - the workaround is perfectly adequate. Feel free to close this bug if you don't prefer to investigate further. |
in v11, you can now use it with <pre>
<code [highlight]="code" language="cs"></code>
</pre> Here is a fixed stackblitz |
Reproduction
Steps to reproduce: See https://stackblitz.com/edit/ngx-highlightjs-ifd39t?file=src%2Fmain.ts
Expected Behavior
Highlighting for
codeWithLinebreakInString
should work. It's working with the highlight.js demo https://highlightjs.org/demoActual Behavior
The code for
codeWithLinebreakInString
isn't highlighted. Have a look to the first keywordvar
.Environment
The text was updated successfully, but these errors were encountered: