erusev / parsedown

Better Markdown Parser in PHP

Home Page:https://parsedown.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table not displaying correctly using Parsedown 1.7.4 or 1.8.0-beta-7

dj357 opened this issue · comments

commented

I have the following table in a .MD file:

| Letter | Status | Details | | :----: | ------ | ------- | | N | Not Validated | The item is in the **Not Validated** tab in the Claims module, awaiting validation by the user. | | V | Validated | The item is in the **Validated** tab in the Claims module, awaiting verification checks by the system. | | E | Exceptions | The item is in the **Claim Exceptions** tab in the Claims module, awaiting editing/fixing by the user. | | C | Ready To Claim | The item is in the **Send Claim** tab in the Claims module, awaiting transmission to the PCRS. | | P | Paid | The item has been sent to the PCRS and has not yet received an Exception response. As such, we assume it will be paid for unless the system is told otherwise. | | D | Deleted | The item has been deleted from the **Claims Exceptions** tab as it was rejected by the PCRS and then deleted manually by the user, presumably because they opted not to pursue a further reclaim for the item. |

When testing this table on the website, it parses correctly:

demo

However, when using Parsedown 1.7.4 or Parsedown 1.8.0-beta-7, neither of them display the table correctly:

live

I am running PHP v5.6 on an IIS Server. Is this a bug or a configuration issue or a PHP version issue perhaps?

This is the code being used to display the Markdown:

$handle = fopen($path, 'r'); if ($handle) { while (($line = fgets($handle)) !== false) { // process the line read. echo $Parsedown->text($line); } fclose($handle); } else { // error opening the file. echo "Error"; }

Have you forgotten to create a new object?

$Parsedown = new Parsedown();

commented

Have you forgotten to create a new object?

$Parsedown = new Parsedown();

Hi jockel09, thanks for the reply. No, that is done higher up, I just didn't include that line of code.

Hi, it looks like the issue is that the table you're wanting to display is an object that spans multiple lines, however you're asking Parsedown to parse the lines individually. To get the result you'd expect, you'd need to read the file into a single string, and then pass that string to Parsedown all in one go.

commented

Hi, it looks like the issue is that the table you're wanting to display is an object that spans multiple lines, however you're asking Parsedown to parse the lines individually. To get the result you'd expect, you'd need to read the file into a single string, and then pass that string to Parsedown all in one go.

Ok that makes so much sense. Confirmed issue resolved.