Highlight Laravel Blade & Alpine.js syntax with highlight.js.
You can see the highlight results here.
Using npm to download the library.
npm install highlight.js hightlight-blade
To use the Blade template definition with highlight.js, you have two options for importing:
Load only the language definitions you need.
// import core hljs api and required languages
import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
import xml from 'highlight.js/lib/languages/xml';
import php from 'highlight.js/lib/languages/php';
import blade from 'highlight-blade';
// register each language definition
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('xml', xml);
hljs.registerLanguage('php', php);
hljs.registerLanguage('blade', blade);
Load all languages of highlight.js, please note that this generates a large file.
import hljs from 'highlight.js';
import blade from 'highlight-blade';
hljs.registerLanguage('blade', blade);
More information about importing highlight.js library, please refer to here.
- Support Laravel Blade syntax
- Support Alpine.js syntax