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:
Exporting this to markdown & loading back to Writer, the code span was lost:
And now it's preserved:
This also works with code blocks.
Second, here is a document with lists:
Exporting this to markdown & loading back to Writer, the lists were lost:
And now they are preserved:
This also works with nested lists.
Third, here is a document with an image:
Exporting this to markdown & loading back to Writer, the image was lost:
And now it's preserved:
This also works with embedded and anchored images.
Fourth, here is a document with a table:
Exporting this to markdown & loading back to Writer, the table was lost:
And now it's preserved:
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:
Exporting this to markdown & loading back to Writer, the quote's paragraph indentation was lost:
And now it's preserved:
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:
- desktop lok, doc save: register .md for Markdown
- sw markdown export: handle code
- tdf#168152 sw markdown export: handle lists
- tdf#168172 sw markdown export: handle images
- tdf#167564 sw markdown export: handle tables
- sw markdown export: handle block quote
- tdf#168317 sw markdown export: handle code block
- sw markdown export: handle table cell adjustment
- tdf#168341 sw markdown filter: handle links on images
- sw markdown export: handle line breaks
- tdf#168446 sw markdown export: improve image name/description/title handling
- tdf#167564 sw markdown export: handle multi-para table cells
- tdf#167564 sw markdown export: handle nested table cells
- tdf#168617 sw markdown filter: map tasks to checkbox content controls and back
- sw markdown filter: import images with 'data:' URLs
- sw markdown filter: export non-linked inline images
- tdf#168662 sw markdown export: extract inline image export functions
- tdf#168662 sw markdown export: handle anchored images
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).