GeSHi WordPress Sample with Javascript

The WP-Syntax plugin allows easy insertion of code in blog posts, using GeSHi (Generic Syntax Highlighter). It supposedly supports over one hundred programming languages, including including PHP, HTML, CSS, Java, C, Lisp, XML, Perl, Python, and assembly.

For example:

1
2
   <pre lang="html" line="1" escaped="true">
   </pre>

The line=”1″ directive tells WP-Syntax to insert line numbers. For this example, to nest xml inside xml, set escaped=”true”, and use html entities.

Here is another example, this time using “javascript” for the selected language. In this case, the code is indented. WP-Syntax converts real spaces into HTML space entities, which allows you to intend code.

1
2
3
4
5
<script type="text/javascript">// <![CDATA[
    document.write("<h1>This is a heading</h1>");
    document.write("This is a paragraph.");
    document.write("This is another paragraph.");
// ]]></script>

Interested in JavaScript? I send out weekly, personalized emails with articles and conference talks. Click here to see an example and subscribe.

3 replies
    • Anuar
      Anuar says:

      Hello,Just wondering if anoyne could help. I did something stupid and started my blog using a numerical archive system, and now I’d like to change it so that the post title is part of the URL for SEO reasons. Is there any WordPress plugins that anoyne knows of that could switch it without sending Googlers to invalid pages? Maybe some sort of redirector to the correct page?Thanks.

      Reply
  1. Mirella
    Mirella says:

    After installing php5-gd and rarsetting Apache2, I still got the same error messages. Looking thru the error logs I noticed: failed to open stream: Permission denied in /var/www/wp-admin/includes/file.php on line 348 . Line 347-8 has: $new_file = $uploads[‘path’] . /$filename copy( $tmp_file, $new_file );Ahh, more file permissions, this time on the uploads dir. Once I gave the Apache process recursive write perms to wp-content/uploads and restarted, all was good.Thanks for the tips!

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *