Forums

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

Is there a way to create code blocks in markdown?

Denis Trapeznikov July 11, 2023

I have an md file that I'm trying to post to Confluence using the Markup macro. It contains several code blocks. When pasting the contents into the input field in Markup dialog, those blocks turn into plain mono preformatted paragraphs. I tried to change the ``` that start code blocks into inline HTML, e.g. <ac:structured-macro ac:name="code" ac:schema-version="1"> etc., but Markup fails to parse it as inline HTML and just inserts in the text literally. I don't regard changing every such piece of the doc into a Code Block macro as a plausible option (and even less do I regard doing it again, when the source md file changes) but is there a way to automate it? Thanks.

2 answers

1 accepted

2 votes
Answer accepted
Denis Trapeznikov July 11, 2023

Ok, after some automated text processing and slightly-less-automated brace and sqr. bracket escaping I was able to convert the initial md into Conflu wiki format where macros can be typed, perhaps will keep it as such.

0 votes
Sayed Bares _ServiceRocket_
Community Champion
July 11, 2023

@Denis Trapeznikov Welcome to the community!

You can use the following syntax for the markup macro:

{code:title=This is my title|theme=FadeToGrey|linenumbers=true|language=java|firstline=0001|collapse=true}
This is my code
{code}

Hope it helps!

Denis Trapeznikov July 11, 2023

Thank you, this is something called "Confluence markup syntax", and Conflu seems to ignore it when pasted into the Markdown input.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events