• Resolved Chris_K

    (@handysolo)


    I apparently am having a blonde moment. Or a bland moment. or something. I want to include some code (html) samples in a post I’m building. using <code> isn’t the trick. nor is block-quote. Isn’t there a way to do this that won’t attempt to render my html?

    Heh – would the “backtick” solution that we use here work? I really don’t want to type a billion gt’s and lt’s if I can avoid it!

Viewing 6 replies - 16 through 21 (of 21 total)
  • SHRIKEE:
    Hmmm. It seems to work find if I’m logged in (<li> will show properly when posting, editing posts, commenting and editing comments). But if I’m not logged in, then <li> codes gets eaten by WordPress (in fact a lot of other tags get eaten, too).

    I suspect it’s the hooks not properly written, but I’m at a loss here how to correct this problem. Probably have to find out exactly what goes on when comments get posted.

    PS: temporary test-bed here:
    https://claes.twbbs.org/insane/wordpress/6
    Comments open to all for now. No need to enter email.

    Surprised, nobody talked about iG:Syntax Hiliter

    if i remember correct its not working very well with tinymce …

    i tried it a while back

    Thread Starter Chris_K

    (@handysolo)

    Lol – wow, one of my old threads!

    I ended up with iG:Syntax Hiliter as well (although CAE was pretty slick too). As I don’t use the tinymce thingy, it works out quite well for me.

    i use code snippet, https://blog.enargi.com/codesnippet/.

    works very well in teh old editor.
    it uses the geshi library.

    Just an update on using backticks. It doesn’t work properly in comments because of the kses filter. All one needs to do is to apply the backtick filter to pre_comment_content. This also means that the translated html entities in the code will be stored in the database (for comments only).

    Using the same code, just hook onto:

    add_filter('the_content','backticker_code_trick',1);
    add_filter('the_excerpt','backticker_code_trick',1);
    add_filter('pre_comment_content','backticker_code_trick',1);
    add_filter('comment_text','backticker_code_trick',1);

    This should make it work properly. For posts, code will be stored in its original form in the database; for comments, code will be translated into html entities, then get stored in the database. (Actually don’t have to hook comment_text, if you’ve never used this on comments before.)

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘I just want to post source code samples in a blog post’ is closed to new replies.