some way to paste HTML in Confluence 4?
Asked by Robert Lauriston:

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.


Answers:
author: Robert Lauriston
body: Kludge no longer necessary, just install the Confluence Source Editor plugin.

<https://marketplace.atlassian.com/plugins/com.atlassian.confluence.plugins.editor.confluence-source-editor/version/6>


author: Robert Lauriston
body: I guess Atlassian's answer is to buy Arsenale Invisible Ink:

<https://jira.atlassian.com/browse/CONF-23914>


author: Robert Lauriston
body: 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.


author: Andrew Frayling
body: 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?


author: Jeremy Largman
body: Yes. Use the [HTML macro](http://confluence.atlassian.com/display/DOC/HTML+Macro). It has to be enabled by an administrator. Notice also some widgets work with the [Widget Connector](http://confluence.atlassian.com/display/DOC/Widget+Connector+Macro).

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;
```

comments: author: Robert Lauriston
body: 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><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> 
strikethrough
 <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>]]></ac:plain-text-body></ac:macro>
```


author: Jeremy Largman
body: 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:

<https://developer.atlassian.com/display/CONFDEV/Confluence+XML-RPC+and+SOAP+APIs>

Notice this note:

<https://developer.atlassian.com/display/CONFDEV/Changes+to+the+remote+API+in+Confluence+4.0>


author: Robert Lauriston
body: 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.


author: Jeremy Largman
body: 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](https://studio.plugins.atlassian.com/wiki/display/CSOAP/Confluence+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.


author: Robert Lauriston
body: 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"
```


author: Jeremy Largman
body: Looks like that might be a bug:

<https://studio.plugins.atlassian.com/browse/CSOAP-116>

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


author: Robert Lauriston
body: I'm not sure that's relevant. The CLI addPage command handles HTML just like the editor.


author: Andrew Frayling
body: Hi Robert, at a guess I'd say that the Paragraph... ?


Tags: html

import

xhtml