markdown
markdown copied to clipboard
h is singled out in parsing
I want to use this library for a changelog parser.
But while testing out the output structure of the parser, i found out, it singles out h's in text while using links or references in the text.
The following code sample is used as a baseline (dd is a function from symfony link):
class ChangelogParser extends GithubMarkdown
{
public function parseChangelog(string $text)
{
parent::prepare();
if (ltrim($text) === '') {
return '';
}
$text = str_replace(["\r\n", "\n\r", "\r"], "\n", $text);
parent::prepareMarkers($text);
$blocks = parent::parseBlocks(explode("\n", $text));
dd($blocks);
}
}
the following markdown doesn't trigger the error:
qwertzuiopüasdfghjklöäyxcvbnm
output:
^ array:1 [▼
0 => array:2 [▼
0 => "paragraph"
"content" => array:1 [▼
0 => array:2 [▼
0 => "text"
1 => "qwertzuiopüasdfghjklöäyxcvbnm"
]
]
]
]
but these do:
qwertzuiopüasdfghjklöäyxcvbnm[test](https://github.com)
output:
^ array:1 [▼
0 => array:2 [▼
0 => "paragraph"
"content" => array:5 [▼
0 => array:2 [▼
0 => "text"
1 => "qwertzuiopüasdfg"
]
1 => array:2 [▼
0 => "text"
1 => "h"
]
2 => array:2 [▼
0 => "text"
1 => "jklöäyxcvbnm"
]
3 => array:6 [▼
0 => "link"
"text" => array:1 [▼
0 => array:2 [▼
0 => "text"
1 => "test"
]
]
"url" => "https://github.com"
"title" => null
"refkey" => null
"orig" => "[test](https://github.com)"
]
4 => array:2 [▼
0 => "text"
1 => ""
]
]
]
]
qwertzuiopüasdfghjklöäyxcvbnm[test]
[test]: https://github.com
output:
^ array:1 [▼
0 => array:2 [▼
0 => "paragraph"
"content" => array:5 [▼
0 => array:2 [▼
0 => "text"
1 => "qwertzuiopüasdfg"
]
1 => array:2 [▼
0 => "text"
1 => "h"
]
2 => array:2 [▼
0 => "text"
1 => "jklöäyxcvbnm"
]
3 => array:6 [▼
0 => "link"
"text" => array:1 [▼
0 => array:2 [▼
0 => "text"
1 => "test"
]
]
"url" => null
"title" => null
"refkey" => "test"
"orig" => "[test]"
]
4 => array:2 [▼
0 => "text"
1 => ""
]
]
]
]
qwertzuiopüasdfghjklöäyxcvbnm
[test]: https://github.com
output:
^ array:1 [▼
0 => array:2 [▼
0 => "paragraph"
"content" => array:3 [▼
0 => array:2 [▼
0 => "text"
1 => "qwertzuiopüasdfg"
]
1 => array:2 [▼
0 => "text"
1 => "h"
]
2 => array:2 [▼
0 => "text"
1 => "jklöäyxcvbnm"
]
]
]
]