Suggest breaking changes for v4 #32
Replies: 1 comment 4 replies
-
|
PCE is evolving rapidly, and I'm currently using it as a drop-in replacement for Prism. While my variation significantly extends the existing implementation, I use PCE to generate both static and editor output code blocks. Hover DescriptionsI think it would be great to introduce hover descriptions. The addition of completions is excellent, and we could take it a step further by supporting hover descriptions in isolation, though this requires some consideration. Recently, I found the need to effectively describe some code within a code block. Personally, I don't like Shiki much, but I do appreciate the two-slash implementation. However, it comes with a lot of overhead and can be difficult to manage. It's definitely not something for PCE, but a variation could work quite well, in my opinion. A very rough example of how this might look: {
onHover({ token: string, language: string }) {
// token will be the grammar token name
// language will be the current language name
return {
description: string; // provide an HTML string to render in the tooltip
signature: string; // provide an HTML string to render as the signature
};
}
}While this example doesn't account for The idea here is to allow the user to specify the hovers to apply, without doing too much heavy lifting. The current CSS and styling give us great customisation options, the same can apply with something like this, meaning the user can control how the tooltip/popover looks. HydrationWe briefly touched on this in GitHub discussion #21. I currently have an approach that works well but has plenty of room for improvement. As mentioned, I'm using PCE both as an editor provider and for static (readonly) code blocks. I'll describe my current setup to provide context if you decide to explore this further. In my case, when using PCE for highlighting in a Node environment, I pass it code output from a tool like markdown-it. I perform syntax highlighting using the available It's important to note that in some cases, I don't want to include PCE in my browser bundle, as I only need it for highlighting (via Prism). However, I still like to have some features, like line numbers. To achieve this, I augment the returned const tokenize = tokenizeText('...', language);
const rawCode = highlightTokens(tokenize);
// Insert line numbers
const lineNumbers = rawCode
.split('\n')
.map((token, i) => `<div class="line-no" aria-hidden="true" data-line="${i + 1}">${token}</div>`)
.join('');While this adds line numbers, if I wanted to use an extension like
The Future of PCEI just want to reiterate my appreciation for what you've accomplished with this project. You've built something impressive, and it's clear how much thought has gone into it. It's been great thus far being able to use PCE in my own projects. That said, while the underlying Prism parsing algorithm is powerful, it does come with inherent limitations. I would advocate and champion for exploring alternative grammar-level approaches to bypass some of the constraints imposed by Prism's parsing strategy. As PCE continues to evolve and new features are introduced, these limitations may become more pronounced, potentially creating performance bottlenecks. I'd be interested to know if you've considered other approaches to tackle these issues or if you're committed to maintaining the current structure, and if you have or are considering a different route on that front, I'd love to help. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I'm planning to begin working on version 4. It won't be a major rewrite, just some small breaking changes. If anyone has suggestions for breaking changes they'd like to see, leave them here.
Beta Was this translation helpful? Give feedback.
All reactions