question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

preserve lang attribute in <pre> codeblocks

See original GitHub issue

On PyPI, fenced code blocks from markdown are translated to HTML as

<pre>
...
</pre>

On GitHub, the HTML preserves the language attribute (if given),

<pre lang="python">
...
</pre>

This helps third-party applications, like my Purple Pi, to do fancy stuff. (In the case of Purple Pi to render LaTeX math.) I’d love to see this on PyPI, too.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
dicommented, Jun 30, 2021

I haven’t taken a look, but if it’s bringing cmarkgfm more inline with what GFM is actually doing, that sounds good to me.

If it changes the styles significantly, we’ll make the necessary changes here (and downstream on PyPI) once we update the pin.

0reactions
nschloecommented, Jul 13, 2022

fair enough - I tried to validate the request that OP had - and confirmed that GitHub’s own rendering doesn’t preserve a lang attribute either.

I tried again and found, contrary to your results, that GitHub does preserve the lang attribute. For example, the README.md

```abc
lorem
```

produces lang="abc".

screenshot

See here for a test repo.

(I might be slow to reply since I’m holidays right now.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Semantics, standards and using the "lang" attribute for source ...
To answer this question, we should look at two things; any potentially relevant specifications, and what is actually done in the real world....
Read more >
Add selected language as a `data-` attribute in rendered code ...
It looks fine on a static block but I'm playing with scrolling the code block at fixed height, so it disappears on scroll...
Read more >
1 Code::Blocks Project Management
In Code::Blocks, multiple projects can be open. By saving open projects via 'File' →'Save workspace' you can collect them in a single workspace...
Read more >
codeblock - OASIS Open
The element represents lines of program code. Like the element, content of this element has preserved line endings and is output in a...
Read more >
Code blocks - APIdocs documentation - GitHub Pages
To mark a block-level code fragment for highlighting, use the pre tag with the data-language attribute defining the language of the contents. See...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found