sbarex / SourceCodeSyntaxHighlight

Quick Look extension for highlight source code files on macOS 10.15 and later.
GNU General Public License v3.0
2.98k stars 72 forks source link

Extension Supports Fewer Formats than App #1

Closed alexclst closed 2 years ago

alexclst commented 5 years ago

I thought at first that the extension wasn’t working because there were files (in my case, a shell script) that the App could show but the Quick Look extension could not. The extension should support all the same formats as the App, and actually there are some (XML, Plists, JSON, YML, just to name a few) that I believe QLColorCode supported that this App and Extension do not yet support. It should support all of these.

sbarex commented 5 years ago

Ok, I add some other format but xml, plist and many others don't works for now. I have to understand why ... does anyone have an idea? In QLSupportedContentTypes I have inserted the content type for the xml format but extension don't preview this file type...

sbarex commented 5 years ago

I make more test and bugfix and I have added many other language definitions, but xml, plist and other format still don't works.

xml, plist, json, plain text (and other non source file extensions) are handled by /System/Library/QuikLook/Text.qlgenerator. Booting into Recovery mode, I removed this generator, but after a reboot my extension still not handle xml and plist files! It is maos that does not allow quicklook customization for some type of file?! For example I have created the thefinition for a custom type org.sbarex.xml that handle .xml and .myxml extension. The plugin handle correctly .myxml but non .xml. Similarly I have added a definition for typescript files (UTI com.microsoft.typescript, extension .ts). MacOS recognize .ts file as a mpeg stream and the plugin don't works!

I don't found a solution to force the use of my extension. The tool qlmanage don't help a lot... For example the argument -g to force the use of a specific generator don't work with a quicklook plugin and I don't found any possibilble substitute. Also the parameter -m to show registered generator don't show application extension. To see registered quicklook extension you can use pluginkit -mAvvv -p com.apple.quicklook.preview.

rileytwo commented 5 years ago

@sbarex have you tried looking at the uti of an xml or plist file? You can run this in at the command line:

mdls -name kMDItemContentType -name kMDItemContentTypeTree -name kMDItemKind file.xml

which outputs something like this:

kMDItemContentType     = "public.xml"
kMDItemContentTypeTree = (
    "public.xml",
    "public.text",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemKind            = "XML Document"

Maybe the contents of KMDItemContentTypeTree need to be added to QLExt/Info.plist, as strings in the public.filename-extension array under the UTTypeTagSpecification dict?

sbarex commented 5 years ago

Yes I tried and I added the UTI public.xml inside the QLSupportedContentTypes property of the Info.plist extension.

Also I have created a new document type (org.sbarex.xml) conformed to public.xml that use .xml extension (and .myxml). This type definition is in the Exported Type UTIs of the Info.plist application and in the Impoted Type UTIs of the extension plist. And in QLSupportedContentTypes I added the org.sbarex.xml. File with extension .myxml are processeded by the extension, so the plist configuration I hope is correct. But .xml files are not passed to the quicklook extension...

sbarex commented 5 years ago

I also try to sign the app, notarizing and moving inside /Applications. But xml, plist, ts… still are not handled!

setanarut commented 5 years ago

In my opinion. This application should not be limited to highlight only. it should combine the features of other plugins under one roof. The application should be given a name like QLSwissArmyKnife. (qlImageSize, BetterZipQL)

sbarex commented 5 years ago

I prefer an app that does just one thing and good that many things roughly ... For many features you need a programmer with more experience on macos apps

alexclst commented 5 years ago

I agree with @sbarex that this app should just be focused on the source code (and related formats like plist and JSON) Quick Look preview. That being said, the thought has crossed my mind that someone maybe should start a Quick Look Library-like app that can be built out to some day become a central host app for multiple Quick Look App Extensions from assorted developers. But this app is not that. I, though I have experience with iOS and Mac app development, and have lent that knowledge to this project in a few of my suggestions, also do not have time at the moment to create this sort of thing.

orefalo commented 4 years ago

Hi, first and foremost, thank you for this great extension - really helpful. You should advertise it more - it deserves more attention.

Next, just pointing out the same issue as mentioned in this thread.

$ qlmanage -m plugins |grep Text.ql
  public.plain-text -> /System/Library/QuickLook/Text.qlgenerator (905.1)
  com.apple.property-list -> /System/Library/QuickLook/Text.qlgenerator (905.1)
  public.rtf -> /System/Library/QuickLook/Text.qlgenerator (905.1)
  org.oasis-open.opendocument.text -> /System/Library/QuickLook/Text.qlgenerator (905.1)
  public.xml -> /System/Library/QuickLook/Text.qlgenerator (905.1)
  com.apple.rtfd -> /System/Library/QuickLook/Text.qlgenerator (905.1)
  public.json -> /System/Library/QuickLook/Text.qlgenerator (905.1)

I can't overload these system generators! Issue with osx..

sbarex commented 4 years ago

thanks, I'm afraid it's an apple limitation, not only for some source file formats, but also for jpg, png, ... I submitted a request for feedback to apple about a month ago to clarify which formats are reserved but obviously I have not yet received a reply.

NylonDiamond commented 4 years ago

xml support would be cool as I deal with it daily.

sbarex commented 4 years ago

xml support would be cool as I deal with it daily.

unfortunately for xml, ts and plist format I don't have a solution

winkelsdorf commented 4 years ago

This should be closed as "won't fix", you simply cannot override QuickLook for all public.* types in macOS Catalina. See https://forums.developer.apple.com/thread/124857.

If you want it to be changed, like me, send your feedback to Apple.

sbarex commented 4 years ago

I know, it's my post ;-) ... Apple never responded to my feedback request :-(

winkelsdorf commented 4 years ago

@sbarex I don't know why, but I already thought it was you. Timing was just too perfect 😅 Sad to hear, now it's very unlikely to see anything change soon.

sbarex commented 4 years ago

Yeah, but it would be enough for Apple to tell us which files are not customizable so you can stop making empty attempts,

winkelsdorf commented 4 years ago

@sbarex Absolutely, fully agreed. I was experimenting with the QLVideo extension right now and came across the same issue there.