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

Syntax Highlighting on Website for Soar Code #24

Open
1 of 3 tasks
moschmdt opened this issue Jun 2, 2024 · 5 comments
Open
1 of 3 tasks

Syntax Highlighting on Website for Soar Code #24

moschmdt opened this issue Jun 2, 2024 · 5 comments

Comments

@moschmdt
Copy link
Contributor

moschmdt commented Jun 2, 2024

It would be nice, if the Soar code snippets on the website would have syntax highlighting.

According to the MkDocs Material docs relies on pygments to highlight the syntax of code blocks. Unfortunately, pygments does not have a Soar lexer, yet.

I have created a pygments lexer for Soar in my fork, but this needs more work until it might be in a state which is acceptable to be merged in pygments.

Tasks for native highlighting for Soar code via mkdocs:

  • Complete Lexer in fork
  • Merge Soar lexer in upstream pygments
  • Update mkdocs material version once pygments version is updated.
@moschmdt moschmdt changed the title Syntax Highlighting on Website Syntax Highlighting on Website for Soar Code Jun 2, 2024
@garfieldnate
Copy link
Collaborator

Wow, a Soar lexer would be really amazing! Writing a general Soar parser is really difficult, but it looks like you don't actually have to do that to get syntax highlighting. This will make our website look a lot better, but will also do the same for anyone else that wants to write/blog about Soar, which would be really wonderful. Thank you! I'm looking forward to this.

@garfieldnate
Copy link
Collaborator

Gonna note here since I was thinking about it:

It would be great to have syntax highlighting on GitHub, too, but GitHub asks that there be at least 200 unique repositories that contain a particular language before accepting a new extension to linguist, and I don't think we qualify yet: https://github.com/search?q=path%3A%2F%28%5E%7C%5C%2F%29.*%5C.soar%24%2F&type=code.

@moschmdt
Copy link
Contributor Author

moschmdt commented Jun 5, 2024

As of now, the lexer works fairly good, see examples, but everything is very gray due to the coloring of mkdocs material and the pygments tokens for ^variable and <variable> are Name.Variable, cf. test files

Any idea/ suggestion on how to separate ^variable and <variable> into different reasonable pygments tokens without creating a new code highlighting theme for mkdocs (if that is even possible for a single language..)?

Examples

Left-side displays updated version with local pygments version with Soar support, left-side is current upstream version.

Light mode example:

image

Dark mode example:

image

@garfieldnate
Copy link
Collaborator

Not sure what <> is getting marked as, but I guess it could be an operator or a keyword. The ^xyz tokens could be marked as Name.Property or Name.Attribute perhaps? Not sure how all of the different coloring might look. The gray is indeed unfortunate.

@moschmdt
Copy link
Contributor Author

moschmdt commented Jun 7, 2024

<> is currently marked as operator.

I decided to declare all identifiers as Name only. Thus, they have a little darker colorization.

moschmdt added a commit to moschmdt/documentation that referenced this issue Jul 31, 2024
Since the pygments PR is not reviewed yet this already enables the Soar syntax highlighting and might allow us to catch existing bugs.

This also enables the use of mkdocs material code annotations.

Related: SoarGroup#24
moschmdt added a commit to moschmdt/documentation that referenced this issue Jul 31, 2024
Since the pygments PR is not reviewed yet this already enables the Soar syntax highlighting and might allow us to catch existing bugs.

This also enables the use of mkdocs material code annotations.

Related: SoarGroup#24
garfieldnate pushed a commit that referenced this issue Aug 1, 2024
Since the pygments PR is not reviewed yet this already enables the Soar syntax highlighting and might allow us to catch existing bugs.

This also enables the use of mkdocs material code annotations.

Related: #24
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