Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

some way to paste HTML in Confluence 4?

Robert Lauriston
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.
December 9, 2011

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

2 votes
Answer accepted
Robert Lauriston
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.
May 28, 2012

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

1 vote
Robert Lauriston
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.
January 3, 2012

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

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

1 vote
Robert Lauriston
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.
December 19, 2011

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.

1 vote
Andrew Frayling
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.
December 10, 2011

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?

1 vote
Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 10, 2011

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;

Robert Lauriston
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.
December 11, 2011

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> <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>]]></ac:plain-text-body></ac:macro>

Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2011

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

Robert Lauriston
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.
December 11, 2011

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.

Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2011

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.

Robert Lauriston
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.
December 11, 2011

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"

Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2011

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.

Robert Lauriston
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.
December 11, 2011

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

0 votes
Andrew Frayling
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.
December 10, 2011
Hi Robert, at a guess I'd say that the Paragraph... ?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events