Skip to content

Instantly share code, notes, and snippets.

@ryangjchandler
Last active May 13, 2022 15:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryangjchandler/f939b4105cf665e564df638d93e8c7d7 to your computer and use it in GitHub Desktop.
Save ryangjchandler/f939b4105cf665e564df638d93e8c7d7 to your computer and use it in GitHub Desktop.
`highlight.php` Laravel Blade Support
  1. Copy the contents of the blade.json file into a new resources/syntax/blade.json file, or wherever you want to place it.

  2. Add the following code snippet into your application before using highlight.php:

\Highlight\Highlighter::registerLanguage('blade', resource_path('syntax/blade.json'), true);

You should change the 2nd argument according to where you created your blade.json file.

{
"case_insensitive": true,
"subLanguage": "xml",
"contains": [
{
"className": "comment",
"begin": "\\{\\{--",
"end": "--\\}\\}"
},
{
"className": "template-variable",
"begin": "\\{\\{",
"starts": {
"end": "\\}\\}",
"returnEnd": true,
"subLanguage": "php"
}
},
{
"className": "template-variable",
"begin": "\\}\\}"
},
{
"className": "template-variable",
"begin": "\\{!!",
"starts": {
"end": "!!\\}",
"returnEnd": true,
"subLanguage": "php"
}
},
{
"className": "template-variable",
"begin": "!!\\}"
},
{
"className": "template-tag",
"begin": "@php",
"starts": {
"end": "@endphp",
"returnEnd": true,
"subLanguage": "php"
},
"relevance": 10
},
{
"begin": "@[\\w]+",
"end": "[\\W]",
"excludeEnd": true,
"className": "template-tag"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment