fixed table alignment parsing

feature/tests
Michael Ochmann 3 years ago
parent a1bf9a82ae
commit a63756d2b0
  1. 4
      README.md
  2. 9
      src/Parser.php

@ -82,7 +82,7 @@ or via reference to [a later defined url][massivedynamic], i we so desire.
### Tables ### Tables
```markdown ```markdown
| Product name | Amount | Price | | Product name | Amount | Price |
|--------------|-----:----|-------:| |--------------|:--------:|-------:|
| Football | 7 | $18,00 | | Football | 7 | $18,00 |
| Golfball | 122 | $7,00 | | Golfball | 122 | $7,00 |
| Fooseball | 355 | $1,00 | | Fooseball | 355 | $1,00 |
@ -90,7 +90,7 @@ or via reference to [a later defined url][massivedynamic], i we so desire.
``` ```
| Product name | Amount | Price | | Product name | Amount | Price |
|--------------|-----:----|-------:| |--------------|:--------:|-------:|
| Football | 7 | $18,00 | | Football | 7 | $18,00 |
| Golfball | 122 | $7,00 | | Golfball | 122 | $7,00 |
| Fooseball | 355 | $1,00 | | Fooseball | 355 | $1,00 |

@ -396,11 +396,14 @@ class Parser {
if ($buffer === "") if ($buffer === "")
continue; continue;
if (substr($buffer, 0, 1) === ':')
$firstChar = substr($buffer, 0, 1);
$lastChar = substr($buffer, strlen($buffer) - 1, 1);
if ($firstChar === ':' && $lastChar !== ':')
array_push($props, "left"); array_push($props, "left");
elseif (substr($buffer, strlen($buffer) - 1, 1) === ':') elseif ($lastChar === ':' && $firstChar !== ':')
array_push($props, "right"); array_push($props, "right");
elseif (str_contains($buffer, ':')) elseif ($firstChar === ':' && $lastChar === ':')
array_push($props, "center"); array_push($props, "center");
else else
array_push($props, "left"); array_push($props, "left");

Loading…
Cancel
Save