-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding syntax highlight element #14425
Comments
The solution is to use a WordPress plugin that does server-side highlighting via PHP instead of client-side highlighting via JS. I don't see there being anything required on the AMP side. See ampproject/amp-wp#972 (comment) |
Not all cases use Wordpress. I'm asking if there is a way to create such an element. |
I wouldn't be opposed to adding this if the highlighting does nothing but add color. |
Anyone can approve me to develop |
As some people mentioned that there are some workarounds, but I was wondering the same idea. |
doing this client-side is borderline against AMP UX principles. I don't think we would develop such extension. SSR is the right, performant approach. |
If that's the case, @aghassemi, can you provide a solution or pointers to such a solution? |
@caraya any syntax highlighting tool that can run server-side would do. Actually Prism.js can do that and they even mention AMP as one of the cases where SSR is needed from: https://prismjs.com/
|
If using PHP on your site, you can use highlight.php: https://github.com/scrivo/highlight.php |
@aghassemi OK. It says it can't be done but not how. I'll keep looking and work trying to figure out how. @westonruter This is not for PHP or WordPress. |
I am using AMP via Wordpress and the wp-amp plugin. I use Prism.js (via plugin) to do syntax highlight. This works in the regular Wordpress render but not when used through AMP.
In amphtml/#2412 @cramforce mentions that this should be done server side. We still need the tool to do so, either in the amp cache or via an element that caches the JS and CSS for the fences.
Using amp-gist (amphtml/#8580) is not an option as some of my posts have 15 or more code examples. The plugin website closed an issue requesting syntax highlighting (amp-wp/#972)
The text was updated successfully, but these errors were encountered: