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

Upgrade to use Torchlight? #74

Closed
aaronstezycki opened this issue Nov 1, 2022 · 6 comments
Closed

Upgrade to use Torchlight? #74

aaronstezycki opened this issue Nov 1, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@aaronstezycki
Copy link

Comes with a wide array of functionality (seems to come up alot in the issues, i.e. line numbers, diffs) baked in.
Also comes with focusing, collapsible sections and much more.

Would probably need to use the CLI version of Torchlight, but should work well.
Torchlight.dev

@Snapstromegon
Copy link
Member

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.

@zachleat zachleat added the enhancement New feature or request label Jan 30, 2023
@zachleat
Copy link
Member

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!

@zachleat zachleat closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2023
@aaronstezycki
Copy link
Author

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
  });
};

@Snapstromegon
Copy link
Member

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.

@aaronstezycki
Copy link
Author

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. :)

@Snapstromegon
Copy link
Member

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).

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

No branches or pull requests

3 participants