Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to edit code block in issue description text editor using rest api?

Alperen Ozdemir
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 27, 2023

I try to create issues using jira's rest api.

using this: POST /rest/api/3/issue

I'm adding code blocks in issue description area. Using this data scheme: 

```

const bodyData = {
update: {},
fields: {
description: {
type: "doc",
version: 1,
content: [
{
type: "codeBlock",
attrs: {
language: "csharp"
},
content: [
{
type: "text",
text: "source code",
},
],
},
],
},
},
};

```

It's work but i can't syntax highlight and can't edit line numbers for real lines on source document.

Can this be done? and where can i find the documentation about this description field.

1 answer

0 votes
Darryl Lee
Community Champion
January 29, 2023

Hi @Alperen Ozdemir - Welcome to the Community!

I think what you're running into is that the code format in the Description field doesn't seem to allow additional syntax highlighting. At least I could not do this in the UI.

I did find an answer that links to documentation for the {code} macro in Confluence which apparently uses the same renderer as Jira. It includes the ability to select different themes and what might be of use to you, a firstline parameter that might allow you to specify at least the first line of the code snippet. 

Darryl Lee
Community Champion
January 29, 2023

Oof. I just tested. The language and firstline parameters don't seem to do anything. Very odd.

Darryl Lee
Community Champion
January 29, 2023

But yeah, maybe you could try adding an attribute of {firstline: 1234} (maybe "1234"?) to see if that might do something.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events