some way to paste HTML in Confluence 4?

I've been looking for a migration path to get our existing FrameMaker documents into Confluence 4.0.

If I export a space, I can see that a page body looks like this:

<property name="body"><![CDATA[<p>Paragraph</p><h1>Heading 1</h1><h2>Heading 2</h2><pre>Preformatted</pre><blockquote><p>Quote</p></blockquote><p>Paragraph</p><p>Character styles: <strong>bold</strong> <em>italic</em> <u>underlined</u> <span style="color: rgb(255,0,0);">red</span> <s>strikethrough</s> <sub>subscript</sub> <sup>superscript</sup> <code>monospace</code></p><ul><li>bullet list 1</li><li>bullet list 2</li></ul><ol><li>numbered list 1</li><li>numbered list 2</li></ol><p>Paragraph</p>]]></property>

Is there some widget I can use to paste that XHTML and have Confluence parse it?
If I use Insert > Wiki Markup, it's pasted as literal text. If I use an HTML Macro, it doesn't get parsed, it stays in HTML.

6 answers

1 accepted

1 vote

Yes. Use the HTML macro. It has to be enabled by an administrator. Notice also some widgets work with the Widget Connector.

Sorry, on reading this again, I didn't see your intial comment:

If I use an HTML Macro, it doesn't get parsed, it stays in HTML.

It works if you cut off the front and the back, as Andrew says:

&lt;h1&gt;Heading 1&lt;/h1&gt;&lt;h2&gt;Heading 2&lt;/h2&gt;&lt;pre&gt;Preformatted&lt;/pre&gt;&lt;blockquote&gt;&lt;p&gt;Quote&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Paragraph&lt;/p&gt;&lt;p&gt;Character styles: &lt;strong&gt;bold&lt;/strong&gt; &lt;em&gt;italic&lt;/em&gt; &lt;u&gt;underlined&lt;/u&gt; &lt;span style="color: rgb(255,0,0);"&gt;red&lt;/span&gt; &lt;s&gt;strikethrough&lt;/s&gt; &lt;sub&gt;subscript&lt;/sub&gt; &lt;sup&gt;superscript&lt;/sup&gt; &lt;code&gt;monospace&lt;/code&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;bullet list 1&lt;/li&gt;&lt;li&gt;bullet list 2&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;&lt;li&gt;numbered list 1&lt;/li&gt;&lt;li&gt;numbered list 2&lt;/li&gt;&lt;/ol&gt;

It doesn't get parsed, only rendered. When I edit the page, the code is still embedded in the HTML macro. If I could edit the source, I could just delete the macro tags (Confluence is adding the CDATA tags, all I'm pasting is the stuff from <h1> to </ol>):

<ac:macro ac:name="html"><ac:plain-text-body><![CDATA[
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<p>Character styles: <strong>bold</strong> <em>italic</em> <u>underlined</u> <span style="color: rgb(255,0,0);">red</span> <s>strikethrough</s> <sub>subscript</sub> <sup>superscript</sup> <code>monospace</code></p>
<li>bullet list 1</li>
<li>bullet list 2</li></ul>
<li>numbered list 1</li>
<li>numbered list 2</li></ol>]]></ac:plain-text-body></ac:macro>

Ah, thanks. Now athat you mention rendering as opposed to parsing, it helps.

I think you can use the Remote API (v2) to store pages in xhtml. In fact that might be ideal, since you can upload a lot of them at once, programatically:

Notice this note:

Yeah, I found the Remote API, but that seems more like something to use to build a plugin to do what I need. The stuff I'm migrating needs a lot of cleanup after import, so it's most efficient to cut and paste page by page.

One sort of absurd kludge is to use an HTML macro, save, copy the rendered text, edit, and paste over the HTML macro.

It's not quite building a plugin, you can use a script to do it, but yeah it's code-heavy if you're not a developer. The Command Line Interface might be a way to go?

Otherwise, yes, I think the copy and paste from the rendered output is the way to do it through the UI.

Tried the CLI using the following. The HTML is not parsed, just shows up as literal text.

confluence --action addpage --space "robert01" --title "test001" --content "&lt;h1&gt;Heading 1&lt;/h1&gt;" --parent "Home"

Looks like that might be a bug:

Have a look there, it seems like Bob (the author) will put that in the next version.

I'm not sure that's relevant. The CLI addPage command handles HTML just like the editor.

Sorry, must remember to not use the iPad to answer questions on here.

Full answer was that at a guess I'd say that the <![CDATA tag was throwing the HTML Macro as CDATA tells the macro it's character data and shouldn't be parsed. What happens if you remove the opening and closing <![CDATA tags and just try the text from <p>paragraph</p>... onwards in your above example?

Well, as I said, this seems like an absurd kludge, but it works: paste the HTML in an HTML macro, save, copy the rendered text, edit, and paste over the HTML macro.

I guess Atlassian's answer is to buy Arsenale Invisible Ink:

Hi Robert, at a guess I'd say that the Paragraph... ?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Confluence

Three common content challenges + how to manage them

An efficient enterprise content management system, or ECM, is a must-have for companies that create work online (cough   cough, all companies). If content calendars, marketing plans, and bu...

64 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you