News for hackers. Stuff that matters.
Re:Show HN: Pure CSS/HTML C# syntax highlighting without Jav... by hunterb123 on Monday January 17, 2022 @12:11PM (#29968769)
See also: Chroma (https://github.com/alecthomas/chroma) based on Pygments (https://pygments.org).

JS libs like Highlight.js and Prisma.js can be ran server side and then you send the HTML/CSS like normal.

Generally you'd want to pre-render blogs so syntax highlighting should be compiled HTML/CSS during the build process.

CF workers and other edge computing work great if you have dynamic content if you don't want the client to use JS.

For non-readonly, Monaco and Codemirror are available but heavier ofc.

Anyone else know of another perf syntax highlighting lib? I like collecting tech.

Re:Show HN: Pure CSS/HTML C# syntax highlighting without Jav... by john-doe on Monday January 17, 2022 @12:19PM (#29968888)
See also: Shiki https://shiki.matsu.io/
Re:Show HN: Pure CSS/HTML C# syntax highlighting without Jav... by eyelidlessness on Monday January 17, 2022 @12:58PM (#29969360)
I was also gonna mention Shiki. While it is JS, you can SSR/SSG, and:

- it uses VSCode grammars and themes, which is awesome.

- it’s got some really cool extensions like Shiki Twoslash[1], allowing VSCode-like type hovers and type error demos. I’ve heard this can work without client-side JS but haven’t had the opportunity to check that out just yet.

- with some effort, you can extract the inline styles to a stylesheet and support pure CSS dark mode (note to self: clean up and open source my implementation of this).

1: https://shikijs.github.io/twoslash/

Re:Show HN: Pure CSS/HTML C# syntax highlighting without Jav... by john-doe on Tuesday January 18, 2022 @05:31AM (#29977280)
> (note to self: clean up and open source my implementation of this)

Please do!

Re:Show HN: Pure CSS/HTML C# syntax highlighting without Jav... by eyelidlessness on Tuesday January 18, 2022 @12:29PM (#29982524)
I’ll try to get that out this weekend, now that I know there’s interest!
Re:Show HN: Pure CSS/HTML C# syntax highlighting without Jav... by hunterb123 on Monday January 17, 2022 @12:24PM (#29968950)
Ooo nice one. Cool features I noticed:

- VSCode theme support

- Textmate grammar tokenizing

- Multiple targets (SVG/PDF)

- Annotations