SourceCodeSyntaxHighlight icon indicating copy to clipboard operation
SourceCodeSyntaxHighlight copied to clipboard

On macOS 13.0, JSON files are still handled by system

Open hywhuangyuwei opened this issue 2 years ago • 24 comments

I have tested many source code files and they have been previewed perfectly by SourceCodeSyntaxHighlight. But .json files are not working correctly (though .jsonc files are working)

Here is my config:

  • mdls -name kMDItemContentType JSONPATH -> kMDItemContentType = "public.json"
  • qlmanage -m | grep public.json -> public.json -> /System/Library/QuickLook/Text.qlgenerator (961)
  • System preferences: image
  • SyntaxHighlight preferences: image

hywhuangyuwei avatar Sep 12 '22 10:09 hywhuangyuwei

Also, after turning on debug mode, previewing a .json file does not generate a .log file on my desktop.

hywhuangyuwei avatar Sep 12 '22 10:09 hywhuangyuwei

At the moment I have no way to test macOS 13. But if the operating system has reserved the use of the json extension it will not be possible to solve the problem in any way.

sbarex avatar Sep 12 '22 15:09 sbarex

At the moment I have no way to test macOS 13. But if the operating system has reserved the use of the json extension it will not be possible to solve the problem in any way.

Is there a way to check whether this is reserved by system?

hywhuangyuwei avatar Sep 12 '22 16:09 hywhuangyuwei

no, if a custom Quick Look Extension do not handle the .json, the format is likely to be managed by the system...

sbarex avatar Sep 12 '22 18:09 sbarex

I've stumbled at this very same issue. It was working before I upgraded to Ventura.

alanwilter avatar Nov 15 '22 13:11 alanwilter

It's very weird, but now it's working:

Screenshot 2022-11-16 at 16 13 08

alanwilter avatar Nov 16 '22 16:11 alanwilter

I had the same problem

ZhangRuiMingZRM avatar Nov 17 '22 10:11 ZhangRuiMingZRM

On my system the json extension is handled correctly.

From the Terminal, what is the output of this command? mdls -name kMDItemContentType JSONPATH

sbarex avatar Nov 17 '22 11:11 sbarex

I have tested many source code files and they have been previewed perfectly by SourceCodeSyntaxHighlight. But .json files are not working correctly (though .jsonc files are working)

Here is my config:

  • mdls -name kMDItemContentType JSONPATH -> kMDItemContentType = "public.json"
  • qlmanage -m | grep public.json -> public.json -> /System/Library/QuickLook/Text.qlgenerator (961)
  • System preferences:

On my system the json extension is handled correctly.

From the Terminal, what is the output of this command? mdls -name kMDItemContentType JSONPATH

@sbarex Now, the output of mdls -name kMDItemContentType JSONPATH is kMDItemContentType = "public.json". (just the same as when I opened this issue)

hywhuangyuwei avatar Nov 17 '22 11:11 hywhuangyuwei

It's very weird, but now it's working:

Screenshot 2022-11-16 at 16 13 08

I think this preview is not generated by my application. I don't have the button to expand/collapse the items (unless you have activated some plugin).

sbarex avatar Nov 17 '22 11:11 sbarex

I have tested many source code files and they have been previewed perfectly by SourceCodeSyntaxHighlight. But .json files are not working correctly (though .jsonc files are working) Here is my config:

  • mdls -name kMDItemContentType JSONPATH -> kMDItemContentType = "public.json"
  • qlmanage -m | grep public.json -> public.json -> /System/Library/QuickLook/Text.qlgenerator (961)
  • System preferences:

On my system the json extension is handled correctly. From the Terminal, what is the output of this command? mdls -name kMDItemContentType JSONPATH

@sbarex Now, the output of mdls -name kMDItemContentType JSONPATH is kMDItemContentType = "public.json". (just the same as when I opened this issue)

maybe the extension is being handled by other applications which is not working well....

You can search in the output of this command which app uses the public.json uti: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump Limit the search only to extension point ID: com.apple.quicklook.preview and type id: com.apple.quicklook-generator

sbarex avatar Nov 17 '22 11:11 sbarex

I think this preview is not generated by my application. I don't have the button to expand/collapse the items (unless you have activated some plugin).

Indeed, I've installed brew install --cask quicklook-json

alanwilter avatar Nov 17 '22 12:11 alanwilter

maybe the extension is being handled by other applications which is not working well....

You can search in the output of this command which app uses the public.json uti: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump Limit the search only to extension point ID: com.apple.quicklook.preview and type id: com.apple.quicklook-generator

Here is my script:

filename = '/Users/hywhu/Downloads/dump.txt'
divider = '--------------------------------------------------------------------------------'

with open(filename, mode='r') as f:
    records = f.read().split(divider)
    print(f"len = {len(records)}")
    for r in records:
        bool1 = r.find('public.json') > 0
        bool2 = r.find('com.apple.quicklook.preview') > 0
        bool3 = r.find('com.apple.quicklook-generator') > 0
        if bool1 and (bool2 or bool3):
            print([line for line in r.splitlines() if line.startswith('path')][0])

Its output is:

len = 10239
path:                       /Applications/Syntax Highlight.app/Contents/PlugIns/Syntax Highlight Quicklook Extension.appex (0x851c)
path:                       /System/Library/Frameworks/QuickLookUI.framework/Versions/A/PlugIns/QLPreviewGenerationExtension.appex (0x76fc)

hywhuangyuwei avatar Nov 17 '22 12:11 hywhuangyuwei

It is correct.

Then try to open the Console.app, start the monitor and open a quicklook preview for a json file and see if in the log exists some error messages.

sbarex avatar Nov 17 '22 13:11 sbarex

It is correct.

Then try to open the Console.app, start the monitor and open a quicklook preview for a json file and see if in the log exists some error messages.

( I used the keyword quicklook to filter out log items image ) When quicklook a json file, no log is listed; When quicklook a normal js file, there are some log items about Syntax Highlight.app listed.

hywhuangyuwei avatar Nov 17 '22 14:11 hywhuangyuwei

@alanwilter Hi, I also have the quicklook-json extension installed, but json files are still handled by Syntax Highlight. Do you happen to know how to prioritize one extension over another? I’m using Ventura as well.

twio142 avatar Dec 06 '22 14:12 twio142

Did you happened to instal quicklook-json after syntax-highlight? This is only thing I did. Aside from that I'm afraid I have no clue.

alanwilter avatar Dec 06 '22 14:12 alanwilter

Before Ventura it was possible to reorder the plugin list from the system preferences and (perhaps) it would be used as a priority criteria. In Ventura this feature is gone.

sbarex avatar Dec 06 '22 14:12 sbarex

I temporally uninstalled syntax highlight, but quicklook-json is just not working at all 😅 ok then.

twio142 avatar Dec 06 '22 14:12 twio142

even if you removed both then install only quicklook-json?

I realised now there are two other things you may want to try to:

  1. qlmanage -r
  2. restart Finder app.

alanwilter avatar Dec 07 '22 08:12 alanwilter

Running into the same issue. The system I'm on

image

boedy avatar Jan 06 '23 13:01 boedy