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

How do I add support for typescript syntax highlighting? #19

Closed
martinfjant opened this issue Jan 2, 2020 · 5 comments
Closed

How do I add support for typescript syntax highlighting? #19

martinfjant opened this issue Jan 2, 2020 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@martinfjant
Copy link

So, I really do not get how I am supposed to extend the languages Prism can highlight. Where and how do I add say typescript if I want it to be able to highlight that?

@zachleat
Copy link
Member

zachleat commented Jan 3, 2020

https://prismjs.com/#languages-list

Language examples are documented here for Markdown, Liquid, and Nunjucks: https://www.11ty.dev/docs/plugins/syntaxhighlight/#markdown-highlighter Most of the examples use js but you can use typescript or ts per the prism doc link above.

@martinfjant
Copy link
Author

martinfjant commented Jan 3, 2020

The problem is, that ts is not instanciated per default (only markup, javascript and clike are). So, when I try to add it as per the documentation, and use it but using ts rather than js in my code fences , I get errors:

[eleventy:default] Language does not exist ts
[eleventy:default] Problem writing Eleventy templates: (more in DEBUG output)
[eleventy:default] > Having trouble rendering liquid (and markdown) template ./src/blog/track.md (TemplateContentRenderError)
[eleventy:default] > Cannot read property 'rest' of undefined (TypeError):

@martinfjant
Copy link
Author

Okay, so I changed it to say typescript rather than ts, and it worked. I'm not sure this is a bug with Prism (that lists both ts and typescript as supported) or the plugin. Sorry for taking up time, but this might help someone else in the future perhaps! Thanks for the really fast feedback, by the way! ❤️

@zachleat zachleat added this to the v3.0.1 milestone Jan 3, 2020
@zachleat zachleat added bug Something isn't working and removed education labels Jan 3, 2020
@zachleat
Copy link
Member

zachleat commented Jan 3, 2020

Ah hmm, I believe you did uncover a bug here. I don’t think aliases are quite resolving correctly with the Prism loader

Related:
PrismJS/prism#593
PrismJS/prism#768
PrismJS/prism#972

@zachleat
Copy link
Member

zachleat commented Jan 3, 2020

Pushed a fix to this, it’ll go up with 3.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants