seed-rs / seed-rs.org

Seed's official website
https://seed-rs.org/
Other
14 stars 40 forks source link

Force code blocks reinitialization #46

Closed akhilman closed 4 years ago

akhilman commented 4 years ago

Required for https://github.com/seed-rs/seed/issues/364

MartinKavik commented 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?

akhilman commented 4 years ago

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.

akhilman commented 4 years ago

Or we can drop the github markdown stylesheet and write the style for pre directly in the custom element.

MartinKavik commented 4 years ago

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.

akhilman commented 4 years ago

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 .

MartinKavik commented 4 years ago

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.

akhilman commented 4 years ago

One more option. Use hash form code itself as el_key. https://gist.github.com/akhilman/337cb082fff23f7ab63e23b6eb33b6ed

MartinKavik commented 4 years ago

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?

akhilman commented 4 years ago

Yes. Merge it.