32

Jira (hosted version) does not seem to support Markdown without a plugin. How can I paste and format a code block in a Jira issue comment or description?

1
  • Definitely a correct answer was given Nov 3, 2015 at 17:23

2 Answers 2

37

The Atlassian JIRA {code} macro is covered in section Advanced Formatting within the Text Formatting Notation Help:

Makes a preformatted block of code with syntax highlighting. All the optional parameters of {panel} macro are valid for {code} too. The default language is Java but you can specify others too, including ActionScript, Ada, AppleScript, bash, C, C#, C++, CSS, Erlang, Go, Groovy, Haskell, HTML, JavaScript, JSON, Lua, Nyan, Objc, Perl, PHP, Python, R, Ruby, Scala, SQL, Swift, VisualBasic, XML and YAML.

Example:

{code:title=Bar.java|borderStyle=solid}
// Some comments here
public String getFoo()
{
    return foo;
}
{code}

{code:xml}
    <test>
      <another tag="attribute"/>
    </test>
{code}
5
  • 1
    The problem with this documentation is that it doesn't tell you how to specify something other than Java (say SQL, for example).
    – bcr
    Dec 16, 2016 at 22:14
  • 8
    {code:<language>} such as {code:sql} for sql
    – relipse
    Jan 5, 2017 at 15:14
  • 2
    The Advanced Formatting section has been updated to include all possible language types: The default language is Java but you can specify others too, including ActionScript, Ada, AppleScript, bash, C, C#, C++, CSS, Erlang, Go, Groovy, Haskell, HTML, JavaScript, JSON, Lua, Nyan, Objc, Perl, PHP, Python, R, Ruby, Scala, SQL, Swift, VisualBasic, XML and YAML. Feb 7, 2019 at 17:25
  • 2
    They document “Java” → java, but “Plain Text” → what? plain text, plaintext, plain-text, etc.?
    – ændrük
    May 24, 2021 at 17:20
  • 1
    Just use {code:none} if you don't want any syntax highlight (or {noformat})
    – VRoxa
    Dec 15, 2021 at 18:26
2

By default it uses the Default Text Renderer on the Description field. You may need to edit your field configuration(s) (as admin) to use the Wiki Style Renderer

Not the answer you're looking for? Browse other questions tagged or ask your own question.