This week one of our clients asked if we could help to convert a large Word document to MediaWiki pages. His document was separated into 30 small “chapters” and he wanted each one to be its own page.

We said no problem and we converted that for him, including footnotes. How did we do it? Good question.

First trick is to open the file in LibreOffice Writer. Next is to copy and past one chapter into another document and then you can export that in MediaWiki format.

Do that 30 times and now you have 30 text files.

But they have some garbage “anchor” code that comes out ugly red in MediaWiki, so now we must remove that. We used this CLI command for that:

find . -exec sed -i 's/{{anchor|Toc.*}}//'  {} \;

Next step is to import those text files into MediaWiki. To do each one manually is silly of course, so we used this command to import them all via CLI:

php maintenance/importTextFiles.php --overwrite  /home/clientuser/private/txt.files.to.import/*

That was it. Images come out as references and those must be added manually, but that’s not too hard.

Leave a Reply

Your email address will not be published.