assertEquals($expected, markdown_to_bb($src));
}
private function markdown_to_bbcode_provider(): array {
return [
'empty text' => [
'',
''
],
'plain text' => [
'This is a test',
'This is a test'
],
'bold and italic' => [
'This is a test of [b]bold text[/b], [i]italic text[/i] and [b][i]bold and italic text[/i][/b]',
'This is a test of **bold text**, *italic text* and ***bold and italic text***'
],
'multiline text' => [
'This text is text wrapped over multiple lines.',
"This text is\ntext wrapped\nover multiple\nlines."
],
'text with hard linebreak' => [
"Line one\nLine two",
"Line one \nLine two"
],
'paragraphs' => [
"Paragraph one\n\nParagraph two",
"Paragraph one\n\nParagraph two",
],
'inline image' => [
'[img=https://example.com/image.jpg]https://example.com/image.jpg[/img]',
'![](https://example.com/image.jpg)'
],
'inline image with alt text' => [
'[img=https://example.com/image.jpg]Alt text[/img]',
'![Alt text](https://example.com/image.jpg)'
],
'inline code' => [
'[code]some code[/code]',
'`some code`'
],
'inline code with wrapped text' => [
'[code]some code unwrapped[/code]',
"`some code\n unwrapped`"
],
'code block no language' => [
"[code]some code\nover multiple lines[/code]",
"```\nsome code\nover multiple lines\n```"
],
'code block no language indented' => [
"[code]some code\n over multiple lines\n with indentation[/code]",
"```\nsome code\n over multiple lines\n with indentation\n```"
],
'code block with language' => [
"[code=php]<?php\necho phpinfo();[/code]",
"```php\nassertEquals($markdown, html2markdown($html));
}
public function html2markdownProvider(): array {
return [
'empty text' => [
'',
''
],
'space and nbsp only' => [
' ',
''
],
'strong, b, em, i, bib' => [
'strong bold em italic boitalicld',
'**strong** **bold** *em* *italic* **bo*italic*ld**'
],
'empty tags' => [
'text1 text2 ',
'text1 text2'
],
'HTML entities' => [
'& gt > lt <',
'& gt > lt <'
],
'escaped HTML entities' => [
'& lt < gt >',
'& lt < gt >'
],
'linebreak' => [
"line1
line2\nline3",
"line1 \nline2 line3"
],
'headlines' => [
'
somethingblah', "> something\n\nblah" ], 'code' => [ '
<p>HTML text</p>
',
'`HTML text
`' ], 'pre' => [ 'one line with spaces', "```\n one line with spaces \n```" ], 'div p' => [ '
p