packagist icon indicating copy to clipboard operation
packagist copied to clipboard

Syntax Highlighting in README.md seems not to work properly when coming from Bitbucket

Open Moskito89 opened this issue 1 year ago • 3 comments

I assume that syntax highlighting in a README.md file seems not to work properly when the repository comes from Bitbucket.

Here are to libraries to compare:

In both of them, the PHP code has been written with three backticks, followed by php.

Strangely enough, the HTML of the rendered documents is different:

From GitHub:

<pre><span class="pl-ent">&lt;?php</span>
<span class="pl-k">use</span> <span class="pl-v">Solaris</span>\<span class="pl-v">MoonPhase</span>;
[…]
</pre>

From Bitbucket:

<pre><code class="language-php">&lt;?php
use BitAndBlack\SentenceConstruction;
[…]
</code></pre>

Has anyone an idea what happens here and why?

Moskito89 avatar Apr 29 '24 12:04 Moskito89

Code syntax highlighting currently only works for GitHub repositories. For GitHub repositories, Packagist uses the GitHub API to fetch the rendered HTML of a readme file. For all other repositories a cebe/markdown is used to render the markdown as HTML which doesn't seem to support code syntax highlighting.

glaubinix avatar Apr 29 '24 12:04 glaubinix

Oh, interesting! Thanks for the explanation, @glaubinix! I thought we'd be using something like highlight.js here... What were the reasons against solving this on the front-end side?

Moskito89 avatar Apr 29 '24 12:04 Moskito89

I don't know, but I would assume that the GitHub API call is convenient, covers >95% of installed packages without the need for an additional dependency. So far the lack of code syntax highlighting in other repositories probably just hasn't come up yet.

glaubinix avatar Apr 29 '24 16:04 glaubinix

Yeah it just works and GitHub is almost 99% of packages, so not really worth the hassle to fix IMO. We have so many other things to do.

Seldaek avatar May 20 '24 15:05 Seldaek