Index ¦ Archives ¦ RSS

Markdown import/export in Writer

Estimated read time: 3 minutes

Writer recently got a Markdown import & export filter and there were a number of improvements to that.

This work is primarily for Collabora Online, but the feature is available in desktop Writer as well.

Motivation

Ujjawal Kumar contributed a markdown import to Writer, as part of Google Summer of Code (GSoC) this summer. Mike Kaganski of Collabora also created a minimal markdown export in Writer. I looked at the feature differences between the two, and filled in various gaps in the markdown export. I also added a few general markdown import/export improvements relevant for normal Writer documents, like embedded image support.

Results so far

Here is a sample case of a document using inline code spans:

Code span: baseline

Exporting this to markdown & loading back to Writer, the code span was lost:

Code span: old result

And now it's preserved:

Code span: new result

This also works with code blocks.

Second, here is a document with lists:

Lists: baseline

Exporting this to markdown & loading back to Writer, the lists were lost:

Lists: old result

And now they are preserved:

Lists: new result

This also works with nested lists.

Third, here is a document with an image:

Image: baseline

Exporting this to markdown & loading back to Writer, the image was lost:

Image: old result

And now it's preserved:

Image: new result

This also works with embedded and anchored images.

Fourth, here is a document with a table:

Table: baseline

Exporting this to markdown & loading back to Writer, the table was lost:

Table: old result

And now it's preserved:

Table: new result

This also works with table alignments and nested tables (to the extent the markdown markup allows that).

Fifth, here is a document with a quote block:

Quote: baseline

Exporting this to markdown & loading back to Writer, the quote's paragraph indentation was lost:

Quote: old result

And now it's preserved:

Quote: new result

How is this implemented?

If you would like to know a bit more about how this works, continue reading... :-)

As usual, the high-level problem was addressed by a series of small changes. Core side:

Want to start using this?

You can get a development edition of Collabora Online 25.04 and try it out yourself right now: try the development edition. Collabora intends to continue supporting and contributing to LibreOffice, the code is merged so we expect all of this work will be available in TDF's next release too (26.2).

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.