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 support with highlight.js or similar #175

Closed
dsikes opened this issue Jan 13, 2022 · 5 comments · Fixed by #176
Closed

syntax highlighting support with highlight.js or similar #175

dsikes opened this issue Jan 13, 2022 · 5 comments · Fixed by #176
Assignees

Comments

@dsikes
Copy link
Contributor

dsikes commented Jan 13, 2022

How much work would it be to have syntax highlighting support using something like https://highlightjs.org/?

@skx
Copy link
Owner

skx commented Jan 14, 2022

It looks like highlightjs is pretty simple to support, looking over the pull-requests there to see an example of adding syntax highlighting for a new thing:

You'd only need identifiers, and our keywords ("case", "default", .. "true", "while"). I guess catching strings, and numbers would be nice too.

I could have a stab at it, though I'm not sure how likely it would be to be accepted.

@skx skx self-assigned this Jan 14, 2022
@skx
Copy link
Owner

skx commented Jan 14, 2022

I've hacked up a quick demo, and it seems to work. I'll past the code into this issue once I'm happier, and submit a PR to the original project.

  • Clone the code.
  • Add my evalfilter.js
    • src/languages/evalfilter.js
  • Build the docker container to test it.
    • cd ~/highlight.js/ ; docker build -t highlight .
  • Launch the docker container
    • docker run --rm -it --publish 8080:80 highlight
  • Confirm it works via the browser

via building and testing with docker.

@skx
Copy link
Owner

skx commented Jan 14, 2022

Pull-request opened, we'll see how well I did:

You can take the evalfilter.js from there.

skx added a commit that referenced this issue Jan 15, 2022
This pull-request adds a simple highlight.js-helper for syntax
highlighting of evalfilter code.

This closes #175.
@skx
Copy link
Owner

skx commented Jan 15, 2022

Turns out they're too busy to accept/maintain new languages in the highlight.js project, so I've added a snippet beneath misc/ along with a demo.

Hope that's enough.

@skx skx closed this as completed in #176 Jan 15, 2022
@dsikes
Copy link
Contributor Author

dsikes commented Jan 15, 2022

Thanks for the quick turn around. The misc/ example is perfect.

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

Successfully merging a pull request may close this issue.

2 participants