Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

SyntaxEdit and JSON syntax parser - please add

I don't know why I haven't requested this before (at least as far as I can remember).

1. Please add a JSON syntax parser scheme to SyntaxEdit.
2. Please use this scheme in the HTML.xml syntax scheme for <script type="application/ld+json"> ... </script> and <script type="application/json"> ... </script>

A customer had a question about this related to improper syntax parsing/highlighting of JSON in a <script type="application/ld+json"> ... </script> .

Hopefully this would not be difficult to add and very worthwhile because of the popularity and simplicity of JSON.

Thank you.


Comments

  • 13 Comments sorted by Votes Date Added
  • Done.
  • Fantastic! Thank you!

  • Some follow-up questions.

    1. Does the new JSON syntax scheme work with SyntaxEdit 2021? It doesn't seem to be working for me (JSON text is showing as all one color).

    2. To verify, I tried to download the precompiled SyntaxEdit demo dated Feb 14, 2022 from https://www.lmd.de/download#lmd-ide-tools-2022 and got an older demo from 2021. Perhaps these demos have not yet been updated?

    Thank you.
  • 1) Should work. You need to reload all schemes, since they are depend one from another.
    2) We'll check.
  • 2) Fixed. The link now points to the updated demo.
  • edited February 2022 Posts: 192Vote Up0Vote Down
    Thanks. Got the demo EXE and can see the new JSON scheme in action but still can't get it to work with SyntaxEdit 2021 for some reason.

    My code should be loading all the schemes to a 'master' document then using Assign() to copy the schemes from the 'master' document to other documents.

    JSON documents are displaying with only one text color.... I'm still trying to figure out what's going on.


    PNG
    PNG
    Capture.PNG
    17K
  • You should specify somewhere in your project that the json scheme should be used for json files. For example, our example GetSyntaxScByExt method, which is used in SetCurrentDoc method.

    Actually, you should set:

    MyEditDocument.ActiveSyntaxScheme := 'Json';
  • edited February 2022 Posts: 192Vote Up0Vote Down
    Hello, yes, I'm going that.

    I think I figured out the issues.

    First, I think the text color being all blue for *.json documents was because I was using the SyntaxEdit 2021 default.xml color scheme which specifies blue for the JSON tokens... so it was working but didn't look like it was because all the tokens were the same color.

    Second, the JSON in HTML documents was acting weird and/or not working and I think it's because of some bugs in HTML.xml. Instead of this:
                (type \s* = \s* (&quot;|&apos;) \s* application/json \s* \6 ) |
                (type \s* = \s* (&quot;|&apos;) \s* application/ld\+json \s* \6 )

    Shouldn't it be this (change 1st \6 to \3 and 2nd \6 to \5)?
                (type \s* = \s* (&quot;|&apos;) \s* application/json \s* \3 ) |
                (type \s* = \s* (&quot;|&apos;) \s* application/ld\+json \s* \5 )

    I think a similar error may exist for text/VBScript... although I doubt anyone uses that anymore.
  • edited February 2022 Posts: 0Vote Up0Vote Down
    It works fine for me in both cases: as a standalone JSON, and as well, as embedded in HTML.
  • Demo screenshots.
    png
    png
    1.png
    27K
    png
    png
    2.png
    13K
  • edited February 2022 Posts: 192Vote Up0Vote Down
    Without the 'fix', it doesn't work for me. In an HTML document, it looks like it uses the JavaScript parser instead of the JSON parser (notice in broken.png the 'function' keyword is in bold and the number 500 is not the proper color for the colors I'm using for "number" tokens).


    png
    png
    works.png
    20K
    png
    png
    broken.png
    20K
  • Two questions:

    1) Why you are not using new 2022 version?
    2) Can you confirm that the new version of syntax edit demo works in this aspect?

    Because at my side everything work fine even without your modifications.
    png
    png
    изображение_2022-02-24_151005.png
    7K

  • 1) I thought about using 2022 but I was releasing a minor update and wanted to wait for the next minor update or maybe even the next major release of my software.... or maybe wait until I update other components as well...we'll see... I definitely plan on eventually using SyntaxEdit 2022 but I want more time to figure out how I will offer the users access to the new color themes.

    2) Strangely, it does seem to work in the 2022 demo.
Sign In or Register to comment.