diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.cs
index 38cdb86..2f833dc 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.cs
@@ -15,9 +15,14 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+using System;
using System.IO;
+using System.Linq;
+using System.Reflection;
using System.Windows;
+using System.Xml;
using ICSharpCode.AvalonEdit.Highlighting;
+using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.TextViewer
@@ -30,6 +35,26 @@ namespace QuickLook.Plugin.TextViewer
public void Init()
{
+ HighlightingManager hlm = HighlightingManager.Instance;
+
+ string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ if (string.IsNullOrEmpty(assemblyPath)) return;
+
+ string syntaxPath = Path.Combine(assemblyPath, "Syntax");
+ if (!Directory.Exists(syntaxPath)) return;
+
+ foreach (string file in Directory.EnumerateFiles(syntaxPath, "*.xshd"))
+ {
+ string lang = Path.GetFileNameWithoutExtension(file);
+ using (Stream s = File.OpenRead(Path.GetFullPath(file)))
+ using (XmlTextReader reader = new XmlTextReader(s))
+ {
+ XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader);
+ IHighlightingDefinition highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
+ if (xshd.Extensions.Count > 0)
+ hlm.RegisterHighlighting(lang, xshd.Extensions.ToArray(), highlightingDefinition);
+ }
+ }
}
public bool CanHandle(string path)
diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/QuickLook.Plugin.TextViewer.csproj b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/QuickLook.Plugin.TextViewer.csproj
index 685a6b1..d5bb817 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/QuickLook.Plugin.TextViewer.csproj
+++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/QuickLook.Plugin.TextViewer.csproj
@@ -65,6 +65,7 @@
+
..\..\packages\UTF.Unknown.1.0.0-beta1\lib\net40\UtfUnknown.dll