hallowelt / migrate-confluence

Tool to migrate content from Confluence export files into a MediaWiki compatible import source
GNU General Public License v3.0
35 stars 8 forks source link

multiple Macros #75

Closed markus-96 closed 6 months ago

markus-96 commented 1 year ago

We used these scripts for migrating an old Confluence instance to Mediawiki. In one space, the macro for expandable sections was heavily used. Also, the macros gallery, latex and multimedia were used. Since we decided to copy these sections manually, I will post my findings here. Maybe it will be usefull for someone.

expand

It was mainly used in tables, the XML of these sections looks like:

        <tr>
            <td>
                <ac:structured-macro ac:name="expand">
                    <ac:parameter ac:name="title">click here to expand</ac:parameter>
                    <ac:rich-text-body>
                        <ul>
                            <li>something
                                <ul>
                                    <li>something more</li>
                                </ul>
                            </li>
                        </ul>
                    </ac:rich-text-body>
                </ac:structured-macro>
            </td>
            <td>next collum</td>
        </tr>

Maybe, it can be replaced with the following in Mediawiki:

| <div class="toccolours mw-collapsible mw-collapsed">
click here to expand
<div class="mw-collapsible-content">
* something
** something more
</div></div>
| next collum

latex

If you embed some formula in latex, it looks like this in the export:

<ac:structured-macro ac:name="latex"><ac:plain-text-body><![CDATA[\Large
$\boldsymbol{Grundgleichungen}$

\begin{equation}
\begin{aligned}
\boldsymbol{S} = \boldsymbol{s^E} \boldsymbol{T} + \boldsymbol{\delta} \boldsymbol{E}
\end{aligned}
\label{gl.piezo1}
\end{equation}

]] ></ac:plain-text-body></ac:structured-macro>

With the Extension Math, Latex can be rendered:

<math>
\Large$\boldsymbol{Grundgleichungen}$

\begin{equation}
\begin{aligned}
\boldsymbol{S} = \boldsymbol{s^E} \boldsymbol{T} + \boldsymbol{\delta} \boldsymbol{E}
\end{aligned}
\label{gl.piezo1}
\end{equation}
</math>

gallery

This seams to be a bit tricky.

<ac:structured-macro ac:name="gallery">
    <ac:parameter ac:name="title">Gallery with images</ac:parameter>
    <ac:parameter ac:name="sort">name</ac:parameter>
    <ac:parameter ac:name="excludeLabel">Foto</ac:parameter>
    <ac:parameter ac:name="columns">3</ac:parameter>
    <ac:parameter ac:name="exclude">Foto</ac:parameter>
</ac:structured-macro>

There has to be a function that iterates over all images attached to the page and then add it to the gallery. There is also an option to include attached images from other pages, that is even more tricky. I would suggest to add these in an post process..

<gallery>
Media:Image1.jpg
Media:Image2.jpg
Media:Image3.jpg
Media:Image4.jpg
Media:Image5.jpg
</gallery>

multimedia

<ac:structured-macro ac:name="multimedia">
    <ac:parameter ac:name="name">
        <ri:attachment ri:filename="video.mov" />
    </ac:parameter>
</ac:structured-macro>

If the extension TimedMediaHandler is used, that is maintained by Mediawiki, the Syntax is as simple as:

[[File:video.mov|File:video.mov]]
osnard commented 6 months ago

Solved by https://github.com/hallowelt/migrate-confluence/pull/80