ecency / render-helper

Render helper for Ecency social apps, markdown2html and markdown2amp. Package name @ecency/render-helper
https://ecency.com
MIT License
3 stars 10 forks source link

Add highlight.js integration for Remarkable #19

Closed tipyy closed 3 years ago

feruzm commented 3 years ago

@tipyy Thank you for your contribution. This is something we discussed with team while back, code highlight is good feature to have and we want to add that into render-helper.

But highlight.js adds more than 200kb size into package bundle which means it is extra 200kb on every website that use it.

What do you think if we try lolight package or something that's smaller? 1.6 kb https://bundlephobia.com/result?p=lolight@1.4.0

feruzm commented 3 years ago

Another idea we thought would be great to add support for embedding github gists, that way every format could be supported. What do you think?

tipyy commented 3 years ago

You're totally right @feruzm ! I'll check the package you are talking about and I'll see what I can do during the week.

I would also love to have gist integration but it seems to be more work, let's postponed that for another pull request :)

tipyy commented 3 years ago

I made the switch to lolight.

The rendering is not as great as the one from highlight.js but it works and yeah it's way more tiny.

I had to use a little hack tho. The library does not really supports string directly so my implementation hardcodes the CLS_PREFIX constant.

The good point is that we don't need the pull request on ecency-vision anymore

feruzm commented 3 years ago

@tipyy great, looks good to me 👍 thank you. Is there any chance you can share screenshot of how it looks and also add simple tests for this in markdown-2-html.spec.ts ?

tipyy commented 3 years ago

No problem, I added a unit test. I used the SNAPSHOT_JSON object to match the file style, but I prefer jest snapshots. But I know this is not something everyone agrees with.

Here is a snapshot of how it looks right now

Screenshot 2021-08-18 at 13 34 34

It does not recognized as much tokens (ruby symbols are not recognized for example) but I guess that's ok for now. And we still can make pull requests, I looked at the code and it should be pretty easy to extend.

feruzm commented 3 years ago

@tipyy it is live on ecency.com now 👍