Skip to content

tmLanguage file: python considers it invalid xml? #195

Closed
@asottile

Description

@asottile

(kinda meta so I deleted the default text here)

A little background, I'm trying to use the textmate grammars here to power a terminal highlighter for a text editor I'm building -- as such I'm using the plist format of various grammars (vs code's json ones strip useful information like the file types, and cson is slow to parse and requires an external dependency)

when trying to use the tmLanguage files provided here, I get an error loading them as the xml comment appears before the declaration:

  File "/home/asottile/workspace/textmate-highlight/demo/../highlight_demo.py", line 306, in parse
    data = plistlib.load(f)
  File "/usr/lib/python3.8/plistlib.py", line 986, in load
    raise InvalidFileException()
plistlib.InvalidFileException: Invalid file

If I run this through an xml validator (I'm using check-xml), it also complains as well:

$ check-xml MagicPython.tmLanguage 
MagicPython.tmLanguage: Failed to xml parse (MagicPython.tmLanguage:2:0: XML or text declaration not at start of entity)

An easy fix for this would be to move the comment below the xml declaration, which passes/parses fine:

$ head -3 MagicPython.tmLanguage 
<?xml version="1.0" encoding="UTF-8"?>
<!-- AUTOGENERATED FROM grammars/src/MagicPython.syntax.yaml -->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
$ check-xml MagicPython.tmLanguage 
$

any chance that I could fix this by moving the comment down one line? I'd be happy to submit a PR if you point me in the right direction -- thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions