Improving syntax highlighting for QML
-
[quote author="unclewerner" date="1302181004"]The devnet is using "this highlighter":http://alexgorbatchev.com/SyntaxHighlighter/ ?[/quote]
Yes, that is correct. Our version is plain vanilla, no custom hacks.
-
Thanks for the info! I will see then if I can fix the highlighter.
-
[quote author="unclewerner" date="1302185614"]Thanks for the info! I will see then if I can fix the highlighter.[/quote]
That would be awesome unclewerner, I can offer you 400 all virtual devnet points as a bounty for your effort if you share it with us and Alex Gorbatchev :)
-
I looked again into the highlighter. For starters it would be nice to select the "brush". JavaScript is already there, but cannot be selected (or at least I don't know how). When I look at the HTML code generated by the wiki, everything seems to be highlighted using the C++ brush by default. Maybe allow selection of "c++", "js", "python" and "qml" somehow? QML could be mapped to css for starters, the others are already supported by the highlighter.
-
Since we have a single code tag (@) we have used the C++ as a base and added Qt classes on our own. Our goal is to make it simple, hence only one code tag.
We are cool with setting the syntax highlight standard much lower than in an IDE, since this is just a web page after all. It simply needs to give the viewer the overview of the code snippet, not the IDE use-cases of syntax highlighting.
We have been pondering on making Qt classes auto-link to the relevant page in documentation though...
-
I see. But it looks quite uggly because JavaScript has different keywords. I would really like to see an option to select the language.
Maybe like this:
@
[[code:qml]]
%
MyComponent {
id: smth
width: other.width * 2
}
%
@It's OK to have the Qt class name hacks with all the languages.
-
The @ tag can only take one brush, to add additional tags for syntax highlighting is not something we can do quickly. We have some experimental work on [ code ] (without the spaces, try it) and I guess this can fit the bill, but it's not ready yet. Then we could have [code brush=js] (with "qml" and "quick" as aliases for "js").
Edit: or [code:qml] as suggested in your edit :)
-
OK, let's see...
[code]
var f = function() { return 0; }, s = "abc\n" // commentQt.point(0.,0.)
MyComponent {
id: smth
width: 2 * other.width
}
[/code]Looks like a generic highlighter. Nice.
-
[quote author="mariusg" date="1302265389"]
We have been pondering on making Qt classes auto-link to the relevant page in documentation though...[/quote]I was wondering if this would be possible. It would be especially cool to have once the docs come under QtDN too.