composer / packagist

Package Repository Website - try https://packagist.com if you need your own -

Home Page:https://packagist.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Moskito89 opened this issue · 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?

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.

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?

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.

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.