highlight.js language definition for Qt Company QML declarative language. See Qt Documentation for language details. See https://highlightjs.org/ for more information about highlight.js.
Follow instructions at highlightjs to learn how to include the library and CSS. Then include qml
as a registered language.
Mark the code you want to highlight with the qml
class:
<pre><code class="qml">...</code></pre>
or use JavaScript to dynamically highlight text:
hljs.registerLanguage('qml', window.hljsDefineQML);
var highlighted = hljs.highlightAuto(text, ["qml"]);
Include highlight.js
distribution on your webpage, get the standard highlight.js distribution and then add the QML language highlighter from this repo:
<link rel="stylesheet" href="/path/to/css/default.css">
<script src="/path/to/highlight.js/highlight.pack.js"></script>
<script src="/path/to/highlightjs-qml/qml.js"></script>
<script>
hljs.registerLanguage("qml", window.hljsDefineQML);
hljs.initHighlightingOnLoad();
</script>
const hljs = require('highlightjs');
const hljsQML = require('highlightjs-qml');
hljsQML(hljs);
hljs.initHighlightingOnLoad();
Download this repo and install the dependencies:
npm install
Update qml.js
. Be sure to update the test data input.txt
to include a test for your changes, or create a new test in qml-spec.js
. The tests must pass!
npm test
Issue a pull request.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at