I ran into an interesting problem this evening. It actually started a few days ago when I noticed that my qq script wasn’t returning searches within the @(metadata) I set up in the note bodies. I figured I’d come back to it when I had time. Then I got a couple of emails from readers who had also noticed this, so I started digging. It turned out that Spotlight had stopped indexing text content of all files with the .md
extension. If I renamed the file to .txt
or .mmd
, it would work fine, but something had convinced Spotlight that Markdown files were source code, not text. My source code importers don’t handle Markdown, so I was getting no content imported.
A little testing with mdls
and mdimport -d2
showed that–on my system–only .md
files were being affected, but if you’re seeing this problem it could be happening with whatever file extension your system has registered as a Markdown document.
I don’t know who the culprit is yet. I grep’d through plists and schema.xml files throughout all of my apps and mdimporters, but to no avail. I figured if I couldn’t find the problem, I might as well hack a solution. The solution below worked perfectly for me. If you’ve noticed your searches in Spotlight or mdfind
coming up short, this might fix the issue. I’d love to hear back from people if it works for you.
- Download the file at the end of the post
- Unzip it into
~/Library/Spotlight/
Once you’ve done that, you can force a re-import of your Markdown files with:
mdimport -r ~/Library/Spotlight/Markdown.mdimporter
Again, let me know how it works. This is very much a hack experiment on my part. I basically took the default text importer, duplicated it and hacked the info.plist file to look for net.daringfireball.markdown
files. You can do this directly to the original importer, but I wanted an external solution that wouldn’t break with the next update. This is doing the trick for me.
Download
Markdown Spotlight Plugin v1
Download Markdown Spotlight Plugin v1
A quick mdimporter hack to make Spotlight index Markdown files which have been errantly marked as source code instead of plain text.
Published 10/18/11.
Updated 10/18/11. Changelog