assertEquals($markdown, html2markdown($html));
}
public function html2markdownProvider() {
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, lt does not work' => [
'& gt > lt <',
'& gt > lt'
],
'escaped HTML entities' => [
'& lt < gt >',
'& lt < gt >'
],
'linebreak' => [
"line1
line2\nline3",
"line1 \nline2 line3"
],
'headlines' => [
'
header1
Header 3
',
"header1\n=======\n\n### Header 3"
],
'unordered list' => [
'',
"- Item 1\n- Item 2\n- Item **3**"
],
'ordered list' => [
'- Item 1
- Item 2
- Item 3
',
"1. Item 1\n2. Item 2\n3. Item **3**"
],
'nested lists' => [
'- Item 1
- Item 1a
- Item 1b
- Item 2
',
"- Item 1\n 1. Item 1a\n 2. Item **1b**\n- Item 2"
],
'img' => [
'',
'![alt text](/path/to/img.png "title text")'
],
'link' => [
'link',
'[link](http://hubzilla.org "Hubzilla")'
],
'img link' => [
'',
'[![alt img text](/img/hubzilla.png "img title")](http://hubzilla.org "Hubzilla")'
],
'script' => [
"",
""
],
'blockquote, issue #793' => [
'something
blah',
"> something\n\nblah"
],
'code' => [
'<p>HTML text</p>
',
'`HTML text
`'
],
'pre' => [
' one line with spaces
',
"```\n one line with spaces \n```"
],
'div p' => [
'div
',
"div
p\n\n
"
]
];
}
/*public function testHtml2markdownException() {
//$this->expectException(\InvalidArgumentException::class);
// need to stub logger() for this to work
$this->assertEquals('', html2markdown('<bold
i
';
$bb1 = 'test';
// php-mock can not mock global functions which is called by a global function.
// If the calling function is in a namespace it does work.
$bbc = $this->getFunctionMock(__NAMESPACE__, "bbcode");
$bbc->expects($this->once())->willReturn('testbold
i
');
$this->assertEquals($bb1, bb2diaspora($html1));
}
*/
}