• 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 15 replies - 1 through 15 (of 21 total)
  • &lt; = <
    &gt; = >

    Replace the characters on the right above in your sample HTML with the character entity codes on the left, and no “rendering” will occur.

    Thread Starter Chris_K

    (@handysolo)

    drat. That hits my last sentence pretty hard!

    I really don’t want to type a billion gt’s and lt’s if I can avoid it!

    Guess I’ll pull it into vi first and do some global search and replace lovin’

    Thread Starter Chris_K

    (@handysolo)

    Oh hell, and replace every leading space with a nbsp; too? Dang.. there has GOT to be a better way to not lose all formatting.

    Where’s my html books?

    Edit: Bah, Kafkaesqui is a faster typer. ??

    There is a better way.

    https://codex.www.ads-software.com/Plugins/Posts_Formatting

    I use Code Auto Escape personally. There are also ones that will apply syntax highlighting (colors) to your code.

    But CAE is a little cooler then my suggestion. :)

    Thread Starter Chris_K

    (@handysolo)

    Sweet! Thanks guys, I’ll give those a shot.

    Thread Starter Chris_K

    (@handysolo)

    Hmm, anyone seen one of these critters that’s 2.0 friendly? I’ll try some tonight, but with tinyMCE in the mix… I’m not overly hopeful.

    tinymce keeps raping the snippets i insert. is there a plugin to make this work better?

    i need to be able to insert php/css/html snippets

    i need to be able to insert php/css/html snippets

    Then disable the wysiwyg. If you know code why would you need that idiotic tinymce that causes zillion times more problems than it solves?

    I was just wondering about this the other day, what to use or do, to be able to post “html codes” and stuff in the posts.

    I basically was trying what Handy said in the first post, but gave up on it at the time, because I had alot more to worry about getting done. Oh well..I’ll try those two plugins or just turn off the tinymce, like Moshu said above here lol.. =)

    spencerp

    I guess I was just hoping to do it, without turning off the tinymce, but..oh well lol!! God damn things… =P

    Well, if anyone’s interested, I sneaked into my copy of bbPress and stole their code for using the backtick, then dumped it into a quick plugin. I’ve tested it to work with my WordPress 2.0.2.

    Here’s the working code:
    backtick-code.phps

    Just activate this and you can write code as you would here on this forum (well they’re basically the same code). It doesn’t touch your database at all, just filters post excerpts, contents, comments and it seems that it does RSS feeds as well.

    I’ve only made two modifications:

    1) Rather not so elegant (I think) solution to replace leading spaces with &nbsp; (for indentation). Also I just converted tabs into four &nbsp;—sometimes I copy and paste code that indent using tabs, so I wanted those to work as well.

    2) Within backtick code blocks, two backticks in a row will be converted back to one backtick when it is displayed. (Downside is you need to type four backtickes in a row, if you want to display a literal backtick while not inside a backtick code block.)

    I like using backticks just because I’m lazy and don’t want to type a million CODE tags…although I do feel that the CAE plugin using the code tags is a “better” solution. After all, once you get settled into using backticks, these backticks will get stored into your database…

    BTW: reminders on mistakes I made or on how to improve this would be greatly appreciated. I’m just a PHP beginner.

    PS: I do not know if this works with the WYSIWIG editor. I’ve grown to hate that thing. ??

    Terry

    (@wherewillyoube)

    Maybe this suggestion is quite stupid, but this may help a little before you install the plugings.

    Try typing the code into Microsoft Word and then replace all “<” with “<” and replace all “>” with “>”. And then paste everything back into your wordpress editing area.

    Sorry if I sidetracked a lot into Microsoft Office. Just a suggestion.

    Thanks for that alrescha. =) I’ll give it a try on the localhost blog once….see what happens. ??

    spencerp

    yea i tried replacing the < and >. it doesnt exactly get me excited when i post code with loads of tags.

    I also tried the autoescape (and most others i could find) plugin which works nicely, when tinymce is turned off.
    alrescha: your plugin doesnt work if the posted html includes the < li> tag

    i even tried to patch tinymce to make a ‘original’ plugin (insertcode, using geshi) work but then wp comes in between and makes a mess of it (codewise that is)

    i think im running out of options and stick with the old editor and a highlight plugin for now ??

    thanks anyway for the quick replies!

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