Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Force code blocks reinitialization #46

Merged
merged 1 commit into from
May 4, 2020
Merged

Force code blocks reinitialization #46

merged 1 commit into from
May 4, 2020

Conversation

akhilman
Copy link
Member

@akhilman akhilman commented May 4, 2020

Required for seed-rs/seed#364

@MartinKavik
Copy link
Member

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
Copy link
Member Author

akhilman commented May 4, 2020

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
Copy link
Member Author

akhilman commented May 4, 2020

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

@MartinKavik
Copy link
Member

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
Copy link
Member Author

akhilman commented May 4, 2020

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
Copy link
Member

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
Copy link
Member Author

akhilman commented May 4, 2020

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

@MartinKavik
Copy link
Member

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
Copy link
Member Author

akhilman commented May 4, 2020

Yes. Merge it.

@MartinKavik MartinKavik changed the title Use obvserver to update code block Force code blocks reinitialization May 4, 2020
@MartinKavik MartinKavik merged commit ee98550 into seed-rs:master May 4, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants