Custom confluence user macro with multiline body as input
Asked by pascal schilp:

Hi! I'm trying to create a custom user macro and I was hoping that, similarly to the code block macro, I would be able to have the user have a multi-line input for the macro where they can input their text, but it seems that using the $body, I can only use one single line. Is there any way to configure that the $body is supposed to have newlines/linebreaks and can be multi-line?


Answers:
author: Kseniia Trushnikova
body: Hi [@pascal schilp](/t5/user/viewprofilepage/user-id/5463048),

Please share with us your macro configuration.

The macro body may be in one line due to the option *Escaped* selected in **Macro Body Processing**.

comments: author: pascal schilp
body: Here's what the macro looks like:  

\`\`\`  
## Macro title: Highlighted code snippet  
## Macro has a body: Y  
##  
## Developed by: redacted  
## Date created: 26March2024

## [@Param](/t5/user/viewprofilepage/user-id/1345631) Language:title=Language\|type=enum\|enumValues=astro,c,c++,css,gql,html,http,java,javascript,json,json5,jsonc,jsx,md,php,python,ruby,sql,svelte,toml,tsx,typescript,wasm,xml,yaml\|required=true\|default=javascript\|desc=Choose the language  
## [@Param](/t5/user/viewprofilepage/user-id/1345631) Theme:title=Theme\|type=enum\|enumValues=andromeeda,aurora-x,ayu-dark,catppuccin-frappe,catppuccin-latte,catppuccin-macchiato,catppuccin-mocha,dark-plus,dracula,dracula-soft,github-dark,github-dark-default,github-dark-dimmed,github-light,github-light-default,houston,light-plus,material-theme,material-theme-darker,material-theme-lighter,material-theme-ocean,material-theme-palenight,min-dark,min-light,monokai,night-owl,nord,one-dark-pro,poimandres,red,rose-pine,rose-pine-dawn,rose-pine-moon,slack-dark,slack-ochin,solarized-dark,solarized-light,synthwave-84,tokyo-night,vesper,vitesse-black,vitesse-dark,vitesse-light\|required=true\|default=nord\|desc=Choose the theme

\<script type="module" src="<https://cdn.ing.com/confluence-macros/1.0.3/es-modules/highlight.js>"\>  
\</script\>  
\<style\>  
highlighted-code-snippet:not(:defined) {  
display: none;  
}  
\</style\>  
\<highlighted-code-snippet lang="$paramLanguage" theme="$paramTheme"\>$body\</highlighted-code-snippet\>

<br />

\`\`\`

\> The macro body may be in one line due to the option *Escaped* selected in **Macro Body Processing**.

Do you mean that using the *Escaped* option only allows one line? And so are you saying that the other options (rendered, unrendered, etc) allow multiple lines?


author: Kseniia Trushnikova
body: [@pascal schilp](/t5/user/viewprofilepage/user-id/5463048), try to change Macro Body Processing to *Rendered*. This option keeps lines and breaks and displays them as they were entered.


author: pascal schilp
body: I believe we tried the *Rendered* body processing option, and it still only allowed a single line I believe, but i'll double check to verify.

In the meantime, could you confirm that using *Rendered* will allow me to enter text with multiline, similarly to the "code block" macro like this?

![PLv7M0b](https://community.atlassian.com/t5/image/serverpage/image-id/315363iA5EBDACE92F71841/image-size/large?v=v2&px=999 "PLv7M0b")


author: Kseniia Trushnikova
body: [@pascal schilp](/t5/user/viewprofilepage/user-id/5463048), I'm not sure about the tag \<highlighted-code-snippet\> you're using, but just adding the macro with "Macro Body Processing" = "Rendered" and the following body works for me:

```
## @param Language:title=Language|type=enum|enumValues=astro,c,c++,css,gql,html,http,java,javascript,json,json5,jsonc,jsx,md,php,python,ruby,sql,svelte,toml,tsx,typescript,wasm,xml,yaml|required=true|default=javascript|desc=Choose the language
## @param Theme:title=Theme|type=enum|enumValues=andromeeda,aurora-x,ayu-dark,catppuccin-frappe,catppuccin-latte,catppuccin-macchiato,catppuccin-mocha,dark-plus,dracula,dracula-soft,github-dark,github-dark-default,github-dark-dimmed,github-light,github-light-default,houston,light-plus,material-theme,material-theme-darker,material-theme-lighter,material-theme-ocean,material-theme-palenight,min-dark,min-light,monokai,night-owl,nord,one-dark-pro,poimandres,red,rose-pine,rose-pine-dawn,rose-pine-moon,slack-dark,slack-ochin,solarized-dark,solarized-light,synthwave-84,tokyo-night,vesper,vitesse-black,vitesse-dark,vitesse-light|required=true|default=nord|desc=Choose the theme

$body
```

How it looks in the editor: ![Screenshot 2024-03-29 at 19.25.24.png](https://community.atlassian.com/t5/image/serverpage/image-id/315372i95D3CD5A614E441C/image-size/large?v=v2&px=999 "Screenshot 2024-03-29 at 19.25.24.png")

How it looks when a page is published:

![Screenshot 2024-03-29 at 19.28.09.png](https://community.atlassian.com/t5/image/serverpage/image-id/315373iEFABD6F70187E7B8/image-dimensions/291x125?v=v2 "Screenshot 2024-03-29 at 19.28.09.png")

I'm using Confluence Data center 8.5.7.


author: pascal schilp
body: Just tried this again, and indeed it's working now ???? Im really confused as to why we were seeing a different input before, but I'm gonna guess I just did something wrong.

Thank you for the help and for verifying! Very happy to have it working now


Tags: confluence-data-center

data-center