ProfessionalWiki / ExternalContent

MediaWiki extension that allows embedding external content
https://professional.wiki/en/news/external-content
GNU General Public License v2.0
7 stars 4 forks source link

Add option to only show specific lines #39

Closed JeroenDeDauw closed 1 year ago

JeroenDeDauw commented 1 year ago

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, perhaps show=23-42. Consideration: perhaps we also want to have a "highlight specific lines" option in the future, which suggests from=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:

image

malberts commented 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.

myousuffazal commented 1 year ago

Opened an enhancement request at Prism for this.

malberts commented 1 year ago

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.