From 2de78bebbd5fc2f7681fe4923b4ed53be051ade6 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Tue, 11 Jan 2022 11:30:56 -0600 Subject: [PATCH] Added example for integration with MensBeam\HTML-DOM --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index ff0112b..3029a0f 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,18 @@ $document = new DOMDocument(); $element = MensBeam\Lit\Highlight::toElement($code, 'text.html.php', $document); ``` +Other DOM libraries which inherit from and/or encapsulate PHP's DOM such as [`MensBeam\HTML-DOM`][d] may also be used: + +```php +... +$document = new MensBeam\HTML\DOM\Document(); +// $element will be owned by $document. +$element = MensBeam\Lit\Highlight::toElement($code, 'text.html.php', $document->innerNode); +$element = $element->ownerDocument->getWrapperNode($element); +// MensBeam\HTML\DOM\Element can simply be cast to a string to serialize. +$string = (string)$element; +``` + Of course Lit can simply output a string, too: ```php