Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何制作聚光灯索引标记文件?_Macos_Markdown_Spotlight - Fatal编程技术网

Macos 如何制作聚光灯索引标记文件?

Macos 如何制作聚光灯索引标记文件?,macos,markdown,spotlight,Macos,Markdown,Spotlight,我通常对标记文档使用.markdown或.md扩展名。不幸的是,spotlight拒绝为它们编制索引,除非它们具有.txt文件扩展名 我在textmate博客上看到了一个可能的解决方案。有更好的办法吗 更新:我刚刚发现它增加了聚光灯支持和漂亮的HTML quicklook预览。这是一种享受 你必须写一个聚光灯导入器。有一个Xcode项目模板,它将为您设置基本内容并让您开始;我认为还有一个开发者的例子 您的导入程序需要在其Info.plist中有一个UTExportedTypeDeclaratio

我通常对标记文档使用.markdown或.md扩展名。不幸的是,spotlight拒绝为它们编制索引,除非它们具有.txt文件扩展名

我在textmate博客上看到了一个可能的解决方案。有更好的办法吗


更新:我刚刚发现它增加了聚光灯支持和漂亮的HTML quicklook预览。这是一种享受

你必须写一个聚光灯导入器。有一个Xcode项目模板,它将为您设置基本内容并让您开始;我认为还有一个开发者的例子

您的导入程序需要在其Info.plist中有一个
UTExportedTypeDeclarations
部分,用于描述具有路径扩展名的标记文件的统一类型标识符。然后,只需让您的导入程序为降价文件传递适当的数据。

您可以编写导入程序,但有一种更简单的方法。标记只是文本,由聚光灯处理。如果您将降价文件的扩展名设置为“.txt”,Spotlight会将其选中


在我的例子中,我只是将我的全部命名为“.mdwn.txt”,并教emacs的标记模式为匹配此扩展名的文件激活。

这说明了如何修改RichText.mdimporter以导入源文件和标记文件。

以下内容适用于Mac OS X 10.11 El Capitan:

由于我们无法在El Capitan中编辑系统文件,因此必须暂时禁用SIP(系统完整性保护)(有关详细信息,请参阅此部分)

  • 通过重新启动计算机并按住
    command+R
    直到屏幕上出现Apple徽标,重新启动Mac进入恢复模式
  • 单击
    实用程序
    终端
  • 在终端窗口中,键入
    csrutil disable
    ,然后按Enter键
  • 重新启动Mac
现在,我们可以编辑位于
/System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist
的文件:

  • sudo open-文本编辑/System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist
  • LSItemContentTypes
    下添加
    net.daringfireball.markdown
    (有关更多信息,请参阅)
完成后,您可能希望重新索引包含标记文件的文件夹,请参阅本文:。
不要忘记通过重复第一部分并运行
csrutil enable

来重新打开SIP。通过创建系统RichText.mdimporter的副本、修改其Info.plist并将其保存在/Library/Spotlight中,您可以在不禁用SIP的情况下执行此操作

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
cp-r/System/Library/Spotlight/RichText.mdimporter。
修补程序-p2 RichText.mdimporter/Contents/Info.plist
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 @@
MDImporter
lsItemContentType
-public.rtf
-public.html
-public.xml
-公共文本
-com.apple.traditional-mac-plain-text
-com.apple.rtfd
-com.apple.webarchive
-org.oasis-open.opendocument.text
-org.openxmlformats.wordprocessingml.document
+net.daringfireball.markdown
@@ -30,11 +22,11 @@
cfbundlegetingfostring
1.0,版权所有(c)2004-2010苹果公司。
CbundleIdentifier
-com.apple.MDImporter.RichText
+com.apple.MDImporter.Markdown
CbundleInfo字典版本
6
CFBundleName
-富文本嗅探器
+降价嗅探器
CbundleShortVersionString
6.9
CbundleSupportedPlatform

这似乎与“编程”无关,但我很高兴“看门狗”没有击落你!我需要这个信息+1.当前的QL gen项目位于以下位置:。旧版本(链接到上面)不喜欢XCode 7…您真正需要做的就是复制富文本并添加
net.daringfireball.markdown
,但不管怎样,这个答案都很有魅力。谢谢@简单地说,是的,这在High Sierra对我很有效
cp-r/System/Library/Spotlight/RichText.mdimporter.
,然后添加那一行,然后
sudo cp-r RichText.mdimporter/Library/Spotlight
mdimport-r/Library/Spotlight/RichText.mdimporter.
OP在他的问题中特别回避了这种方法。
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>