Pygments Code Macro

Name Pygments Code Macro
Version 0.1.4
Product Versions Confluence >= 2.3
Author(s) Philip Jenvey
Homepage http://confluence.atlassian.com/display/CODEGEIST/Pygments+Code+Macro
Price Free
License BSD
JavaDocs n/a
IssueTracking  
Download JAR pygments-macro-plugin-0.1.4.jar
Download Source pygments-macro-plugin-src-0.1.4.tar.gz

Description/Features

Replacement {code} macro plugin, using the Python Pygments library via Jython.

Supports many more languages than the default Confluence {code} macro, such as Python, Ruby, C#, PHP, JSP, shell, apache conf files and more.

Usage

Before using the Pygments Code Macro plugin, disable the default Confluence code macro plugin.

{code:<language>}

Where <language> is one of those listed here (case insensitive): http://pygments.org/languages/

All the optional parameters of {panel} macro are valid for {code} too. Specify the parameter 'linenos=false' to disable line numbering.

Examples

Version History

Screenshots

Labels

codegeist_2007_confluence codegeist_2007_confluence Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 17, 2007

    Bryan Ewert says:

    Unfortunately, this macro doesn't preserve syntax compatibility with the builtin...

    Unfortunately, this macro doesn't preserve syntax compatibility with the built-in {code} macro.

    For example, try the following with Pygments 0.1.4 installed:

    In the following example, specifying the "none" keyword as the language option causes a plug-in error to be generated in the rendered text:

    ' Specifing "none" as language results in a plug-in error.
    lineprint ''Generic code which does not benefit from syntax highlighting'' . end

    In the following example, text specified within '<' and '>' braces will not render if the text is not a recognized HTML tag, or will be highlighting if it is an HTML tag:

    // "arg1" and "arg2" fail to print.
    command <arg1> <arg2>;
    
    // Tags are highlighted, even though no language is specified.
    <i>foo</i> <em>bar</em>
    
    // Workaround is to buffer the text with spaces:
    command < arg1 > < arg2 >;
    1. Aug 26, 2007

      Philip Jenvey says:

      I wasn't aware code:none did anything (didn't see it in the docs). I can alias n...

      I wasn't aware code:none did anything (didn't see it in the docs). I can alias none to 'text', which highlights nothing.

      Specifying no language has pygments try to guess the language, that's why you would see the tags highlighted when using just a plain code tag (it guesses the code is HTML). I need to update the docs

      What language were you using when arg1/arg2 failed to print? I tried java and couldn't reproduce it.

      Also there is a Jython concurrency issue with the 0.1.4 version – if you see any odd exceptions, highlighting all of a sudden not working when it did before, that might be the cause. I will update with 0.1.5 or 0.1.6 soon, with this issue solved.

      1. Jun 10

        Greg Miller says:

        Hi Philip do you have any suggestions on how to incorporate a new lexer into Pyg...

        Hi Philip - do you have any suggestions on how to incorporate a new lexer into Pygments? We would like to customize this plugin to add more functionality - any help you can provide on how to do this would be very appreciated.

        Thanks,

        -Greg

  2. Nov 26, 2007

    Daniel Heise says:

    Hi, i installed the plugin and it works fine! But if I show the linenumbers I h...

    Hi,

    i installed the plugin and it works fine! But if I show the linenumbers I have the following problem: the line spacing between the linenumbers and the code are different.

    Here is a screenshot:

    Is this a problem with our theme?

    1. Jun 04

      Greg Miller says:

      I also had an issue with the line numbers not being correct. I simply used the "...

      I also had an issue with the line numbers not being correct. I simply used the "linenos=false" syntax to disable line numbers. The line numbers aren't really needed for me.

      Here's an example:

      {code:Perl|linenos=false}

       -Greg

  3. Nov 27, 2007

    Mika Zeng says:

    Hi, Why we&nbsp;cannot install this plugin via confluence plugin repository? I g...

    Hi,

    Why we cannot install this plugin via confluence plugin repository? I got download error.(file name, directory name or volume label syntax is incorrect) We use confluence ver. 2.5.7

  4. Dec 03, 2007

    Serge van den Oever says:

    I really have trouble with this plugin. After save code with tags between brack...

    I really have trouble with this plugin.

    After save code with tags between brackets displays ok (), after edit again, all tags are removed. Even if code:XML is used.

    <root>
      <node>test</node>
    </root>

    results after an aditional edit into just the text "test".

    Even in this comment, I edited it again and all XML tags where removed again. I added them again. Try it out in a comment. Type over above XML in {code:XML}..{code} nodes...

  5. Jan 25

    Brian Sanders says:

    I installed this thru the plugin repo and it does not work for me. The descripti...

    I installed this thru the plugin repo and it does not work for me. The description doesn't even render properly. The error is:
    Error formatting macro: code: Traceback (innermost last): File "<string>", line 1, in ? ImportError: no module named pygments

    I cannot find anything about this error.

    1. Jun 02

      Pierre Sarciaux says:

      Hi Brian,\\ &nbsp;&nbsp;&nbsp;&nbsp; I've the same problem. Have you solved your...

      Hi Brian,

           I've the same problem. Have you solved your problem. I'm using confluence 2.8.0. I've simply install the plugin on the plugin page admin. Even in this page, it doesn't recognize the macro code. Is there any depend plugin to install before ?

           Can someone help ?

          Thanks.

      1. Jun 04

        Greg Miller says:

        Hi Pierre &nbsp;I've installed the plugin with Confluence 2.8.1 and it seems to...

        Hi Pierre -

         I've installed the plugin with Confluence 2.8.1 and it seems to be working fine. Did you disable the default "code" plugin? You should use the new pygment plugin in its place.

        -Greg

        1. Jul 01

          martin says:

          also not working for us. (although deavticated confluence code macro) Error Mes...

          also not working for us. (although deavticated confluence code macro)

          Error Message

          Error formatting macro: code: Traceback (innermost last): File "<string>", line 1, in ? ImportError: no module named pygments
          macro plugin, using the Python Pygments library via Jython.
          Supports many more languages than the default Confluence 
          

          Using

          • Confluence 2.5.8
          • Tomcat 5.5.x
          • MySql 5

          Any idea why ?
          Thanks
          Martin

          1. Jul 12

            David Hergert says:

            We are experiencing the same issues.&nbsp; Conluence 2.8.0, standalone, Oracle 1...

            We are experiencing the same issues.  Conluence 2.8.0, standalone, Oracle 10g.  Any help?