git push fixed link handling

feature/tests
Michael Ochmann 3 years ago
parent 98b72d96c1
commit 2c00ed8b4a
  1. 2
      README.md
  2. 8
      src/Parser.php

@ -33,7 +33,7 @@ A simple paragraph can contain **bold text**, `inline codeblocks` and *italic te
or via reference to [a later defined url][massivedynamic], i we so desire.
```
A simple paragraph can contain **bold text**, `inline codeblocks` and *italic text*. We can also link [with a direct url][https://google.com] *(i.e. to google)*
A simple paragraph can contain **bold text**, `inline codeblocks` and *italic text*. We can also link [with a direct url](https://google.com) *(i.e. to google)*
or via reference to [a later defined url][massivedynamic], i we so desire.
### Images

@ -119,19 +119,19 @@ class Parser {
$rbracket = $this->consume();
$consumption++;
if ($this->current()->type !== TokenType::LBRACKET) {
if ($this->current()->type !== TokenType::LBRACKET && $this->current()->type !== TokenType::LPAREN) {
$this->pointer -= $consumption;
return null;
}
$lbracket = $this->consume();
$lbracketOrParen = $this->consume();
$index = "";
while (!($this->current()->type === TokenType::RBRACKET || $this->current()->type === TokenType::EOL))
while (!($this->current()->type === TokenType::RBRACKET || $this->current()->type === TokenType::RPAREN || $this->current()->type === TokenType::EOL))
$index .= $this->consume()->data;
$rbracket = $this->consume();
$elm = $this->document->createElement("a", $text);
$href = str_starts_with($index, "http") ? $index :
$href = $lbracketOrParen->type === TokenType::LPAREN ? $index :
(array_key_exists($index, $this->references) ? $this->references[$index] : self::MAGIC_CHAR.$index.self::MAGIC_CHAR);
$elm->setAttribute("href", $href);

Loading…
Cancel
Save