Fossil Forum

Feature request: generating highlighted source file view server-side
Login

Feature request: generating highlighted source file view server-side

Feature request: generating highlighted source file view server-side

(1) By gpanders on 2023-09-12 18:26:20 [source]

I know that it's possible to use highlight.js or similar to highlight source file views on the client side. But I'd prefer to minimize Javascript usage on the frontend and generate highlighted code on the server.

Something like highlight can do this, but it requires support from Fossil to use the third party command to first generate the HTML, instead of dumping the source file contents directly.

I implemented a prototype myself, which seems to work ok. It adds a new filecontent-command setting that, when set, pipes the source file contents into the command and uses the command's stdout as the HTML in the source file view.

Is this of interest to the Fossil developers and community? If so, I can share the patch.

Thanks,

Greg

(2) By Stephan Beal (stephan) on 2023-09-12 23:32:13 in reply to 1 [link] [source]

it requires support from Fossil to use the third party command to first generate the HTML, instead of dumping the source file contents directly.

Shelling out an external application from a fossil server (as opposed to CLI mode) is not likely to gain much traction among the developers. It's a security risk, for one thing. The command could do anything the server's user account allows. It would permit, through hacking of an admin's fossil account, setting up ssh access to the server by setting filecontent-command to inject an ssh key into ~/.ssh/authorized_keys2. There's no end to the potential mischief.

The /ext extension enables similar risks but they are largely mitigated by the fact that the scripts themselves have to live on the server, not in editable form in fossil.