diff --git a/README.md b/README.md index 3029a0f..132310a 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,7 @@ $element = MensBeam\Lit\Highlight::toElement($code, $grammar->scopeName); * Go * Go modules * Go templates +* HTML * Java * Java expression language * Java properties diff --git a/lib/GrammarRegistry.php b/lib/GrammarRegistry.php index 2013666..630ed61 100644 --- a/lib/GrammarRegistry.php +++ b/lib/GrammarRegistry.php @@ -39,6 +39,17 @@ class GrammarRegistry { return false; } + /** + * Retrieves whether a grammar exists in the registry or not. + * + * @param string $scopeName - The scope name (eg: text.html.php) of the grammar that is being requested + * @return bool + */ + public static function has(string $scopeName): bool { + $result = array_key_exists($scopeName, self::$storage); + return $result ?: file_exists(__DIR__ . "/../data/$scopeName.json"); + } + /** * Sets a grammar in the registry. *