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

Forum: Remap some file extensions to prism languages #1380

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion TASVideos.ForumEngine/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public async Task WriteHtml(HtmlWriter w, IWriterHelper h)

// "text" is not a supported language for prism,
// so it will just get the same text formatting as languages, but no syntax highlighting.
var lang = osplit.Length > 0 ? osplit[^1] : "text";
var lang = PrismNames.FixLanguage(osplit.Length > 0 ? osplit[^1] : "text");

if (lang != "text")
{
Expand Down
15 changes: 15 additions & 0 deletions TASVideos.ForumEngine/PrismNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace TASVideos.ForumEngine;

public static class PrismNames
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this approach, should be easy to add more mappings as they are discovered

public static string FixLanguage(string s)
{
return s switch
{
"bat" => "batch",
"sh" => "shell",
"c++" => "cpp",
_ => s
};
}
}