Browse Source

Minor changes to readme

main
Dustin Wilson 3 years ago
parent
commit
907df20c16
  1. 34
      README.md

34
README.md

@ -6,6 +6,24 @@
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
<?php
echo "OOK!";
?>
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);
```
## Documentation ##
### dW\\Lit\\Highlight::toElement ###
@ -27,21 +45,5 @@ encoding - If a document isn't provided an encoding may be provided for the new
Returns a `pre` `\DOMElement`.
## Usage ##
Here's an example of highlighting PHP code:
```php
$code = <<<CODE
<?php
echo "OOK!";
?>
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);
```

Loading…
Cancel
Save