-
Notifications
You must be signed in to change notification settings - Fork 858
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
Markdown code blocks marked as csharp missing defined syntax highlighting #8184
Comments
csharp
missing defined syntax highlithing
@TheBoxyBear I am not sure I understand your issue clearly, but below is a screenshot example of a DocFX output. Is this different from yours? |
In the article, the HTML for the code block is |
Not entirely sure if this is a DocFx or template issue. I took a look through the template source files and could not find anything related to code blocks except the style definition for the block and colors for the different types of tokens. |
The syntax highlighting support is handled by highlight.js, which dynamically generate the coloring such as the If your actual desire is color scheme (try some examples by clicking the |
Indeed, they are not present in the generated HTML but do when looking at the final HTML from DevTools. There is still a discrepency with how code blocks are generated between articles and api documentation. There are no javascript errors related to highlight.js when articles are loaded. |
Seems that now spans do get generated but only for the more complex code. It could be that the blocks I was looking at had no signoficant tokens to be highlighted. |
For the codes in the screenshot I posted, there is no difference in the outputs.
The level of highlight may also depend on the color scheme, the default may not be that colorful (just click the |
None issue, highlight.js applies no syntax highlighting to things like type references in bodies, methods calls, property references and variable references. This can cause certain code blocks appear to not have syntax highlighting while in reality, there is nothing to highlight. |
Operating System: (
Windows
orLinux
orMacOS
)Windows 11
DocFX Version Used:
docfx.console NuGet 2.59.4
Template used: (
default
orstatictoc
or contain custom template)SingulinkFX
Steps to Reproduce:
The SingulinkFX provides full syntax highlithing in config.css. Inspecting the resulting HTML, code blocks generated from assembly have their code split into spans with the respective colors applied. Defining a code block such as
results in
<code class="lang-csharp hljs">
tags with the code left as plain text, rather than being parsed and split into spans. The same happens ifc#
is used instead ofcs
with the code class beinglang-c# hljs
Actual example of problematic markdownExpected Behavior:
Code in markdown code blocks are parsed and converted into spans with styles applied such as here https://www.singulink.com/Docs/Singulink.IO.FileSystem/articles/guides/getting-started.html
Actual Behavior:
Cotents of the code blocks are left are plain text between the opening and closing
<code>
tags, only applying styles for keywords like "new".The text was updated successfully, but these errors were encountered: