Closed JeroenDeDauw closed 1 year ago
I am not aware of an existing PrismJS plugin that does something like this. One thing to consider is whether we strip the lines on the backend, which means the excluded lines will not be included when fetching page content (directly or via API), or whether this is fully handled on the frontend, which means the full code is always available. Having those expand buttons would suggest handling everything on the frontend.
"highlight specific lines" option
There is a plugin for line highlighting: https://prismjs.com/plugins/line-highlight/
On a sidenote: That uses a line
parameter, whereas my initial choice to use line
to enable line numbers was based on the SyntaxHighlight extension parameter. So that original parameter might still need to change.
Opened an enhancement request at Prism for this.
While it would be nice if there was an upstream plugin to handle this use case, I'm not sure if anyone over there will be working on it any time soon. From my understanding PrismJS v1 is stable and feature complete and development is focused on v2.
When embedding code blocks, allow specifying
from line 23 to line 42
. Other lines should not be shown.TBD: how is the info specified? Perhaps
from=23|to=42
, perhapsshow=23-42
. Consideration: perhaps we also want to have a "highlight specific lines" option in the future, which suggestsfrom=23|to=42
isn't great.Nice to have: other lines can be shown by clicking something like "show previous" or "show next", perhaps similar to what GitHub has in diffs: