Closed akhilman closed 4 years ago
It looks too hacky / error-prone to me. What do you think about alternatives? E.g. use attributes - https://gist.github.com/MartinKavik/713dd5251330e565128b443058d2a5e8?
I'm fine with attributes.
But how about something like this: https://gist.github.com/akhilman/dba0dab68e8c8112ab2d446c7279261b ?
It is reusable, portable, self-contain and plug'n'play.
Or we can drop the github markdown stylesheet and write the style for pre
directly in the custom element.
I suggest to use the simplest code for now - that means only attributes and without shadow DOM. However don't delete that gist, we can reuse it during website redesign.
All right, so I should patch build.rs to put code to attribute.
One more option: pre-render code blocks with https://github.com/trishume/syntect .
I tried syntect before I've migrated syntax highlighting to JS/Web component + build.rs script - it was slow and many languages weren't supported. It should be better now (because syntect core has been migrated to native rust regex crate (if I remember correctly)) but we had discussion about it with a Seed user on chat recently and he also migrated to JS because there were still some problems with that library.
One more option. Use hash form code itself as el_key
.
https://gist.github.com/akhilman/337cb082fff23f7ab63e23b6eb33b6ed
One more option. Use hash form code itself as el_key.
Interesting solution - I'm not sure if I would recommend it as a best practice to users, but it's simple and elegant - I'm ok with it if it works without problems. Can I merge it?
Yes. Merge it.
Required for https://github.com/seed-rs/seed/issues/364