Bug 162153 - Support importing Markdown files
Summary: Support importing Markdown files
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Ujjawal Kumar
URL: https://wiki.documentfoundation.org/D...
Whiteboard: target:26.2.0
Keywords:
: 165590 (view as bug list)
Depends on:
Blocks: Format-Filters
  Show dependency treegraph
 
Reported: 2024-07-23 09:32 UTC by Eyal Rozenberg
Modified: 2025-07-11 09:23 UTC (History)
6 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-07-23 09:32:17 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 open a Markdown document in Writer, and get it "rendered" with appropriate styles. i.e. we should be able to import Markdown into Writer.

Note:

* Bug 160734 regards the ability to export to Markdown.
Comment 1 Eyal Rozenberg 2024-07-23 09:37:35 UTC
(In reply to Buovjaga from comment #8 on bug 160734)
> (In reply to Antonio Vidal from comment #4 on bug 160734)
> > > 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.

1. Are you sure Markdown can contain _any_ HTML rather than just _some_ HTML?
2. Regardless - we could start with an input filter that doesn't support HTML, or with very limited HTML support (e.g. tags like a, b, em). This would already be useful.
Comment 2 Buovjaga 2024-07-23 09:51:50 UTC
(In reply to Eyal Rozenberg from comment #1)
> 1. Are you sure Markdown can contain _any_ HTML rather than just _some_ HTML?

https://spec.commonmark.org/0.31.2/#html-blocks

I sure have used any HTML I like in Markdown content when building the new LibreOffice site with Hugo.
Comment 3 Buovjaga 2025-03-05 15:01:01 UTC
*** Bug 165590 has been marked as a duplicate of this bug. ***
Comment 5 Eyal Rozenberg 2025-07-07 10:06:00 UTC
(In reply to Adolfo Jayme Barrientos from comment #4)
>  890d2c865215f8a679fbb8e0644e3f73c4c4bb0c
> 58cfa7b1a5f44b2dbd945db4fd8261b7227c33b6

Can you elaborate on what exactly the state of support for Markdown input is, after these commits? And which flavors of Markdown are supported?
Comment 6 Buovjaga 2025-07-07 10:17:33 UTC
(In reply to Eyal Rozenberg from comment #5)
> (In reply to Adolfo Jayme Barrientos from comment #4)
> >  890d2c865215f8a679fbb8e0644e3f73c4c4bb0c
> > 58cfa7b1a5f44b2dbd945db4fd8261b7227c33b6
> 
> Can you elaborate on what exactly the state of support for Markdown input
> is, after these commits? And which flavors of Markdown are supported?

As seen in the commits, https://github.com/mity/md4c is used. Even Writer tables are supported. Stay tuned for more as there is still plenty of time left in the GSoC project.
Comment 7 Eyal Rozenberg 2025-07-07 12:09:13 UTC
(In reply to Buovjaga from comment #6)

Is there an outline of the GSoC project which could be attached or linked to from here?

Anyway, added (Adlopho) Jayme to the CC list.
Comment 8 Buovjaga 2025-07-07 13:58:02 UTC
(In reply to Eyal Rozenberg from comment #7)
> (In reply to Buovjaga from comment #6)
> 
> Is there an outline of the GSoC project which could be attached or linked to
> from here?

https://wiki.documentfoundation.org/Development/GSoC/Ideas#Import_Markdown_files_into_LibreOffice_Writer

(it will be moved out once successful)
Comment 9 Commit Notification 2025-07-11 07:46:27 UTC
Ujjawal Kumar committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/efc7ceae33c016fbbc2aa43cd53a611588d66eed

tdf#162153 Fixed member variable initialization bug.

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2025-07-11 09:23:49 UTC
Ujjawal Kumar committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/bec29bda906fe077781da3744f8b1d3fab32b574

tdf#162153 Unit tests for Markdown Filter

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.