Confluence User Macro to justify text

Nico n April 18, 2018

Hello,

I would like to write a user macro very simple in order to justify text. How I can do ?

thanks in advance

2 answers

1 accepted

2 votes
Answer accepted
Alana Fernando
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

hi @Nico n,

Try below code and let me know whether this helps ☺️ 

## Developed by: Alana Fernando
## Date created: 19/04/2018
##Shared with love...



<div>
<p class="txtAlgn">
$ {body}
</p>
</div>

<style>

.txtAlgn{
text-align :justify;
}

</style>

Select Rendered as macro body processing. 

Alana Fernando
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

Here is a much more improved version of above code.

## @param alignment:title=Text alignment|type=enum|desc=Choose Text alignment.|enumValues=Right,Left,Center,Justify

#if ($paramalignment == "Right")

<style>
.txtAlgn{
text-align :right;
}
</style>

#elseif ($paramalignment == "Left")
<style>
.txtAlgn{
text-align :left;
}
</style>

#elseif ($paramalignment == "Center")
<style>
.txtAlgn{
text-align :center;
}
</style>

#elseif ($paramalignment == "Justify")
<style>
.txtAlgn{
text-align :justify;
}
</style>

#end

<div>
<p class="txtAlgn">
$body
</p>
</div>

Nico n April 19, 2018

Many thanks Alana, very useful! :)

I have tried both with some text. They partially works, so that if I write only a paragraph then it is correctly justified, otherwise if I write two or more paragraphs, then it doesn't justify text anymore.

For example see: 

https://doc.helab.nuvolaitaliana.it/display/AEE/prova+condivisione+2

Anyway this macro is very useful and I appreciated a lot. Thanks :)

Alana Fernando
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2018

@Nico n try below change in above code. it should surely solve this issue. 

<div class= "txtAlgn">
<p>
$body
</p>
</div>
Marina Kovacevic June 13, 2022

Where should we add this code?

0 votes
Meg Holbrook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

Hi Nico,

Adaptavist has created a server-version app that has this macro included:

Content Formatting Macros

If you're trying to do this on Cloud, I don't think it's possible. 

Nico n April 18, 2018

Thank you Meg, I know about this plugin but it is not free. I need to write a user macro (very simple) only to justify text.

thank you anyway

Meg Holbrook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

I've found only that you can do this with the HTML macro utilizing justify code. 

Obviously it's possible since Adaptavist has figured it out, but I'm not able to assist with that. 

Nico n April 19, 2018

thanks anyway :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events