html2md icon indicating copy to clipboard operation
html2md copied to clipboard

Table formatting not working

Open carl-vbn opened this issue 4 months ago • 2 comments

Hi, I was testing this library to see if it was applicable to my use case, but table formatting seems to be broken:

Here's my input:

<!DOCTYPE html>
<html>
<head>
  <title>Dummy Table</title>
  <style>
    table {
      width: 60%;
      border-collapse: collapse;
      margin: 20px auto;
    }
    th, td {
      border: 1px solid #ccc;
      padding: 8px 12px;
      text-align: center;
    }
    th {
      background-color: #f4f4f4;
    }
  </style>
</head>
<body>

  <h2 style="text-align: center;">Sample HTML Table</h2>
  <a href="https://example.com">Link</a>
  <table>
    <thead>
      <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Email</th>
        <th>Status</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>1</td>
        <td>Alice</td>
        <td>[email protected]</td>
        <td>Active</td>
      </tr>
      <tr>
        <td>2</td>
        <td>Bob</td>
        <td>[email protected]</td>
        <td>Inactive</td>
      </tr>
      <tr>
        <td>3</td>
        <td>Charlie</td>
        <td>[email protected]</td>
        <td>Pending</td>
      </tr>
    </tbody>
  </table>

</body>
</html>

And the generated output:

$ html2md -p test.html
Dummy Table
=============


## Sample HTML Table
[Link](https://example.com)  
|   |
||----|---------|---------------------|----------|
| - | -  | -       | -                   |
|   |
|   | 1  | Alice   | [email protected]   | Active   |  |
|   | 2  | Bob     | [email protected]     | Inactive |  |
|   | 3  | Charlie | [email protected] | Pending  |  |

This is not how markdown tables should look. Any advice?

carl-vbn avatar Jul 14 '25 14:07 carl-vbn

Yep that's not how it should look like. I'll look into it

tim-gromeyer avatar Jul 14 '25 19:07 tim-gromeyer

Uhm so yeah, I completely forgot about it, are you still looking forward to a fix?

tim-gromeyer avatar Oct 29 '25 12:10 tim-gromeyer