Support » Plugin: Prism Syntax Highlighter (detached) » [Plugin: Prism Syntax Highlighter (detached)] PHP language how to

  • Resolved kriszani


    I’ve enabled the PHP language which is great. But I’m doing something wrong with the encoding. my code is showing up as
    <?php so its being encoded at some point, although it looks correct in the wordpress post editor.

    Also. I guess there’s no easy way for us to add other language definitions to the plugin. It would be great if the plugin provided a folder for the prism code that we could sync our selves with the official prism site or add our own definitions to. Just an idea, havent had chance to have a look at the code yet, still trying to get everything working and themed.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ok so I’ve tracked this through a little bit. If i use unescaped PHP code inside PRE tags in wordpress then everything falls apart. I’ve been using the wp-syntax plugin and that allows it – which is why I thought it was ok.

    wp-syntax adds filters that run before and after the_content, the_excerpt and comment_text. The before filters replace all matching code blocks with a randomly generated placeholder and save the code blocks in an array. The after filters put them back.

    This seems pretty like a pretty inefficient solution to me, but your plugin has an advantage in that the code is already separate from the content. So my suggestion would be to run your plugin as a filter on the_content with a late priority rather than register is as an actual shortcode.

    Any thoughts?

    Plugin Author apfelbox


    The “extension framework” was added with v1.3 and makes it fairly simple to add an own extension (= language).

    I will write a description for it and link it here.

    And yes, there are some issues with the PHP extension, although it seems, that they are caused by the PHP extension itself (which is still experimental), since these encoding issues do not occur with other languages.

    Thanks for all these quick responses. Yes I agree with the cause. The result is that it is not simple to switch to this plugin from another syntax highlighter. I’m currently looking at integrating prism into my theme directly that way I know it will work for me 🙂

    But I do really like the detached idea for code, keep up the good work and I’ll keep my eye on this. We need more of a community around prism to work out these bugs and contribute more stuff to the core.

    Plugin Author apfelbox


    I added a short tutorial on how one can add custom extensions:

    But keep in mind, that WordPress will remove all files on making the plugin update using the WordPress Admin Panel (although I plan to provide a possibility to bypass this problem with the next major update [Ticket]).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Prism Syntax Highlighter (detached)] PHP language how to’ is closed to new replies.