ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Displaying code in entries

June 04, 2008 12:39pm

Subscribe [2]
  • #1 / Jun 04, 2008 12:39pm

    Jamie Pittock

    108 posts

    Afternoon all -

    Displaying EE code in entries has always, for me anyway, caused issues.  I don’t want to highlight code, I just want to display it without it being parsed, without it showing entities instead of brackets, and without it adding HTML formatting that I don’t want.

    Looking in the EE blog they use the built in [ code ] highlighter but that seems to leave ugly empty paragraph tags before and after the codeblock.

    If I just use an HTML code tag with my code inline like this:

    This is some code <code>{embed="globals/_start"}
    inline.</code>

    I get this:

    This is some code &# 123;embed=“globals/_start”&# 125; inline. (spaces added so we don’t all fall into an infinity loop).

    Then I add a < pre > tag to really start confusing matters

    <pre>
    <code>
    {cf_features_body}
    <div id="red">
    hello
    </div>
    {embed="globals/_start"}
    

    </code></pre>

    This ends up as:

    {cf_features_body}
    <div id="red">
    hello
    </div>
    &# 123;embed="globals/start"&# 125;

    Why are the curly brackets in the embed being encoded but not the ones in the custom variable?  Some EE security?

    The fun really starts if any of the code has a line space in it.  This:

    <pre>
    <code>
    {embed="globals/start"}
    {cf_features_body}
    
    <div id="red">
    hello
    </div>
    

    </code></pre>

    Becomes this:

    {embed=“globals/start”}
    
    {cf_features_body}
    
        
    
    
    hello

    Notice the embed brackets now display fine but the HTML div now actually used instead of just displayed.

    I’m using Textile which may be confusing things by encoding what EE has already encoded but I promise you similar oddities are accuring when I just use the XHTML formatting.

    Either way I’m slowly losing my mind over what should be a (fairly) simple task. 

    Anyone able to offer a solution?  Or a large drink?

    BTW, I’ve looked at the Geshi and code highlighter extensions and both seem to add more problems than solutions.

  • #2 / Jun 05, 2008 6:05pm

    John Henry Donovan

    12339 posts

    I use the markdown extra plugin (which allows you to encode those curlys) and the geshi extension which seems to work for me. I set the Geshi plugin to render as an ordered list and styled it as necessary. I know I had the same trouble and tore my hair out in stages but as far as I know this did the trick

  • #3 / Jun 06, 2008 5:32am

    Jamie Pittock

    108 posts

    Hello mate - thanks for the tip.  I’ve tried it and I’m still getting some odd results.  The output now looks like this:

    {cf_features_body}
    &# 123;embed="globals/_start"&# 125;
    <div id="red">
    hello
    </div>

    So it’s still encoding the embed’s curly quotes twice.

    The actual HTML outputed is still pretty fugly too:

    </pre>
    
    The list is still wrapped in a paragraph tag for one.
    
    I’ve just had a quick nosey at your site and indeed the code displayed in your entries is lovely.  I don’t suppose you’d send over the plugin/extension files you’re using would you?  Just so I can check whether you’re using different versions etc.
    
    My EE username at gmail.com
    									
  • #4 / Jun 06, 2008 5:34am

    John Henry Donovan

    12339 posts

    Will do. At work at the moment but will send over the details this evening.

  • #5 / Jun 06, 2008 6:19am

    Jamie Pittock

    108 posts

    Thanks very much!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases