Skip to content

Add warnings when a codeblock tries to use an unsupported language #377

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

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

Mpdreamz
Copy link
Member

No description provided.

@Mpdreamz Mpdreamz added the fix label Jan 30, 2025
@Mpdreamz Mpdreamz linked an issue Jan 30, 2025 that may be closed by this pull request
@Mpdreamz Mpdreamz requested a review from reakaleek January 30, 2025 12:25

public static class CodeBlock
{
private static readonly IReadOnlyDictionary<string, string> LanguageMapping = new Dictionary<string, string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this list coming from? Is it https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md (excluding the extra packages)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly that :)

"terminal" => "bash",
_ => codeBlock.Language
};
if (!string.IsNullOrEmpty(codeBlock.Language) && !CodeBlock.Languages.Contains(codeBlock.Language))
codeBlock.EmitWarning($"Unknown language: {codeBlock.Language}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we actually list the supported languages or add a link to supported languages?

@Mpdreamz Mpdreamz merged commit 2d5c0c0 into main Jan 30, 2025
5 checks passed
@Mpdreamz Mpdreamz deleted the feature/warn-on-unknown-language branch January 30, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn if code block highlighting language is not supported
2 participants