Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XHTML? #3421

Open
TailsFanLOL opened this issue Aug 6, 2024 · 3 comments
Open

XHTML? #3421

TailsFanLOL opened this issue Aug 6, 2024 · 3 comments

Comments

@TailsFanLOL
Copy link

Description of the problem or steps to reproduce

I want an XHTML syntax highlighter. Shouldn't be that difficult to implement. Currently it defaults to XML.

Specifications

Commit hash: doesn't show, OS reports 2.0.9-1ubuntu0.22.04.2, but I took my time to look through the syntax files in this repo to make sure there's no such thing that I want right now.
OS: Ubuntu Jammy
Terminal: Alacritty

@Andriamanitra
Copy link
Contributor

Doesn't the HTML syntax highlighting (you can try it with setlocal filetype html) work for XHTML too? Or do you mean that you would like some XHTML specific file extension(s) to be automatically detected as HTML?

@TailsFanLOL
Copy link
Author

TailsFanLOL commented Aug 7, 2024

It does work, but XHTML has a much stricter syntax. For example, all tags must be closed with no exceptions, attributes must be lowercase, attributes must have a value, etc.

@Andriamanitra
Copy link
Contributor

It does work, but XHTML has a much stricter syntax. For example, all tags must be closed with no exceptions, attributes must be lowercase, attributes must have a value, etc.

Micro's syntax highlighting system is based on regular expressions and thus not advanced enough to pair (nested) tags or do any other kind of advanced syntax analysis. I guess the syntax highlighting could help with some simple things such as only coloring lowercase attributes that end with a '=', but in general you would be better off using a linter (or a language server) to catch mistakes. As far as I know the HTML syntax should be a superset of XHTML syntax and as such sufficient to highlight any correctly formatted XHTML file.

That said if you do want to give making a bespoke XHTML syntax a go the html.yaml syntax would be a good starting point. Just copy the contents of that file to ~/.config/micro/syntax/xhtml.yaml and start hacking! The system is rather simple, you don't need any programming experience (besides the basics of regular expressions). You could then either publish it as a plugin or make a pull request to try and get it merged to the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants