diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/FormatDetector.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/FormatDetector.cs
index 045a2d9..62ab290 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/FormatDetector.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/FormatDetector.cs
@@ -27,13 +27,16 @@ public class FormatDetector
[
new XMLDetector(),
new JSONDetector(),
+ new MakefileDetector(),
];
- public static IFormatDetector Detect(string text)
+ public static IFormatDetector Detect(string path, string text)
{
+ _ = path;
+
if (string.IsNullOrWhiteSpace(text)) return null;
- return Instance.TextDetectors.Where(detector => detector.Detect(text))
+ return Instance.TextDetectors.Where(detector => detector.Detect(path, text))
.FirstOrDefault();
}
}
@@ -44,5 +47,5 @@ public interface IFormatDetector
public string Extension { get; }
- public bool Detect(string text);
+ public bool Detect(string path, string text);
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs
index 4df727b..7555bbb 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs
@@ -26,8 +26,10 @@ public class JSONDetector : IFormatDetector
public string Extension => ".json";
- public bool Detect(string text)
+ public bool Detect(string path, string text)
{
+ _ = path;
+
if (string.IsNullOrWhiteSpace(text)) return false;
var span = text.AsSpan();
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/MakefileDetector.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/MakefileDetector.cs
new file mode 100644
index 0000000..f7aaa7f
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/MakefileDetector.cs
@@ -0,0 +1,35 @@
+// Copyright © 2017-2025 QL-Win Contributors
+//
+// This file is part of QuickLook program.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System;
+using System.IO;
+
+namespace QuickLook.Plugin.TextViewer.Detectors;
+
+public class MakefileDetector : IFormatDetector
+{
+ public string Name => "Makefile";
+
+ public string Extension => ".mk";
+
+ public bool Detect(string path, string text)
+ {
+ if (string.IsNullOrWhiteSpace(text)) return false;
+
+ return "Makefile".Equals(Path.GetFileName(path), StringComparison.OrdinalIgnoreCase);
+ }
+}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/XMLDetector.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/XMLDetector.cs
index 46c7fda..7421327 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/XMLDetector.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/XMLDetector.cs
@@ -27,8 +27,10 @@ public class XMLDetector : IFormatDetector
public string Extension => ".xml";
- public bool Detect(string text)
+ public bool Detect(string path, string text)
{
+ _ = path;
+
return Signature.IsMatch(text);
}
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/JavaScript.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/JavaScript.xshd
index 4d83302..c07a216 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/JavaScript.xshd
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/JavaScript.xshd
@@ -1,5 +1,5 @@
-
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Makefile.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Makefile.xshd
new file mode 100644
index 0000000..b4ceb58
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Makefile.xshd
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :=(){}[]$@%*?
+
+
+
+ #
+
+
+
+
+ $(
+ )
+
+
+
+ ${
+ }
+
+
+
+
+ "
+ "
+
+
+
+ '
+ '
+
+
+
+ @
+ -
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Text.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Text.xshd
index f2c9e2a..cf47b4d 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Text.xshd
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/Text.xshd
@@ -1,6 +1,6 @@
-
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/TypeScript.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/TypeScript.xshd
index 3b7a3e1..81c7b24 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/TypeScript.xshd
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Dark/TypeScript.xshd
@@ -1,6 +1,6 @@
-
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/JavaScript.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/JavaScript.xshd
index b684c9d..3c06332 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/JavaScript.xshd
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/JavaScript.xshd
@@ -1,6 +1,6 @@
-
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/Text.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/Text.xshd
index f2c9e2a..cf47b4d 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/Text.xshd
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/Text.xshd
@@ -1,6 +1,6 @@
-
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/TypeScript.xshd b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/TypeScript.xshd
index 655ef87..f098d4d 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/TypeScript.xshd
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Syntax/Light/TypeScript.xshd
@@ -1,6 +1,6 @@
-
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs
index 8ba0a72..99ca9f2 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.cs
@@ -220,7 +220,7 @@ public partial class TextViewerPanel : TextEditor, IDisposable
Dispatcher.BeginInvoke(() =>
{
var extension = Path.GetExtension(path);
- var highlighting = HighlightingThemeManager.GetHighlightingByExtensionOrDetector(extension, text);
+ var highlighting = HighlightingThemeManager.GetHighlightingByExtensionOrDetector(path, extension, text);
Encoding = encoding;
SyntaxHighlighting = bufferCopy.Length > maxHighlightingLength
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingThemeManager.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingThemeManager.cs
index f5c8ad0..baa25d6 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingThemeManager.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingThemeManager.cs
@@ -42,7 +42,7 @@ public class HighlightingThemeManager
InitCustomHighlighting();
}
- public static HighlightingTheme GetHighlightingByExtensionOrDetector(string extension, string text = null)
+ public static HighlightingTheme GetHighlightingByExtensionOrDetector(string path, string extension, string text = null)
{
if (Light is null || Dark is null) return HighlightingTheme.Default;
@@ -56,7 +56,7 @@ public class HighlightingThemeManager
{
var useFormatDetector = SettingHelper.Get("UseFormatDetector", true, "QuickLook.Plugin.TextViewer");
- if (useFormatDetector && FormatDetector.Detect(text)?.Extension is string detectExtension)
+ if (useFormatDetector && FormatDetector.Detect(path, text)?.Extension is string detectExtension)
{
highlightingTheme = GetDefinitionByExtension(nameof(Dark), detectExtension)
?? GetDefinitionByExtension(nameof(Light), detectExtension);