parsedown-extra icon indicating copy to clipboard operation
parsedown-extra copied to clipboard

List Item is dropping text that follows a custom tag

Open nicholasbrantley opened this issue 4 years ago • 2 comments

- <test></test> helloworld

This should render like this:

  • <test></test> helloworld

However it is rendering like this:

  • <test></test>

Dropping the "helloworld".

nicholasbrantley avatar Sep 12 '21 06:09 nicholasbrantley

Follow up, the issue seems to be in the processTag function. Not sure what part is causing it yet.

nicholasbrantley avatar Sep 14 '21 05:09 nicholasbrantley

$DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild); This method meant to remove the html and body tags is causing sibling tags to get dropped.

If you have a list like this:

- <tag1></tag1> <tag2></tag2>

It will strip tag2 because it is replacing the firstchild (<html>) with the firstChild (<tag>) of the firstChild (<body>) of the firstChild(<html>). This is not good. It should be working like this:

$DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->childNodes, $DOMDocument->firstChild); However this replaceChild method doesn't accept an array of nodes.

Is this literally the only way to strip the <html> and <body> tags from the DOMDocument?

nicholasbrantley avatar Sep 15 '21 06:09 nicholasbrantley