Bug 160734 - Support exporting to Markdown
Summary: Support exporting to Markdown
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://en.wikipedia.org/wiki/Markdown
Whiteboard:
Keywords:
Depends on:
Blocks: Format-Filters
  Show dependency treegraph
 
Reported: 2024-04-19 13:37 UTC by Eyal Rozenberg
Modified: 2024-07-23 09:32 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eyal Rozenberg 2024-04-19 13:37:22 UTC
Markdown is a commonly used text-based format with simple(ish) direct formatting and a few structural elements (e.g. tables, block-quotes, code blocks). It is relatively popular, especially on web-based platforms (e.g. discourse installation, GitHub & GitLab). See:

https://en.wikipedia.org/wiki/Markdown 

It would be useful if we could take a Writer document, and export it into a Markdown document. 

Notes:

* There's a similar request regarding Calc: bug 94978.
* Standardization for MarkDown is a bit problematic, with some fracturing regarding what constitutes the standard. https://commonmark.org may be relevant, but isn't the only option.
Comment 1 Stéphane Guillou (stragu) 2024-04-19 14:11:28 UTC
Import and Export filters are good, less controversial first steps in Markdown support. But as you said, the challenge is picking a flavour.

Exporting to .md would simplify drastically the document to whatever the flavour allows.
(In reply to Eyal Rozenberg from comment #0)
> * There's a similar request regarding Calc: bug 94978.
(I consider "Save As" to be very different, and a lot more difficult to implement, as it would imply that LO supports _editing_ markdown files. And for that, we'd need to accommodate markup editing + rendered view somehow (.e.g by repurposing the Web View), possibly with a stripped down UI that only offers what the format supports.)

In any case, +1 for me.
Design/UX team?
Comment 2 Eyal Rozenberg 2024-04-19 15:54:06 UTC
(In reply to Stéphane Guillou (stragu) from comment #1)
> (I consider "Save As" to be very different, and a lot more difficult to
> implement, as it would imply that LO supports _editing_ markdown files.

The opening comment of the other bug says "One way I could imagine such a support is by export tables created in Calc to Markdown syntax."

Also, I'm not sure how exactly you're making that distinction. If you can import a file format and export to it, then your app is an editor of that format. Perhaps not a great editor, nor an editor with "idempotence" over import-then-export, but an editor nonetheless.

... but maybe I'm misunderstanding?

Also note I am not asking for Markdown _import_ support, at least not with this bug.
Comment 3 Eyal Rozenberg 2024-04-19 15:55:00 UTC
(In reply to Stéphane Guillou (stragu) from comment #1)
> Import and Export filters are good, less controversial first steps in
> Markdown support. But as you said, the challenge is picking a flavour.

Right. And I know I said CommonMark, but then - Tables are important :-)
Comment 4 Antonio Vidal 2024-04-19 22:53:22 UTC
> Markdown support. But as you said, the challenge is picking a flavour

Would propose Markdown-it due to being 100% compliant with CommonMark, secure by Google, and extensible with plugins

https://github.com/markdown-it/markdown-it
Python port: https://markdown-it-py.readthedocs.io/en/latest/#
Experimental Rust port: https://github.com/chrisjsewell/markdown-it-pyrs

Table and strikethrough from GFM flavour are implemented natively, and more features can be added via extensions
https://markdown-it-py.readthedocs.io/en/latest/plugins.html
Comment 5 Heiko Tietze 2024-04-21 07:36:53 UTC
Nothing to decide for UX. But there was a lot of acceptance in the design Telegram channel for adding markdown filters. Same request in bug 94978 - we should make one a duplicate.
Comment 6 Eyal Rozenberg 2024-04-21 07:57:14 UTC
(In reply to Heiko Tietze from comment #5)
> Same request in bug 94978 - we should make one a duplicate.

That bug seems to be calc-specific and tables-focused. I don't object to unifying the bugs, but the one that stays up needs to be generalized.
Comment 7 Eyal Rozenberg 2024-07-17 13:10:06 UTC
Google Docs now supports (Importing and) Exporting Markdown:

https://workspaceupdates.googleblog.com/2024/07/import-and-export-markdown-in-google-docs.html
Comment 8 Buovjaga 2024-07-23 08:30:07 UTC
(In reply to Antonio Vidal from comment #4)
> > Markdown support. But as you said, the challenge is picking a flavour
> 
> Would propose Markdown-it due to being 100% compliant with CommonMark,
> secure by Google, and extensible with plugins
> 
> https://github.com/markdown-it/markdown-it
> Python port: https://markdown-it-py.readthedocs.io/en/latest/#
> Experimental Rust port: https://github.com/chrisjsewell/markdown-it-pyrs
> 
> Table and strikethrough from GFM flavour are implemented natively, and more
> features can be added via extensions
> https://markdown-it-py.readthedocs.io/en/latest/plugins.html

Those are not for export, but for import. For import, an easier integration would probably be this C-based lib: https://github.com/mity/md4c

Note that when dealing with importing, valid Markdown files can contain any HTML.