pythondotorg icon indicating copy to clipboard operation
pythondotorg copied to clipboard

feat(frontend): Improve highlighting of code samples

Open JacobCoffee opened this issue 1 year ago • 3 comments

What

  • Rebased on the latest main from #1517

Add highlighting for the prompt marker in the code samples.

Refactor the html formatting so that the html tags are automatically generated and don't have to be written manually in the code samples sources.

JacobCoffee avatar Sep 12 '24 21:09 JacobCoffee

From original PR:

format_html() is actually a poor man's pygments, but I did not want to introduce this dependency. However, switching to pygments would be straight forward, if one wants to have full-fledged highlighting at some point in the future.

Not sure whether it was not the case at the time of the original PR or whether I just didn't know, but sphinx depends on pygments, so it's available in your doc build environment and you could use that instead of this manual approach.

timhoffm avatar Sep 12 '24 22:09 timhoffm

@timhoffm I'm not sure that we install docs deps where this is used, but I can check tomorrow. pygments is okay with me if it cleans up some cruft

JacobCoffee avatar Sep 12 '24 23:09 JacobCoffee

I would lean towards using pygments.

ewdurbin avatar Sep 16 '24 13:09 ewdurbin