Dustin Wilson
3 years ago
15 changed files with 72 additions and 13 deletions
@ -0,0 +1,7 @@ |
|||
[a]: https://atom.io |
|||
[b]: https://github.com/atom/highlights |
|||
[c]: https://macromates.com |
|||
|
|||
# Fukkus # |
|||
|
|||
Fukkus is a multilanguage syntax highlighter written in PHP. It takes code as input and returns HTML 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 classes for components of programming languages. |
@ -0,0 +1,27 @@ |
|||
<?php |
|||
/** @license MIT |
|||
* Copyright 2021 Dustin Wilson et al. |
|||
* See LICENSE and AUTHORS files for details */ |
|||
|
|||
declare(strict_types=1); |
|||
namespace dW\Fukkus\Grammar; |
|||
|
|||
class Data { |
|||
public static function withFile(string $filepath): \Generator { |
|||
$fp = fopen($filepath, 'r'); |
|||
try { |
|||
while ($line = fgets($fp)) { |
|||
yield $line; |
|||
} |
|||
} finally { |
|||
fclose($fp); |
|||
} |
|||
} |
|||
|
|||
public static function withString(string $data): \Generator { |
|||
$data = explode("\n", $data); |
|||
foreach ($data as $d) { |
|||
yield $d; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
<?php |
|||
/** @license MIT |
|||
* Copyright 2021 Dustin Wilson et al. |
|||
* See LICENSE and AUTHORS files for details */ |
|||
|
|||
declare(strict_types=1); |
|||
namespace dW\Fukkus\Grammar; |
|||
|
|||
class Tokenizer {} |
@ -0,0 +1,14 @@ |
|||
<?php |
|||
/** @license MIT |
|||
* Copyright 2021 Dustin Wilson et al. |
|||
* See LICENSE and AUTHORS files for details */ |
|||
|
|||
declare(strict_types=1); |
|||
namespace dW\Fukkus; |
|||
|
|||
class Highlighter { |
|||
public static function highlightString(string $string): string { |
|||
$data = Grammar\Data::fromString($string); |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue