WordPress.org

Ready to get started?Download WordPress

Forums

Prism Syntax Highlighter (detached)
[resolved] PHP language how to (5 posts)

  1. kriszani
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/prism-detached/

  2. kriszani
    Member
    Posted 1 year ago #

    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?

  3. apfelbox
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. kriszani
    Member
    Posted 1 year ago #

    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.

  5. apfelbox
    Member
    Plugin Author

    Posted 1 year ago #

    I added a short tutorial on how one can add custom extensions:
    https://github.com/apfelbox/Prism-Detached/wiki/Creating-A-Custom-Extension

    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]).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.