Closed SL-Gundam closed 5 years ago
I'd like for any new features to align with the CommonMark spec. Because CommonMark does not (yet) define syntax for tables, I'm hesitant to include it here - instead, I'd prefer to see tables implemented as an addon library.
I need this functionality too, thanks for taking care.
Needed this as well, so built one here: https://github.com/Mark-H/Docs/blob/2.x/convert/util/TableConverter.php
Load it into your converter instance like this:
$environment = Environment::createDefaultEnvironment($options);
$environment->addConverter(new TableConverter());
$this->converter = new HtmlConverter($environment);
@Mark-H Nice! If you wanted to release that as a standalone package (that others can easily composer require
into their own projects) I'd be happy to give it a prominent link on our README :)
@colinodell I wrapped the converter from @Mark-H into an installable package here: https://github.com/xprt64/php-markdown-table-converter and added one unittest.
Hey there, is there any way to convert from Markdown table back to HTML? The CommonMark converter seems to not be able to do it.
I've found an issue under TableConverter.php
Line 48
case 'thead': $headerLine = reset($element->getChildren())->getValue(); $headers = explode(' | ', trim(trim($headerLine, "\n"), '|'));
Getting the Error:
ErrorException: Only variables should be passed by reference
To make it work: moved out the function call to a resulting variable:
$children = $element->getChildren();
$headerLine = reset($children)->getValue();
By the way great work.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Is this library capable of converting a html table to markdown?
If not then this would be a feature request