Skip to content

Consider server-side highlighting #1

@westonruter

Description

@westonruter

I propose that the code block be highlighted on the frontend via server-side logic (as a dynamic block) instead of client-side logic (via enqueueing Prism.js). A couple key benefits are that this improves frontend performance and the syntax highlighting will be seen even when JS is disabled or when the content is served in AMP plugin. What's more, the Highlight.php library includes support for auto-detection of the language, so it would not be necessary to select the language and any existing code blocks could have syntax highlighting automatically added to them.

I've implemented server-side highlighting for a similar block in mkaz/code-syntax-block#13

It is also done in an extension for the SyntaxHighlighter plugin: https://github.com/xwp/syntaxhighlighter-amplified

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions