Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Use server side rendered code blocks syntax highlighting #94

Open
eduardolundgren opened this issue Dec 8, 2017 · 3 comments
Open

Use server side rendered code blocks syntax highlighting #94

eduardolundgren opened this issue Dec 8, 2017 · 3 comments

Comments

@eduardolundgren
Copy link
Contributor

Currently, Electrics.js code blocks syntax highlighting is done on the client side. For wedeploy.com we've used a naive replace approach that works well to print the already rendered code block. The usage is simple and can be integrated with any templating language.

@eduardolundgren eduardolundgren changed the title Use server side rendered code blocks syntax highlight Use server side rendered code blocks syntax highlighting Dec 8, 2017
@robframpton
Copy link

Makes sense, we've talked about doing this in the past. I think the reason we haven't done it already is dealing with Metal components that provide code snippets, because even if we do it server side, the Metal component will render over it.

Correct if I'm wrong, but it looks like you guys do the highlighting on both the server and client? https://github.com/wedeploy/wedeploy.com/blob/b9fec7c902f4a724d96b8774f5667fb33b4bb1a7/node/magnet/src/pages/index.js#L77

Can you explain how highlightCodeSnippetsFromMarkup and highlightAllCodeElementsInDoc work together?

@eduardolundgren
Copy link
Contributor Author

eduardolundgren commented Dec 8, 2017

Yes. The server-side prints it with the highlighted syntax, Metal.js renders it on the client without the highlighted syntax then the highlightAllCodeElementsInDoc decorates it. Because it happens in the same render tick it's unnoticeable.

@robframpton
Copy link

Cool. That approach should work on Electric as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants