#4213

XML syntax highlighting breaks if empty tag contains whitespace before close

OpenloserMcloseropened 1mo ago

Description

XML syntax highlighting handles <tagname attr="text"/> fine, but is borked by <tagname attr="text" />.

Environment

  • Version: 2.0.15 (6a62575b)
  • OS: Archlinux
  • Terminal: alacritty

Activity

1
Andriamanitra1mo ago

This is because the XML syntax (stupidly) always starts a new identifier from a space here:

https://github.com/micro-editor/micro/blob/393cf24858e63ba75af1480b618d2e3add5b9e3e/runtime/syntax/xml.yaml#L23

One fix would be to change the identifier start to require a NameStartChar (and we might as well allow \t as whitespace too while we are at it to bring it closer to the spec):

                start: '[ \t][:A-Z_a-z\x{C0}-\x{D6}\x{D8}-\x{F6}\x{F8}-\x{2FF}\x{370}-\x{37D}\x{37F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]'