pietroppeter / nimib

nimib 🐳 - nim 👑 driven ⛵ publishing ✍
https://pietroppeter.github.io/nimib/
MIT License
177 stars 10 forks source link

support for highlighting other languages #68

Closed pietroppeter closed 1 year ago

pietroppeter commented 2 years ago

with incoming PR #64 we will start to see more languages in nimib.

we should make again easily available the use of highlight.js in documents which contain other languages (initially nimib did nim language highlighting through highlight.js, then thanks to #15, it passed to do it statically).

this would also ease the support of nim highlighting in pure markdown pages (such as those used in nimibook, see examples there) which is not available statically (it would require patching markdown generator or postprocess the html)

implementation should be rather straightforward. among (minor) steps to be understood how to do:

HugoGranstrom commented 1 year ago

Is the idea that https://github.com/pietroppeter/nimibook/issues/64 should use this same feature as nimib or how do we want to do it? Judging from this:

add it to assets

it seems like we will add it as an asset in nimibook, but we do not have any assets in ordinary nimib. So we will have to do it in two different ways in the two libraries. For reference, nimiSlides does it in its own way by using Reveal.js's wrapper around highlight.js, so it is reasonable that different libraries could do it their own way. So I see two options:

  1. Do it differently for nimib and nimiBook.
  2. Host our own highlight.js file, e.g. https://cdn.jsdelivr.net/gh/pietroppeter/nimib/assets/highlight.nim.js that we can decide ourselves which languages should be supported, and it can be implemented the same way in both nimib and nimiBook.

Thinking about it, we would have to do 2. for nimib either way if we don't want to have to copy around highlight.js everywhere. So my vote is for hosting ourselves on jsdelivr.com for both of them.

Your thoughts @pietroppeter?

HugoGranstrom commented 1 year ago

Reading it again, I think I understand that you referred to nimib's assets folder... :facepalm:

pietroppeter commented 1 year ago

Yep, nimib assets folder. Also, GitHub has a cdn for everything in a repo (not sure how good).

It was actually how highlighting was done before Yard implemented the static highlighting, there should be commits in the history with highlighting done with highlight.js

Not sure if you have outstanding questions :)

HugoGranstrom commented 1 year ago

Yep, nimib assets folder.

:+1:

Also, GitHub has a cdn for everything in a repo (not sure how good).

Couldn't find anything by googling on this, or do you mean the "raw" links like https://raw.githubusercontent.com/pietroppeter/nimib/main/assets/androidstudio.css ?

It was actually how highlighting was done before Yard implemented the static highlighting, there should be commits in the history with highlighting done with highlight.js

Yeah, saw the linked PR that removed it, so should just have to revert some parts of it :)

pietroppeter commented 1 year ago

Ah it was actually jsdeliver that can give you a cdn starting from any GitHub repo, see assets.nim in https://github.com/pietroppeter/nimib/pull/15/files and this for reference: https://gomakethings.com/how-to-turn-any-github-repo-into-a-cdn/