Confluence Editor Automatically Adds Line Break Before or After a Macro

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When you have a macro in a Confluence page, for example looks like this:

when you edit the page, there will be a linebreak automatically inserted before or/and after the macro, like this:

Diagnosis


Install Confluence Source Editor plugin and edit the source (storage format) of the page. For the above example, it should look like this:

(info) Please note that the Source Editor plugin is a non supported  app.

<p>hello 123</p>
<div>
  <p> </p>
  <ac:macro ac:name="note">
    <ac:rich-text-body>
      <p>This is a note macro</p>
    </ac:rich-text-body>
  </ac:macro>
  <p> </p>
</div>
<p>The following is an image:</p>

Note that there is new <p> tag added automatically at the beginning and the end of the note macro. This is how the storage format look like before editing the page:

<p>hello 123</p>
<div>
  <ac:macro ac:name="note">
    <ac:rich-text-body>
      <p>This is a note macro</p>
    </ac:rich-text-body>
  </ac:macro>
</div>
<p>The following is an image:</p>

 Note that there is <div> tag wrapping the "note" macro. By right, the default storage format for such content should look like this:

<p>hello 123</p>
  <ac:macro ac:name="note">
    <ac:rich-text-body>
      <p>This is a note macro</p>
    </ac:rich-text-body>
  </ac:macro>
<p>The following is an image:</p>

Cause

The cause is that the note macro was wrapped within <div> tag. Confluence editor will add a line break automatically before an opening <div> tag and after a closing </div> tag. Such content format isn't possible to be created from Confluence editor from scratch. So far our theory is that this could be caused when the content was copy pasted from external source (site or Microsoft Word).

Workaround


  • Install Confluence Source Editor plugin
    (info) Please note that the Source Editor plugin is a non supported  app.
  • Edit the source of the page using Confluence Source Editor plugin. Remove the unnecessary <div> tag from the content and save it. Now there shouldn't be any new line break added automatically every time you edit the page.

Another workaround, valid also in Cloud (above plugin is not available for Cloud instances), is to press SHIFT+ENTER instead of ENTER to go to a new line without adding a new paragraphs/div.

Last modified on Nov 22, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.