From 77d8cb82b75fbbaa1fbc64adeee51798cdaf99fd Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Thu, 16 Sep 2021 08:35:21 -0500 Subject: [PATCH] More readme updates --- README.md | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 162 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 10f4949..65db393 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Lit is a multilanguage syntax highlighter written in PHP. It takes code as input ### dW\\Lit\\Highlight::toElement ### -Highlights incoming string data and outputs a PHP `\DOMElement`. +Highlights incoming string data and outputs a PHP `DOMElement`. ```php public static dW\Lit\Highlight::toElement(string $data, string $scopeName, ?\DOMDocument $document = null, string $encoding = 'windows-1252'): \DOMElement @@ -22,12 +22,12 @@ public static dW\Lit\Highlight::toElement(string $data, string $scopeName, ?\DOM ***data*** - The input data string. ***scopeName*** - The scope name (eg: text.html.php) of the grammar that's needed to highlight the input data. -***document*** - An existing `\DOMDocument` to use as the owner document of the returned `\DOMElement`; if omitted one will be created instead. +***document*** - An existing `DOMDocument` to use as the owner document of the returned `DOMElement`; if omitted one will be created instead. ***encoding*** - If a document isn't provided an encoding may be provided for the new document; the HTML standard default windows-1252 is used if no encoding is provided. #### Return Values #### -Returns a `pre` `\DOMElement`. +Returns a `pre` `DOMElement`. ## Examples ## @@ -43,10 +43,166 @@ CODE; $element = dW\Lit\Highlight::toElement($code, 'text.html.php'); // Use PHP DOM's DOMDocument::saveHTML method to print the highlighted markup. -$string = $element->ownerDocument->saveHTML($element); +echo $element->ownerDocument->saveHTML($element); ``` -An existing `\DOMDocument` may be used as the owner document of the returned pre element: +This will produce: + + +
<?php
+echo "OOK!";
+?>
+ +An existing `DOMDocument` may be used as the owner document of the returned `pre` element: ```php $code = <<