Comments (6)
I would personally do this as a shortcode instead of an after, because with eleventy.after
you'd need to extract the code to highlight yourself, which can be hard to impossible.
For markdown highlighting there exists an eleventyConfig.addMarkdownHighlighter()
, but I think it's undocumented.
If I were to implement it, I'd probably keep it close to this plugin.
from eleventy-plugin-syntaxhighlight.
I strongly oppose "upgrading" to Torchlight with their current licensing model and the fact that their clients interact with an API.
This might be okay to integrate as an optional feature with big warning signs (or even better, a seperate plugin), but switching over completely would make this plugin inaccessible to many projects and 11ty users.
Although Tochlight definetly has some really nice features.
from eleventy-plugin-syntaxhighlight.
Ah yeah, show up super late here to say that Torchlight can absolutely live as a separate plugin! All of the hooks should be available!
from eleventy-plugin-syntaxhighlight.
Noted! Hadn't thought of any issues facing the licensing model. Most (just assuming) are using for a personal/open source project, but that's fair to point out.
@zachleat Out of interest and off the top of my head, and example of implementing this would be to use eleventy.after
and compiling the output with Torchlight?
module.exports = function (eleventyConfig) {
// Async-friendly in 1.0+
eleventyConfig.on('eleventy.after', async () => {
// Run me after the build ends
});
};
from eleventy-plugin-syntaxhighlight.
I guess the only reason I mentioned the eleventy.after is that one of Torchlights build processes is from standalone CLI, so thought that would be an easy route to use the CLI to process the html after 11ty has built it. I'm unaware of any Torchlight integration directly into a js/11ty pipeline that would work, but I'm not very experienced with Torchlight.
Thanks for the direction though, will try to learn and take a look into it. :)
from eleventy-plugin-syntaxhighlight.
Ahh, looking at the docs, I see what you mean.
It would probably be viable to use the CLI that way, but it would also force the user to use torchlight for all syntax highlighting (in a file) instead of for specific code blocks (e.g. when comparing syntax highlighters).
You could use their API directly, as you just need to post an object to https://api.torchlight.dev/highlight, but if you do that for each code block, you might hit rate limits fairly soon.
In general I would personally right now avoid this tool (except for experimentation), because rate limits are really low (for the commercial option) or unknown and the docs seem nice, but lack some information or are outdated (like the link to the remark plugin).
from eleventy-plugin-syntaxhighlight.
Related Issues (20)
- Added and removed lines get no special styling HOT 1
- Providing a default language for fenced code blocks HOT 8
- Add prismjs alias for `nunjucks` mapped to `jinja2` HOT 2
- Unsupported Languages cause Build Failures HOT 3
- Inline code support HOT 1
- Compatibility with markdown-it-attrs HOT 1
- Using the diff function, output is not escaped. HOT 3
- Cannot mix `diff` and `diff-lang` in one app HOT 1
- Feature request: config to add wrapping div HOT 3
- Syntax highlighting can fail if another plugin uses Prism too
- diff-javascript code block generates invalid HTML HOT 1
- Remove character wrap feature.
- Change default `lineSeparator` option to `\n` instead of `<br>` HOT 1
- possibility of adding plugins
- possibility of adding plugins
- possibility of adding Prismjs plugins to a config
- possibility of adding Prismjs plugins to a config
- [Discussion] Allowing users to override Prism instance
- If I'm using Ghost as a data source and it provides article content in HTML code, how can I do code highlighting?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eleventy-plugin-syntaxhighlight.