code formatting

  • Could you add the plugins that allow for source code formatting in WordPress so that languages such as Java will be correctly displayed and formatted?

    thanks

  • Two of the of the most common questions that volunteers on the wordpress.com support forum answer every day are: “How do I edit the wordpress.com template?” “Why does javascript get stripped?”

    The answer is: I’m sorry but you cannot edit your template and you cannot use javascript. It’s important to tell you that although some themes at wordpress.org and wordpress.com may appear to be the same they are not; the software is different.

    At wordpress.com we are on a shared multiuser blogging platform and we are not allowed to alter our templates for security reasons. For the same reason we cannot use javascript, iframes, forms, some media embeds and styles, etc. http://faq.wordpress.com/2006/05/07/javascript-can-i-use-that-on-my-blog/
    This explains is greater detail why javascript is stripped.

    If you do not wish to use one of the themes made available at wordpress.com through your admin section -> Dashboard -> Presentation -> Themes then you have two options. The choice you make may depend on the differences between css customizing a wordpress.com theme or moving to self hosting or a web host and altering a free wordpress.org template.

    (1) The “please read me first before posting” pink sticky at the head of the forum outlines the differences between wordpress.com blogs and wordpress.org blogs which are on different code bases.

    (2) The 15$ you pay to upgrade enables you to to alter the appearance of your theme and but not the underlying php code. Purchasing the upgrade entitles you to customize a cascading style sheet on one blog for one year.

    Specifically the CSS Editor does not let you edit any particular theme stylesheet; rather, it keeps the theme intact and lets you edit a brand new stylesheet. Because your custom CSS is loaded after the theme’s CSS, your style rules can override or add to the existing rules.

    You can use CSS to improve on any existing theme; you can define your own classes for use in posts; you can select the Sandbox theme and build on one of the Minimalist layouts or opt for no stylesheet and do it all yourself. If you decide to upgrade and undertake css customization these two threads may be helpful.

    And as you are new to wordpress.com this thread will be useful to you because it contains links to the basic resources we use here. Happy Blogging!

  • georgesb,

    in case of ‘moving to self hosting’, you’ll, probably, might be interested in something like “Code Markup: a WordPress plugin” or “Highlight.js / WordPress plugin“.

    there’re (rather due than convenient) quick-and-dirty tricks to PREserve a source code text markup (indents) on wp.com:
    * one is to embed a code snippet into the <pre> HTML element;
    * another (slightly more dirtier) is to use a multy-line <textarea> element with a readonly attribute set to “readonly”.

  • Actually I think the top two questions asked around here are teh javascript one and the adsense one. :)

  • I think you guys might’ve misunderstood georgesb. To me, he wasn’t asking how to use Java or JavaScript, but how to make the code display properly, like I’m doing it on my blog

    If I’m correct, then what you, georgesb, need to do when writing a post is to click on the code tab and you should see a [code] button. Use it to display your code the way you want.

    Finally, just a small clarification for those of you who don't know or might get confused with these names, Java and JavaScript are two different things. The former is a programming language, the latter is a scripting language :)

  • Thanks for your answers. What I wanted was to properly display some Java code for some of my high school students. I’ve using a blogger blog where I post a scratchpad of Java ideas we discuss in class. You can see it at http://javascratchpad.blogspot.com
    I was thinking of using WordPress instead but it always seems to strip all the code that comes after the “<” symbol even when I use code tags. I think my best bet might be to self-host a WordPress blog and use one of the plug-ins suggested by “options” above. Again, thanks everyone for your help.`

  • I hate [code]

    Doesn't format the code.
    I have to have everything in 1 block.

    I think devblog uses <pre> tags, and not code tags. And they seem to work better (but still got to format the code yourself)

    I wouldn't mind Code Markup to be added to the list of plugins... But I guess I will have to shift to a hosted setup sometime...

  • in order to post code, in addition to putting everything in <code> or <pre> tags, you’ll need to replace any brackets with their HTML values, &lt; and &gt; respectively.
    i find the easiest way to do this is to just past the code into the rich text editor, and switch over to the code tab to add <code> tags.

  • Regarding the post by devblog above, I’ve found one theme that converts
    code tagged with the pre tag to look the way code looks on:

    http://devblog.wordpress.com/2006/05/25/las-propiedades-textcontent-e-innertext/

    but the code tag doesn’t look like that. The problems are that it only works that way on one theme, on the others it just puts in out there and either gets chopped off short or goes off the right side of the page.

    Also, from what I’ve seen, it seems to be deleting portions of the code.`

  • I would love to see a list of themes that properly support the code tag!

  • The most comprehensize theme review for wordpress.com themes are located here on engtech’s site:

    WordPress.com Theme Reviews

    Not sure offhand if they have what you need but it’s a great resource when these questions pop-up.

  • Anyone else love to see Nerdfusion write up a list of themes that properly support the code tag? :)

    It’s Open Source software. The person who suggests the idea gets to code it. ;)

  • I would be happy to modify an existing theme to properly (in my opinion) support the code tag, if it would then become a publicly available wordpress.com theme.

    And by properly, I mean that it would use a fixed width font, and horizontal scrolling for long lines, instead of wrapping. I’m no designer though, so I don’t want to take on the daunting task of creating an all new theme.

    As far as the write up: I’m mentioning the problem, and my offer to help, here. And yes, I tried them all.

  • @timethief: It would help if you read the question before you did your copy and paste. This is quite a frequent occurence.

  • @root
    I’m not a techy type so when I read the question I assumed the OP’s mention of java meant javascript and that he or she wanted to edit the theme. In fact it wasn’t until devblog chimed in that I understood that I was off track. Also the alleged frequency of misunderstandings occurring on the forum is not your concern. If Staff or Moderators are concerned making corrections is their role.

  • @timethief: The question refers to the formatting of Java. Your answer deals extensively with JavaScript. Different thing entirely. There was no mention of editing the template at all. Nor any requirement to do so. You say you are not a techie. That being so, no answer at all might have been a lot more useful than one which not only confused the OP but also every one else who might have a similar question and was reviewing this thread – having searched – as they are frequently asked to do.

  • Did you need help with something Janette88?

  • Fed up with the restriction of not being able to edit the CSS, and not being able to post an iFrame so that I could accomplish the same goal, I decided to take my blog elsewhere. I then promptly edited the CSS, and if anyone is wondering what proper code support looks like, feel free to check out my CSS [link broken – drmike].

  • You’re running the regular version of wordpress now. There is a difference. You’re the only one putting your blog at risk when you modify files now, not everybody else.

    Looks the same to me actually.

    So when are you going to write up that list of themes that support the code tag? I thought you offered to help.

  • The topic ‘code formatting’ is closed to new replies.