Testing the Syntax High-Lighter

Just installed the WP-Syntax plugin. Let’s see how it works…

 
template <bool Expr>
struct StaticAssert
{
    enum {value = Expr};
};
 
template <>
struct StaticAssert<true>
{
    enum {value = true};
};
 
1
2
3
4
5
6
7
8
9
10
11
12
// Line numbers!
template <bool Expr>
struct StaticAssert
{
    enum {value = Expr};
};
 
template <>
struct StaticAssert<true>
{
    enum {value = true};
};

For future reference, I used the following HTML to put code in a post or comment. You can (and are encouraged to) too!

<pre lang="cpp|html|python|..." line="0|1">
</pre>

Or more aesthetically pleasing:

<pre lang="cpp|html|python|..." line="0|1">
&lt;/pre> <!-- The replace the "&lt;" here with "<". Do you know a way to put a "pre" closing tag inside a "pre"? -->

The supported language names are:
abap, actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp, csharp, css, d, delphi, diff, div, dos, dot, eiffel, fortran, freebasic, genero, gml, groovy, haskell, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, m68k, matlab, mirc, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, per, perl, php-brief, php, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80

VN:F [1.9.13_1145]
Rating: 8.2/10 (5 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)
Testing the Syntax High-Lighter, 8.2 out of 10 based on 5 ratings

21 Comments

  1. yzt says:

    Does it work in comments? Let’s see.

    1
    2
    3
    4
    5
    
    // Back in the days before templates, we could do this
    // for compile-time asserts (took me 3 years to come up with,
    // when I could have read 2 lines of code!)
    // Remember that a zero-sized array is illegal.
    #define STATIC_ASSERT(expr) do{ typedef char __Useless [(expr)?1:0];} while (0)
    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  2. yzt says:

    Good. Pretty coloring. But why it doesn’t recognize “bool” as a keyword?!

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  3. MatGill says:

    Ok, lets test this:

    #include
    #include
    #include
    #include

    #define min(x, y) ((x)(y)?(x):(y))

    using namespace std;

    int main() {
    #ifndef ONLINE_JUDGE
    freopen(“200.in”, “r”, stdin);
    #endif

    map<char, set > all;

    string last = “”;
    string s;

    while (cin >> s, s!= “#”) {

    int i;
    for (i = 0; i < s.size() && i < last.size() && s[i] == last[i]; i++);

    if (i < s.size() && i < last.size()) {
    all[s[i]].insert(last[i]);
    if (all.find(last[i]) == all.end())
    all[last[i]].clear();
    }

    last = s;
    }

    while(all.size()) {

    for (map<char, set >::iterator iter = all.begin(); iter != all.end(); iter++) {
    if (iter->second.size()==0) {
    char c = iter->first;
    cout << c;

    for (map<char, set >::iterator iter1 = all.begin(); iter1 != all.end(); iter1++)
    iter1->second.erase(c);

    all.erase(c);
    break;
    }
    }
    }

    cout << endl;

    #ifndef ONLINE_JUDGE
    cout << “DONE” << endl;
    while(1);
    #endif
    return 0;
    }

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  4. MatGill says:

    #include
    #include
    #include
    #include

    #define min(x, y) ((x)(y)?(x):(y))

    using namespace std;

    int main() {
    #ifndef ONLINE_JUDGE
    freopen(“200.in”, “r”, stdin);
    #endif

    map<char, set > all;

    string last = “”;
    string s;

    while (cin >> s, s!= “#”) {

    int i;
    for (i = 0; i < s.size() && i < last.size() && s[i] == last[i]; i++);

    if (i < s.size() && i < last.size()) {
    all[s[i]].insert(last[i]);
    if (all.find(last[i]) == all.end())
    all[last[i]].clear();
    }

    last = s;
    }

    while(all.size()) {

    for (map<char, set >::iterator iter = all.begin(); iter != all.end(); iter++) {
    if (iter->second.size()==0) {
    char c = iter->first;
    cout << c;

    for (map<char, set >::iterator iter1 = all.begin(); iter1 != all.end(); iter1++)
    iter1->second.erase(c);

    all.erase(c);
    break;
    }
    }
    }

    cout << endl;

    #ifndef ONLINE_JUDGE
    cout << “DONE” << endl;
    while(1);
    #endif
    return 0;
    }

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  5. MatGill says:

    Is this HTML. Yes it is!

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  6. MatGill says:

    Test

    int main() {return 0;}

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  7. MatGill says:

    int main() {return 0;}

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  8. MatGill says:

    Ok, I’m not getting it. It doesn’t let me pre in here.

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  9. yzt says:

    Are you sure? It let’s me

    p      r       e

    as much as I want!
    I wonder if other tags work as well with the “lang” attribute. Let’s see.

    // This is a “div”
    int main ()
    {
    return 0;
    }
    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  10. yzt says:

    Obviously, that didn’t work. What’s wrong with

    1
    2
    3
    4
    5
    
    // This is a "pre". View source to confirm.
    int main ()
    {
        return 0;
    }
    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  11. Testing as a not-logged in user.

    #include
    using namespace std;

    int main (int argc, char * argv [])
    {
    cout << argv[0] < 1)
    return main (argc – 1, argv + 1);
    else
    return 0
    }

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  12. It seems that unregistered users can’t use some tags (all tags?) in their comments.

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  13. nemo says:

    Hi, it’s me! Let’s see if a registered user (just typical subscription) can use “pre”.

    #include
    using namespace std;

    int main (int argc, char * argv [])
    {
    cout << argv[0] < 1)
    return main (argc – 1, argv + 1);
    else
    return 0
    }

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  14. nemo says:

    D@mn!
    I changed the role to “Contributor” instead of “Subscriber”. Let’s see…

    #include
    using namespace std;

    int main (int argc, char * argv [])
    {
    cout << argv[0] < 1)
    return main (argc – 1, argv + 1);
    else
    return 0;
    }

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  15. nemo says:

    Upped to “Author”.

    #include
    using namespace std;

    int main (int argc, char * argv [])
    {
    cout << argv[0] < 1)
    return main (argc – 1, argv + 1);
    else
    return 0;
    }

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  16. nemo says:

    #include
    using namespace std;

    int main (int argc, char * argv [])
    {
    cout << argv[0] < 1)
    return main (argc – 1, argv + 1);
    else
    return 0;
    }

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  17. yzt says:

    :-(

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    #include <iostream>
    using namespace std;
     
    int main (int argc, char * argv [])
    {
        cout << argv[0] << endl;
        if (argc > 1)
            return main (argc - 1, argv + 1);
        else
            return 0;
    }
    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  18. nemo says:

    Shadows always prevail…

    #include
    using namespace std;

    int main (int argc, char * argv [])
    {
    cout << argv[0] < 1)
    return main (argc – 1, argv + 1);
    else
    return 0;
    }

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  19. MatGill says:

    I suppose there are settings to sets that. If nothing works, try using other plugins. There is this plugin with witch you can add “code” tags.

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  20. yzt says:

    Unfortunately, if there are such settings, I can’t find them (unless I modify the code, as far as I can tell.)
    I will investigate other plug-ins when I have time, but this plugin strikes me as quite good, and more usable than others. I wonder if I can manage something with my post and comment templates…

    VN:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  21. MatGill says:

    [sourcecode language='cpp']
    int main() {
    return -1;
    }
    [/sourcecode]

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)

Leave a Reply