microsoft / microsoft/markitdown

HTML tables lose the header delimiter row after `<caption>` or `<colgroup>`, and `<tfoot>` adds a fake header

Open
#2,536 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
186k
Forks
13.7k
Avg merge
1d 4h
Merged PRs (30d)
49

Description

When a table's rows sit directly under <table> (not in <thead> or <tbody>), a <caption> or <colgroup> before them drops the | --- | line under the header. Without it the output isn't a Markdown table anymore, just lines of pipes. JDK 8 and 11 Javadoc summary tables are built this way.

A <tfoot> row has the opposite problem. It gets its own empty header and | --- | line in the middle of the table.

Repro on main (945314a, markdownify 1.2.3):

from markitdown.converters import HtmlConverter

c = HtmlConverter()
print(c.convert_string(
    "<table><caption>Stock</caption><tr><th>Name</th><th>Qty</th></tr>"
    "<tr><td>Apple</td><td>3</td></tr></table>").markdown)
print(c.convert_string(
    "<table><thead><tr><th>Item</th><th>Cost</th></tr></thead>"
    "<tbody><tr><td>A</td><td>1</td></tr></tbody>"
    "<tfoot><tr><td>Total</td><td>1</td></tr></tfoot></table>").markdown)

What I get:

Stock

| Name | Qty |
| Apple | 3 |
| Item | Cost |
| --- | --- |
| A | 1 |
|  |  |
| --- | --- |
| Total | 1 |

I expected | --- | --- | under the first header, the same as without the caption. The footer should just be the last row, | Total | 1 |.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the HtmlConverter entry point and reproduce both cases with convert_string using the HTML snippets in the issue. Trace the table conversion handling for caption, colgroup, and tfoot. Done means captioned or colgroup tables retain the Markdown delimiter row, while tfoot contributes only its data row without creating another header.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.