Skip to content

Commit 41fa5ed

Browse files
committed
Support more Markdown file extension #1562 #1601
1 parent 0021253 commit 41fa5ed

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/Plugin.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace QuickLook.Plugin.ArchiveViewer;
2525

2626
public class Plugin : IViewer
2727
{
28-
private static readonly string[] Extensions =
28+
private static readonly string[] _extensions =
2929
[
3030
".7z",
3131
".bz2",
@@ -50,7 +50,7 @@ public void Init()
5050

5151
public bool CanHandle(string path)
5252
{
53-
return !Directory.Exists(path) && Extensions.Any(path.ToLower().EndsWith);
53+
return !Directory.Exists(path) && _extensions.Any(path.ToLower().EndsWith);
5454
}
5555

5656
public void Prepare(string path, ContextObject context)

QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ namespace QuickLook.Plugin.HtmlViewer;
2525

2626
public class Plugin : IViewer
2727
{
28-
private static readonly string[] Extensions = [".mht", ".mhtml", ".htm", ".html"];
29-
private static readonly string[] SupportedProtocols = ["http", "https"];
28+
private static readonly string[] _extensions = [".mht", ".mhtml", ".htm", ".html"];
29+
private static readonly string[] _supportedProtocols = ["http", "https"];
3030

3131
private WebpagePanel _panel;
3232

@@ -38,9 +38,9 @@ public void Init()
3838

3939
public bool CanHandle(string path)
4040
{
41-
return !Directory.Exists(path) && (Extensions.Any(path.ToLower().EndsWith) ||
41+
return !Directory.Exists(path) && (_extensions.Any(path.ToLower().EndsWith) ||
4242
path.ToLower().EndsWith(".url") &&
43-
SupportedProtocols.Contains(Helper.GetUrlPath(path).Split(':')[0]
43+
_supportedProtocols.Contains(Helper.GetUrlPath(path).Split(':')[0]
4444
.ToLower()));
4545
}
4646

QuickLook.Plugin/QuickLook.Plugin.MarkdownViewer/Plugin.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ public class Plugin : IViewer
3434
private WebpagePanel? _panel;
3535
private string? _currentHtmlPath;
3636

37+
/// <summary>
38+
/// Markdown and Markdown-like extensions
39+
/// It is not guaranteed to support all formats perfectly
40+
/// </summary>
41+
private static readonly string[] _extensions =
42+
[
43+
".md", ".markdown", // The most common Markdown extensions
44+
".mdx", // MDX (Markdown + JSX), used in React ecosystems
45+
".mmd", // MultiMarkdown (MMD), an extended version of Markdown
46+
".mkd", ".mdwn", ".mdown", // Early Markdown variants, used by different parsers like Pandoc, Gitit, and Hakyll
47+
".mdc", // A Markdown variant used by Cursor AI [Repeated format from ImageViewer]
48+
".qmd", // Quarto Markdown, developed by RStudio for scientific computing and reproducible reports
49+
".rmd", ".rmarkdown", // R Markdown, mainly used in RStudio
50+
".apib", // API Blueprint, a Markdown-based format
51+
".mdtxt", ".mdtext", // Less common
52+
];
53+
3754
private static readonly string _resourcePath = Path.Combine(SettingHelper.LocalDataPath, "QuickLook.Plugin.MarkdownViewer");
3855
private static readonly string _resourcePrefix = "QuickLook.Plugin.MarkdownViewer.Resources.";
3956
private static readonly ResourceManager _resourceManager = new(_resourcePath, _resourcePrefix);
@@ -51,7 +68,7 @@ public void Init()
5168

5269
public bool CanHandle(string path)
5370
{
54-
return !Directory.Exists(path) && new[] { ".md", ".mdown", ".rmd", ".markdown" }.Any(path.ToLower().EndsWith);
71+
return !Directory.Exists(path) && _extensions.Any(path.ToLower().EndsWith);
5572
}
5673

5774
public void Prepare(string path, ContextObject context)

QuickLook.Plugin/QuickLook.Plugin.PEViewer/Plugin.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace QuickLook.Plugin.PEViewer;
2525

2626
public class Plugin : IViewer
2727
{
28-
private static readonly string[] Extensions =
28+
private static readonly string[] _extensions =
2929
[
3030
".exe", ".sys", ".scr", ".ocx", ".cpl", ".bpl",
3131
".dll", ".ax", ".drv", ".vxd",
@@ -46,7 +46,7 @@ public void Init()
4646

4747
public bool CanHandle(string path)
4848
{
49-
return !Directory.Exists(path) && Extensions.Any(path.ToLower().EndsWith);
49+
return !Directory.Exists(path) && _extensions.Any(path.ToLower().EndsWith);
5050
}
5151

5252
public void Prepare(string path, ContextObject context)

0 commit comments

Comments
 (0)