Howto:Syntax highlighting for Nasal: Difference between revisions

Jump to navigation Jump to search
m
→‎FlightGear Wiki: isn't it just soo pretty?
(jEdit syntax file was not available anymore, re-uploaded on another server)
m (→‎FlightGear Wiki: isn't it just soo pretty?)
Line 62: Line 62:


== FlightGear Wiki ==
== FlightGear Wiki ==
A common approach in code examples on the wiki is to use php syntax highlighting beween <code>&lt;syntaxhighlight&gt;</code>:
Using the &lt;syntaxhighight&gt; tag with a lang="nasal" attribute, we can have highlighting right here on the wiki. Use enclose="div" to wrap the text, if it happens to be particularly wide.


  <nowiki><syntaxhighlight lang="php">
  <nowiki><syntaxhighlight lang="nasal">
# hello.nas
# hello.nas
print('Hello World!');
print('Hello World!');
Line 70: Line 70:


Which renders into:
Which renders into:
<syntaxhighlight lang="php">
<syntaxhighlight lang="nasal">
# hello.nas
# hello.nas
print('Hello World!');
print('Hello World!');
</syntaxhighlight>
== Syntax highlighting test ==
Just a collection of keywords, etc. to test whether highlighting works (you can copy this to test your own highlighting):
<syntaxhighlight lang="nasal">
# this is a comment
# operators (if applicable):
!a ? a+b - c/d*e : f~g;
# Builtin functions, strings
print('Hello World!');
die("We have an error, Houston!", arg[0]);
cmdarg().getNode("setting").getValue();
streq(typeof(id(keys(hash))),10);
# Loopoids
foreach (var a; ["haha", {command:"NASAL!"}, me]) {
    if(0) break;
    elsif(1) continue;
    else return;
    while(1) sprintf("%s%s\n%s=%f", "Spam", "spam", "spam", 0e-0);
    for (var i=0; i < 0.00; i += 0x0) printf("%d", int(i));
    forindex(var o; a) (func {
        var o = o;
        setlistener("/", func print(o), 1, 2);
    })();
}
# Syntax error!:
%$@&^|\`
</syntaxhighlight>
</syntaxhighlight>


395

edits

Navigation menu