Skip to content

Cannot pygmentize JSON with Unicode escapes (regression in Pygments==2.7.0) #1544

@vytas7

Description

@vytas7
$ echo -e '{\n     "French": "Fran\\u00e7ais",\n     "bug": true\n}\n' 
{
     "French": "Fran\u00e7ais",
     "bug": true
}

Using Pygments==2.7.0:

$ pygmentize -V
Pygments version 2.7.0, (c) 2006-2020 by Georg Brandl.
$ echo -e '{\n     "French": "Fran\\u00e7ais",\n     "bug": true\n}\n' | pygmentize -l json -F raiseonerror 

*** Error while highlighting:
pygments.filters.ErrorToken: "
   (file "<... my virtualenv ...>/lib/python3.8/site-packages/pygments/filters/__init__.py", line 783, in filter)
*** If this is a bug you want to report, please rerun with -v.
{

Removing -F raiseonerror does produce highlighted output, but it looks malformed.

Using Pygments==2.6.1 works as expected (output colours looked OK in my terminal):

$ pygmentize -V
Pygments version 2.6.1, (c) 2006-2019 by Georg Brandl.
$ echo -e '{\n     "French": "Fran\\u00e7ais",\n     "bug": true\n}\n' | pygmentize -l json -F raiseonerror 
{
     "French": "Fran\u00e7ais",
     "bug": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions