> ` tick around embedded javascript are included into mode, so in some
styles they are also 50% transparent
This is easily solved with excludeBegin and excludeEnd[2]. And since
CoffeeScript wants to embed JavaScript it should say `Require:
javascript.js` in the top comment, like this[3].
> functions without patrameters (like two = -> 2) is not matched
I've looked at the current function mode definition and it feels a
little bit suspicious. It doesn't seem a good idea to include param
parentheses in the the begin regexp. The submode "params" should pick it
up all by itself. This way there'd be no need in returnBegin which is
always dangerous.
Also the returnBegin in params itself looks completely unneeded.
> For Javascript/Coffeescript separation illegal "function" in default
mode may be used
This would prevent a variable named "function" which is still legal in
CoffeeScript (or is it?) Anyway it's hard to tune relevance without the
actual code snippet that is detected wrong.
[1]: https://github.com/Sannis/highlight.js/tree/dnagir-coffeescript
[2]:
http://softwaremaniacs.org/wiki/doku.php/highlight.js:mode_reference#excludebegin_excludeend
[3]:
https://github.com/isagalaev/highlight.js/blob/master/src/languages/django.js#L3
понедельник, 19 марта 2012 г. 11:57:10 UTC+4 пользователь Ivan Sagalaev написал:
There's an ongoing work on CoffeeScript support[1]. I wanted to address
Thanks a lot, Oleg! I've merged this a couple of hours ago.
I managed to unify function definitions into one and made some more
changes[1]. Now we just need to test it thoroughly.
I also wanted to note that I was wrong about the "Requires" header. It's
not strictly required for sub-languages after all. The only place where
it is used now is django.js that actually uses `hljs.LANGUAGES.xml` in
its code and this is why it needs some way to ensure that it is
available. It might be useful for coffeescript to use some data defined
in javascript.js but apparently they don't share that much to warrant
the complication.
[1]:
https://github.com/isagalaev/highlight.js/commit/5e342d8ddfedb8a34638fe7d96eb38bf3b445c69
Forgot one thing that bothered me… Right now a colon (":") is defined as
one of the delimiters between the function title and the rest of the
header so the title "cube" is highlighted in the following code:
math =
root: Math.sqrt
square: square
cube: (x) -> x * square x
This looks a bit out of place. May be it's not a good idea to highlight
inline functions within an object because it makes it inconsistent with
other keys that are not highlighted. What do you think?
I managed to unify function definitions into one and made some more
changes[1]. Now we just need to test it thoroughly.
I also wanted to note that I was wrong about the "Requires" header. It's
not strictly required for sub-languages after all. The only place where
it is used now is django.js that actually uses `hljs.LANGUAGES.xml` in
its code and this is why it needs some way to ensure that it is
available. It might be useful for coffeescript to use some data defined
in javascript.js but apparently they don't share that much to warrant
the complication.
Forgot one thing that bothered me… Right now a colon (":") is defined as
one of the delimiters between the function title and the rest of the
header so the title "cube" is highlighted in the following code:math =
root: Math.sqrt
square: square
cube: (x) -> x * square xThis looks a bit out of place. May be it's not a good idea to highlight
inline functions within an object because it makes it inconsistent with
other keys that are not highlighted. What do you think?
var math = {root: Math.sqrt,square: function (x) { return x*x; },cube: function cube (x) { return x*x*x; }};
Well, "function" is a keyword, not a title. I can't explain properly
where the difference is right now, I suppose I'm not sure myself. But it
just feels weird :-). I'll drop the colon for now and see how it goes.
It costs nothing to bring it back at any time :-).
25 марта 2012 г. 9:49 пользователь Ivan Sagalaev
<man...@softwaremaniacs.org> написал:
--
Best regards,
Oleg "Sannis" Efimov