Bug 165590 - Parse Markdown formatted tables pasted into Calc spreadsheets or Writer tables
Summary: Parse Markdown formatted tables pasted into Calc spreadsheets or Writer tables
Status: RESOLVED DUPLICATE of bug 162153
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Paste Writer-Tables CSV-Import
  Show dependency treegraph
 
Reported: 2025-03-05 14:38 UTC by Jeff Fortin Tam
Modified: 2025-03-08 05:55 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot showing Writer and Calc unable to handle markdown tables pasted from clipboard (116.42 KB, image/png)
2025-03-05 14:38 UTC, Jeff Fortin Tam
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Fortin Tam 2025-03-05 14:38:05 UTC
Created attachment 199624 [details]
Screenshot showing Writer and Calc unable to handle markdown tables pasted from clipboard

The Markdown parser in GitLab's comments editor (and perhaps some other Markdown editors) automagically converts tabular content copied from LibreOffice Calc spreadsheets, but the reverse is not true.

If you copy this Markdown table to your clipboard:

| Sales   | Europe | Asia | Africa | Atlantis |
|---------|--------|------|--------|----------|
| Apples  | 434    | 545  |        | 6656     |
| Bananas | 5      |      | 33     | 7657     |
| Oranges | 677    | 535  | 3      | 4390     |

...and paste into Writer or Calc:

* Calc can partially interpret it by guessing the "|" column separators,
  however it adds an extra column at the start,
  and doesn't handle the "---" row below the header row.

* Writer doesn't parse it at all, it just pastes a plaintext mess.

---

Tested with LibreOffice 25.2
Comment 1 Jeff Fortin Tam 2025-03-05 14:53:11 UTC
Note that while the separator row is a requirement in Markdown's syntax, the separator row characters don't necessarily need to go edge-to-edge with the column separators, i.e. this syntax is also valid Markdown:

| Sales   | Europe | Asia | Africa | Atlantis |
| ------- | ------ | ---- | ------ | -------- |
| Apples  | 434    | 545  |        | 6656     |
| Bananas | 5      |      | 33     | 7657     |
| Oranges | 677    | 535  | 3      | 4390     |
Comment 2 Buovjaga 2025-03-05 15:01:01 UTC
There is bug 162153 for Markdown import. If https://github.com/mity/md4c were to be used, "With the flag MD_FLAG_TABLES, GitHub-style tables are supported"

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

*** This bug has been marked as a duplicate of bug 162153 ***
Comment 3 Jeff Fortin Tam 2025-03-07 18:48:33 UTC
Hmm, I understand how you'd consider it part of "import Markdown" in general, but that's a much wider scope than just supporting Markdown tables "at least in Calc" (closer to the existing CSV importer code) to begin with… my ticket was more specific than the other one, which was mostly imagining Writer-like usecases without even considering Calc.

I was also focusing on the "paste from clipboard" scenario, not "open a Markdown document", so I don't know if it all goes through the same codepaths?
Comment 4 Buovjaga 2025-03-08 05:55:45 UTC
(In reply to Jeff Fortin Tam from comment #3)
> Hmm, I understand how you'd consider it part of "import Markdown" in
> general, but that's a much wider scope than just supporting Markdown tables
> "at least in Calc" (closer to the existing CSV importer code) to begin with…
> my ticket was more specific than the other one, which was mostly imagining
> Writer-like usecases without even considering Calc.
> 
> I was also focusing on the "paste from clipboard" scenario, not "open a
> Markdown document", so I don't know if it all goes through the same
> codepaths?

Why would we consider Markdown tables in Calc separately? It would be extremely niche. If we add support via a library, it will be much easier to implement for Calc as well.