Custom confluence user macro with multiline body as input

pascal schilp March 29, 2024

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?

1 answer

1 accepted

0 votes
Answer accepted
Kseniia Trushnikova
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2024

Hi @pascal schilp,

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.

pascal schilp March 29, 2024

Here's what the macro looks like:

```

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

## @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

</script>
<style>
highlighted-code-snippet:not(:defined) {
display: none;
}
</style>
<highlighted-code-snippet lang="$paramLanguage" theme="$paramTheme">$body</highlighted-code-snippet>


```

 

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?

Kseniia Trushnikova
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2024

@pascal schilp, try to change Macro Body Processing to Rendered. This option keeps lines and breaks and displays them as they were entered.

pascal schilp March 29, 2024

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

Kseniia Trushnikova
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2024

@pascal schilp, 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

How it looks when a page is published:

Screenshot 2024-03-29 at 19.28.09.png

I'm using Confluence Data center 8.5.7.

pascal schilp March 29, 2024

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

Like Kseniia Trushnikova likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events