D18951: HTML: highlight JSX, TypeScript & MustacheJS code in the <script> tag
Nibaldo González
noreply at phabricator.kde.org
Tue Feb 12 11:38:54 GMT 2019
nibags created this revision.
nibags added reviewers: Framework: Syntax Highlighting, dhaumann, cullmann.
Herald added projects: Kate, Frameworks.
Herald added subscribers: kde-frameworks-devel, kwrite-devel.
nibags requested review of this revision.
REVISION SUMMARY
In the `<script>` tag, it will be possible to highlight JSX, TypeScript and Mustache (MustacheJS/HandlebarsJS/RactiveJS) code, according to the "type" attribute.
<script type="...">
...
</script>
For example, in `<script type="text/typescript">`, TypeScript code will be highlighted; in `<script type="text/babel">` JavaScript React will be highlighted. These highlights are activated when using the following values in the "type" attribute:
**JSX (JavaScript React):**
- text/jsx
- text/babel
**TypeScript:**
- text/typescript
**MustacheJS/HandlebarsJS/RactiveJS:**
- x-tmpl-mustache
- text/x-mustache-template
- text/x-handlebars-template
- text/ractive
By default, JavaScript highlighting is used.
The absence of highlighting for Mustache templates in HTML is mentioned in the bug #369562. I have created a new hidden language file that adds Mustache variables to JavaScript. [1][2]
Also, I made some modifications to the **data/generators/generate-php.pl** script:
- Avoid duplicate attribute "hidden" in the "language" tag.
- Avoid injecting `<IncludeRules context="FindPHP" />` after `<context ... />` (replace `/>` with `><IncludeRules context="FindPHP" /></context>`).
**References:**
- [1] Mustache.js: https://github.com/janl/mustache.js
- [2] Mustache package for Atom: https://github.com/atom/language-mustache
BUG: 369562
REPOSITORY
R216 Syntax Highlighting
BRANCH
html-script
REVISION DETAIL
https://phabricator.kde.org/D18951
AFFECTED FILES
autotests/folding/test.htm.fold
autotests/folding/test.markdown.fold
autotests/html/test.htm.html
autotests/input/test.htm
autotests/reference/test.htm.ref
data/CMakeLists.txt
data/generators/generate-php.pl
data/syntax/html.xml
data/syntax/mustache-js.xml
To: nibags, #framework_syntax_highlighting, dhaumann, cullmann
Cc: kwrite-devel, kde-frameworks-devel, gennad, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwrite-devel/attachments/20190212/364e5f7a/attachment.html>
More information about the KWrite-Devel
mailing list