MarkEdit-app / MarkEdit

Just like TextEdit on Mac but dedicated to Markdown.
https://bit.ly/markedit-app
MIT License
1.16k stars 46 forks source link

QuickLook Extension can be broken by iA Writer #448

Closed CosmicToast closed 7 months ago

CosmicToast commented 10 months ago

The QuickLook extension doesn't appear to be registering when installing from GitHub. I have it ticked in ExtensionsQuick Look, but to no avail. I took a look at qlmanage -m plugins to see if it got registered, and indeed there's no entry for Markdown or for MarkEdit in there.

This is on Sonoma 14.2.1 (23C71).

cyanzhong commented 10 months ago

Thanks for reporting. This feels like a system bug since I cannot reproduce it and we didn't change anything related to the quicklook extension recently. Have you tried re-installing the app or rebooting the device?

You may also want to try re-launching the Finder app and opening MarkEdit once.

Also, qlmanage -m plugins will not tell you the truth because the quicklook extension in MarkEdit is not a .qlgenerator, it's something like this (implemented using https://developer.apple.com/documentation/quicklook):

image

Also, check if you have multiple MarkEdit instances installed, and most importantly, sometimes other applications that register markdown files can break the quicklook preview too, an example I discovered once ago was the Nova app.

CosmicToast commented 10 months ago

I've attempted the following (in no particular order, besides the last one):

None of these seem to have done anything.

cyanzhong commented 10 months ago

Did you install it via GitHub releases or brew?

Can you try if installing the Mac App Store version brings it back?

Also, it worth checking if the installed app has the extension like the screenshot I shared.

cyanzhong commented 10 months ago

Actually, I just tried brew install and it works fine. When I delete the app, the preview immediately disappears and when I re-install it (and open it once, which is required), it's back even without re-launching Finder.

Other than checking the existence of PreviewExtension.appex, you can check running processes:

There should be something related to Finder. Probably this is something I cannot resolve, if nothing I mentioned above works.

cyanzhong commented 10 months ago

One thing I forgot to ask @CosmicToast Can you find MarkEdit in System Settings > Privacy & Security > Extensions > Quick Look? If you can find it, try toggling its availability.

CosmicToast commented 10 months ago

Yes, I can find MarkEdit in System Settings > Privacy & Security > Extensions > Quick Look. Toggling it does nothing, including after I relaunch finder. PreviewExtension.appex is present as expected, both in github release version and homebrew version.

However, there is no MarkEdit processes at all, unless MarkEdit (the app itself) is running. Even then, there is no process mentioning Finder. It doesn't show up even with the app store version.

I tested a few other extensions, and the qlmarkdown extension seems to work as expected, so it's not a general "quicklook doesn't use any extensions" problem. There does seem to be something funny to do with markdown in particular though, since I also checked the bear quicklook extension and ttscoff's mmd-quicklook (a generator), neither of which had any noticeable effect (the latter, being a generator, didn't do anything even when invoked with qlmanage).

I honestly have no clue as to how to debug this, since it does seem like some plugins can work on the same files that fail otherwise.

cyanzhong commented 10 months ago

That's very interesting, thanks for sharing. If the preview extension of other apps don't work for you either, I suspect there's a problematic text editor. For example, as long as I install https://nova.app/, my markdown preview extension stops working immediately (even when I disable its extension). Other than that, I am running out of ideas. If you're a developer too and wondering what's going on, you can debug the source code of MarkEdit to figure it out.

cyanzhong commented 9 months ago

@CosmicToast Can you please try mdls? I just learned an interesting case where third-party apps can even change how files are displayed in Finder: https://apple.stackexchange.com/questions/384328/why-does-the-kind-column-show-the-chinese-characters-%E6%96%87%E4%BB%B6-for-markdown-files

CosmicToast commented 9 months ago

mdls consistently reports net.daringfireball.markdown. As an additional piece of interesting information, it looks like the quicklook plugin does work on text bundle files... just not plain .md as per above.

cyanzhong commented 9 months ago

Thanks for checking, it is the vanilla UTI for markdown. Working for text bundles at least means that the preview extension works fine, seems still something with the file type association, the extension is not invoked for .md.

CosmicToast commented 9 months ago

I tried to remove anything that could possibly hold the association. To do this, I did a recursive search for net.daringfireball.markdown in /Applications, /Library/QuickLook, ~/Applications and ~/Library/QuickLook. Anything that matched, I moved elsewhere and ensured none of it was registered anymore in any capacity. Then I disabled and re-enabled the extension...

Same result. The behavior is as such: I get the MarkEdit preview for text bundles, but a "plaintext" preview for .md files. The only hits for the UTI are MarkEdit and XCode.

Is it possible that XCode is holding the file type association?

cyanzhong commented 9 months ago

Is it possible that XCode is holding the file type association?

I don't know, but obviously I use Xcode.

cyanzhong commented 7 months ago

I am closing this since I am running out of ideas.

Just yesterday I discovered another case where quick look is broken for Markdown, the root cause was that I installed iA Writer.

It is very hard say what could wrong but I don't think there is anything I can do to improve.

Thanks again for the feedback.

CosmicToast commented 7 months ago

Funnily enough, after reading the above, I tried removing iA Writer and everything started working immediately. (I then reinstalled it and everything stayed ok, so hmm) This does warrant closing, and I'll change the title to help any future users. :)

cyanzhong commented 7 months ago

Thank you for confirming! That's a very interesting finding.

CosmicToast commented 7 months ago

Indeed from what I can see they don’t register any extensions for it or anything like that. Regardless, with the new title it should be searchable for anyone that has trouble.

ziadoz commented 6 months ago

@cyanzhong I'm also experiencing the issue described here.

I had iA Writer Classic installed (via Rosetta) when I installed Markedit alongside it by downloading it from GitHub.

Previews looks like this:

image

I tried a .mdown file extension and got this error:

image

I noticed there's a crash report in Console:

crashreport.txt

The preview extension crashing seems to also cause System Preferences to load and then crash instantly.

cyanzhong commented 6 months ago

@cyanzhong I'm also experiencing the issue described here.

I had iA Writer Classic installed (via Rosetta) when I installed Markedit alongside it by downloading it from GitHub.

  • I've deleted iA Writer Classic and cleaned up all of the applications files and extensions it left behind.
  • I've restarted my machine and relaunched Finder multiple times.
  • The QuickLook extension appears registered in System Preferences, and looks to be running in Activity Monitor.
  • I've also checked mdls and it recognises the file as kMDItemContentType = app.markedit.md.
  • I have Sublime Text installed (not sure if this is relevant, but I saw it mentioned).

Previews looks like this:

image

I tried a .mdown file extension and got this error:

image

I noticed there's a crash report in Console:

crashreport.txt

The preview extension crashing seems to also cause System Preferences to load and then crash instantly.

I checked the crash log and there's nothing worth investigating, they are all system logs.

ziadoz commented 6 months ago

I checked the crash log and there's nothing worth investigating, they are all system logs.

Oh ok. Well thanks for taking a look anyway. I ended up uninstalling MarkEdit because System Preferences just wouldn't open with it installed (presumably due to the preview extension).

cyanzhong commented 6 months ago

@ziadoz Have you enabled identified developers, not just from App Store?

image

I will be very surprised if the system is not opening a notarized app if you enabled sources other than App Store.

ziadoz commented 6 months ago

@cyanzhong I have that option enabled. The MarkEdit app opened and worked fine, it's just the preview extension which wasn't working.

It's the actual System Preferences app that doesn't work once MarkEdit is installed. I click the System Preferences icon, it appears in the dock, but there's no app window. Eventually it crashes, and I found that log matching the timestamp above.

Uninstalling MarkEdit and all its files using AppCleaner was the only thing that got System Preferences working again. It's very weird.

cyanzhong commented 3 weeks ago

I am making a change: https://github.com/MarkEdit-app/MarkEdit/pull/719, it seems with finding in #717, I finally figured out why 3rd-party apps can break the file association.

ziadoz commented 1 week ago

@cyanzhong I tried this again and it seems to work for now. I see a QuickLook preview of Markdown files, and the System Settings panel loads properly.

cyanzhong commented 1 week ago

@ziadoz thanks for confirming.