Html2Markdown.TableConverter (html2markdown v0.3.0)

Handles conversion of HTML tables to Markdown format.

Converts HTML tables to GitHub Flavored Markdown tables with support for:

  • Header detection (from <th> elements or <thead>)
  • Complex table structures with <thead> and <tbody>
  • Colspan handling (content repeated across columns)
  • Empty cells and malformed tables

Examples

# Simple table
<table>
  <tr><th>Name</th><th>Age</th></tr>
  <tr><td>Alice</td><td>30</td></tr>
</table>

# Converts to:
| Name | Age |
| --- | --- |
| Alice | 30 |

Implementation Notes

  • Tables without headers still generate valid Markdown tables
  • Empty cells are preserved as empty columns
  • Malformed HTML is handled gracefully

Summary

Functions

process_table(children, opts)

@spec process_table([Floki.html_node()], Html2Markdown.Options.t()) :: String.t()