table-to-markdown
table-to-markdown copied to clipboard
A Chrome DevTools extension to convert an HTML Table to Markdown for easy export.
Table to Markdown
A Chrome DevTools extension to convert an HTML Table to Markdown for easy export.
Report a Bug
·
Request a Feature
About The Project
This Chrome DevTools extension adds an extra tab to the Chrome DevTools and will allow you to export any HTML Table in Markdown format.
Installing
The latest published version of the extension can be installed from the Chrome Web Store.
To load this extension locally for development, clone the repo to your machine. Visit the Chrome extensions page at chrome://extensions and click the Load Unpacked button. Navigate to and choose this project folder that you cloned. And voilà! The extension will now appear in your browser and DevTools.
Usage
Navigate to a page that has an HTML table element. Right click anywhere on the table you would like to export and inspect it in your DevTools. You don't have to select the top <table> element yourself! If you selected anything inside of the table, the extension will find the entire table.
Open the Table to Markdown panel of the DevTools (you may need to click the dropdown to see it). Click the Convert to Markdown button, and your markdown table will appear in the box.
HTML Table export format
To see an example of how a table will be rendered, let's look at the following table taken from the Scholastic Accolades Wikipedia page.
This table will be rendered in Markdown as follows:
| Accolade | Name | Death |
|-----------------------------------|----------------------------|--------------|
| Doctor Aristotelis Anima | Johannes Dondus | 1380 |
| Doctor a Doctoribus | Antonius Franciscus | 1528 |
| Doctor Fons Canonum | Johannes Andrea | 1348 |
| Doctor Fons Juris Utriusque | Henry of Susa (Ostia) | 1267-81 |
| Doctor Lucerna Juris | Baldus de Ubaldis | 1400 |
| Doctor Lucerna Juris Pontificii | Nicholas Tedeschi (O.S.B.) | 1445 |
| Doctor Lumen Juris | Pope Clement IV | 1268 |
| Doctor Lumen Legum | Irnerius | 1125 (after) |
| Doctor Memoriosissimus | Ludovicus Pontanus | 1439 |
| Doctor Monarcha Juris | Bartholomew of Saliceto | 1412 |
| Doctor Os Aureum | Bulgarus | 1166 |
| Doctor Pater Decretalium | Gregory IX | 1241 |
| Doctor Pater et Organum Veritatis | Pope Innocent IV | 1254 |
| Doctor Pater Juris | Pope Innocent III | 1216 |
| Doctor Pater Peritorum | Pierre de Belleperche | 1307 |
| Doctor Planus ac Perspicuus | Walter Burleigh | 1337 |
| Doctor Princeps Subtilitatum | Francesco d'Accolti | 1486 |
| Doctor Speculator | William Durandus | 1296 |
| Doctor Speculum Juris | Bartholus of Sassoferrato | 1359 |
| Doctor Subtilis | Benedict Raymond | 1440 |
| Doctor Subtilis | Filippo Corneo | 1462 |
| Doctor Verus | Thomas Doctius, Siena | 1441 |
HTML Tables without headers
Most Markdown table parsers do not support header-less tables. To compensate for this, this extension throws in a blank header row. For example, take the following table (taken from the NBA Most Valuable Player Award Wikipedia page).
This table will be rendered in Markdown like this:
| | |
|------------|--------------------------------------------------------------------------|
| ^ | Denotes player who is still active in the NBA |
| * | Inducted into the Naismith Memorial Basketball Hall of Fame |
| † | Denotes player whose team won championship that year |
| Player (X) | Denotes the number of times the player had been named MVP at that time |
| Team (X) | Denotes the number of times a player from this team had won at that time |
HTML tables with missing cells
HTML tables sometimes leave off empty cells in the final column, like this table about medieval accolades.
It will be rendered in Markdown with the cells missing as well. Markdown parsers usually handle this gracefully and render the table with those cells blank.
| Accolade | Name | Death | Translation/Notes |
|-----------------------|----------------------|-----------------|---------------------------------------------------------------------------|
| Apostolus | St. Paul | 67 | Due to his preeminence among the Letters of the Apostles within the Bible |
| Commentator | Averroes (Ibn Rushd) | 1198 |
| Magister sententiarum | Peter Lombard | 1160 |
| Philosophus | Aristotle | BC 322 |
| Propheta | David | BC 10th century | Due to his authorship of the Psalms |
| Theologus | Augustine of Hippo | 430 |
Tables with elements that span rows or columns
HTML tables allow for elements that span multiple rows or columns, a feature not supported in most Markdown flavors. To compensate for this, any cells that span multiple rows or columns are just repeated to avoid ambiguity. See this table of vowels from the Esperanto Wikipedia page.
The a vowel that spans two columns at the bottom would be repeated, and the Markdown would appear as so:
| | | |
|-------|-------|------|
| | Front | Back |
| Close | i | u |
| Mid | e | o |
| Open | a | a |
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details
Contact
Karey Higuera - @kbravh - [email protected]
Project Link: https://github.com/kbravh/table-to-markdown