From e2a944cc721c99487109d10951dbe8bf8cd93b76 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Wed, 15 Sep 2021 23:20:24 -0500 Subject: [PATCH] More readme fixes --- README.md | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 14b128a..fa60e7e 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,7 @@ # Lit # -Lit is a multilanguage syntax highlighter written in PHP. It takes code as input and returns an HTML pre element containing the code highlighted using span elements with classes based upon tokens in the code. It is loosely based upon [Atom][a]'s [Highlights][b] which is used in the Atom text editor to syntax highlight code. Atom's Highlights is in turn based upon [TextMate][c]'s syntax highlighting using its concepts of scope selectors and common keywords for components of programming languages. Lit is not a port of Atom's Highlights but instead an independent implementation of what I can understand of TextMate's grammar syntax, parsing, and tokenization by analyzing other implementations. It aims to at least have feature parity or better with Atom's highlights. - - -## Usage ## - -Here's an example of highlighting PHP code: - -```php -$code = << -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); -``` +Lit is a multilanguage syntax highlighter written in PHP. It takes code as input and returns an HTML pre element containing the code highlighted using span elements with classes based upon tokens in the code. It is loosely based upon [Atom][a]'s [Highlights][b] which is used in the Atom text editor to syntax highlight code. Atom's Highlights is in turn based upon [TextMate][c]'s syntax highlighting using its concepts of scope selectors and common keywords for components of programming languages. Lit is not a port of Atom's Highlights but instead an independent implementation of what I can understand of TextMate's grammar syntax, parsing, and tokenization by analyzing other implementations. It aims to at least have feature parity or better with Atom's Highlights. ## Documentation ## @@ -36,14 +19,28 @@ public static dW\Lit\Highlight::toElement(string $data, string $scopeName, ?\DOM #### Parameters #### -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. -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. +***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. +***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`. +## Usage ## + +Here's an example of highlighting PHP code: +```php +$code = << +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); +```