kdl icon indicating copy to clipboard operation
kdl copied to clipboard

GitHub Syntax Highlighting

Open miraclx opened this issue 4 years ago • 9 comments

Would be nice to have GitHub identify and add syntax highlighting to KDL-formatted files

https://github.com/github/linguist

miraclx avatar Feb 08 '21 03:02 miraclx

Will note that GitHub will likely not include a new grammar for a language unless it can be demonstrated that the language is in significant enough usage ("hundreds of repositories").

~However, including it will require a TextMate-compatible language definition (i.e. for TextMate, Sublime Text Editor, Atom). For example, the YAML syntax highlighting uses the Atom package. The production of such a package for KDL would be the biggest step towards enabling GitHub to start using it when usage of KDL is sufficiently large.~

See below comment re existing TextMate definition.

shieldo avatar Feb 24 '21 14:02 shieldo

I think we have a TextMate definition here, but yes, as far as I am aware more usage is required for GitHub to consider adding it.

larsgw avatar Feb 24 '21 15:02 larsgw

I think KDL does have enough usage now! 2.3k hits for searching for path:*.kdl which is enough under the current rules. I am going through the steps to add a language but problems were found with the grammar (linked in the previous comment):

  • Invalid regex in grammar: source.kdl (in syntaxes/kdl.tmLanguage.json) contains a malformed regex (regex "(?![\\{\}<>;\[\]\=,\(\)\s])[\u00...": PCRE does not support \L, \l, \N{name}, \U, or \u (at offset 29))
  • Invalid regex in grammar: source.kdl (in syntaxes/kdl.tmLanguage.json) contains a malformed regex (regex "(?![\\{\}<>;\[\]\=,\(\)\s])[\u00...": PCRE does not support \L, \l, \N{name}, \U, or \u (at offset 29))

Any regex pros wanna jump in here? This sequence doesn't seem to be anywhere in the grammar.

uncenter avatar Oct 03 '23 01:10 uncenter

I'm also not entirely sure what license the grammar is under. It needs to be one of these (see github-linguist/linguist/CONTRIBUTING.md#L125).

uncenter avatar Oct 03 '23 02:10 uncenter

Maybe we can fix the grammar issues before 2.0? https://github.com/kdl-org/kdl/pull/285

uncenter avatar Oct 18 '23 01:10 uncenter

@uncenter The grammar is under Apache-2.0 by virtue of being in the vscode-kdl repo.

And yes, it would be nice to fix the grammar issues before 2.0! Although the textmate grammar has to kinda be redone to support 2.0.

zkat avatar Feb 08 '24 19:02 zkat

Oh it looks like the fixes already got merged.

Still, we should probably wait to pursue syntax highlighting until 2.0 is out.

zkat avatar Feb 08 '24 19:02 zkat

as far as that sequence being present, it's in the regex for identifiers: https://github.com/kdl-org/vscode-kdl/blob/main/syntaxes/kdl.tmLanguage.json#L97

I'm not really sure how to work around this. KDL, and especially KDL 2.0, has specific restrictions around unicode codepoints. Does this mean that linguist's PCRE doesn't support unicode matching at all, or is there a different syntax I should be using?

zkat avatar Feb 08 '24 20:02 zkat

oh maybe all that needs to be done is to use \x instead of \u 🤔

zkat avatar Feb 08 '24 21:02 zkat