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

[Feature Request] Support code element's language attribute when parsing XML comment #9156

Closed
filzrev opened this issue Aug 31, 2023 · 1 comment · Fixed by #9159
Closed
Labels
dotnet Generate .NET API reference docs
Milestone

Comments

@filzrev
Copy link
Contributor

filzrev commented Aug 31, 2023

Is your feature request related to a problem? Please describe.

As reported by #9145.
When <code> tag is used inside XML doc comment.
lang-csharp style is automatically applied.

It seems older version of docfx don't set this style and highlight.js's auto language detection feature is used.

Describe the solution you'd like
Sandcastle support language attribute on <code> element.
If language attribute is set. It can use this value to select language for syntax highlighting.

Some language (xaml) is not natively supported by hightlight.js
So it need mapping to similar language(xml).

Describe alternatives you've considered
Don't explicitly set lang-* styles by default.
Instead use highlight.js's auto language detection.

@yufeih yufeih added dotnet Generate .NET API reference docs bug labels Sep 1, 2023
@yufeih yufeih added this to the Backlog milestone Sep 1, 2023
@filzrev
Copy link
Contributor Author

filzrev commented Sep 1, 2023

By PR #9159. It can specify language for syntax highlighting.
e.g. <code language="{languageId}">

Specified languageId must be included by is hightlight.js supported language
Otherwise. syntax highlighting is not executed.

For XAML file. It need to customize template's main.js file to register language alias.

  configureHljs: function (hljs) {
    hljs.registerAliases('xaml', { languageName: 'xml' });
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Generate .NET API reference docs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants