title: How to convert Confluence Storage Format XML to HTML?
body: <p>I am pulling content from confluence using the REST API.</p>
  
  <p><a href="https://docs.atlassian.com/atlassian-confluence/REST/3.2/" rel="nofollow noreferrer">https://docs.atlassian.com/atlassian-confluence/REST/3.2/</a></p>
  
  <p>The API returns confluence pages with a content property. The content is a mix of XHTML and proprietary XML tags. The XML is Confluence Storage Format:</p>
  
  <p><a href="https://confluence.atlassian.com/display/DOC/Confluence+Storage+Format" rel="nofollow noreferrer">https://confluence.atlassian.com/display/DOC/Confluence+Storage+Format</a></p>
  
  <p>The custom XML tags are used for things like images, relative links, and attachments. If I render the content straight out the custom XML will not render.</p>
  
  <p>I've found what looks like an endpoint that is supposed to convert the the format:
  <a href="https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/xhtml/api/XhtmlContent.html" rel="nofollow noreferrer">https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/xhtml/api/XhtmlContent.html</a></p>
  
  <p>I don't think it is longer supported.</p>
  
  <p>I've also found this project:</p>
  
  <p><a href="http://www.amnet.net.au/~ghannington/confluence/readme.html#wikifier" rel="nofollow noreferrer">http://www.amnet.net.au/~ghannington/confluence/readme.html#wikifier</a></p>
  
  <p>Which converts confluence XML into confluence wiki markup. The project comes with two <code>.xsl</code> sheets One sheet is <code>confluence2wiki.xsl</code> which handles the markup conversion, and the other is <code>confluence2xhtml.xsl</code>which sounds like it would do the job but unfortunately the implementation is poor. It literally converts the confluence XML into XHTML that looks like the XML. So an image tag from the confluence XML unfortunately becomes:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="extension-element"&gt;
    &lt;p class="extension-element-markup"&gt;
      &lt;span class="element-name"&gt;ac:image&lt;/span&gt;
      &lt;span class="attribute-name"&gt;ac:alt&lt;/span&gt;
      &lt;span class="markup"&gt;="&lt;/span&gt;
      &lt;span class="attribute-value"&gt;Example1.png&lt;/span&gt;
      &lt;span class="markup"&gt;"&lt;/span&gt;
    &lt;/p&gt;
    &lt;div class="extension-element-contents"&gt;
      &lt;div class="extension-element"&gt;
        &lt;p class="extension-element-markup"&gt;
          &lt;span class="element-name"&gt;ri:url&lt;/span&gt;
          &lt;span class="attribute-name"&gt;ri:value&lt;/span&gt;
          &lt;span class="markup"&gt;="&lt;/span&gt;
          &lt;span class="attribute-value"&gt;https://example.com/attachments/token/2ujwb0dm4jsorgk/?name=Omniata_Docs_Projects_Example1.png&lt;/span&gt;
          &lt;span class="markup"&gt;"&lt;/span&gt;
        &lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Which is not very helpful. Currently it looks like I will have to write my own <code>xsl</code> sheet based on the <code>wkik xsl sheet</code>. I'm hoping there is a less manual solution out there or someone has done this before.</p>