Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make spotlight index markdown files?

Tags:

I typically use the .markdown or .md extension for markdown documents. Unfortunately spotlight refuses to index them unless they have the .txt file extension.

I've seen a possible solution involving editing Info.plist files on the textmate blog. Is there a better way?

Update: I just discovered QuickLook generator for Markdown files which adds spotlight support and nice HTML quicklook previews. It works a treat!

like image 330
mloughran Avatar asked Dec 13 '08 20:12

mloughran


1 Answers

You can do this without disabling SIP by creating a copy of the system RichText.mdimporter, modifying its Info.plist and saving it in /Library/Spotlight.

cp -r /System/Library/Spotlight/RichText.mdimporter .
patch -p2 RichText.mdimporter/Contents/Info.plist < Markdown.patch
mv RichText.mdimporter Markdown.mdimporter
sudo cp -R Markdown.mdimporter /Library/Spotlight
mdimport -r /Library/Spotlight/Markdown.mdimporter

Markdown.patch

diff -ru RichText.mdimporter/Contents/Info.plist Markdown.mdimporter/Contents/Info.plist
--- RichText.mdimporter/Contents/Info.plist 2015-11-23 16:14:12.000000000 +0200
+++ Markdown.mdimporter/Contents/Info.plist 2015-11-23 16:10:03.000000000 +0200
@@ -13,15 +13,7 @@
            <string>MDImporter</string>
            <key>LSItemContentTypes</key>
            <array>
-               <string>public.rtf</string>
-               <string>public.html</string>
-               <string>public.xml</string>
-               <string>public.plain-text</string>
-               <string>com.apple.traditional-mac-plain-text</string>
-               <string>com.apple.rtfd</string>
-               <string>com.apple.webarchive</string>
-               <string>org.oasis-open.opendocument.text</string>
-               <string>org.openxmlformats.wordprocessingml.document</string>
+               <string>net.daringfireball.markdown</string>
            </array>
        </dict>
    </array>
@@ -30,11 +22,11 @@
    <key>CFBundleGetInfoString</key>
    <string>1.0, Copyright (c) 2004-2010 Apple Inc.</string>
    <key>CFBundleIdentifier</key>
-   <string>com.apple.MDImporter.RichText</string>
+   <string>com.apple.MDImporter.Markdown</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
-   <string>Rich Text Sniffer</string>
+   <string>Markdown Sniffer</string>
    <key>CFBundleShortVersionString</key>
    <string>6.9</string>
    <key>CFBundleSupportedPlatforms</key>
like image 92
Brian Reiter Avatar answered Sep 28 '22 17:09

Brian Reiter