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}; }; |
|
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"> </pre> <!-- The replace the "<" 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
Does it work in comments? Let’s see.
Good. Pretty coloring. But why it doesn’t recognize “bool” as a keyword?!
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;
}
#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;
}
Is this HTML. Yes it is!
Test
int main() {return 0;}
int main() {return 0;}
Ok, I’m not getting it. It doesn’t let me pre in here.
Are you sure? It let’s me
as much as I want!
I wonder if other tags work as well with the “lang” attribute. Let’s see.
int main ()
{
return 0;
}
Obviously, that didn’t work. What’s wrong with
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
}
It seems that unregistered users can’t use some tags (all tags?) in their comments.
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
}
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;
}
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;
}
#include
using namespace std;
int main (int argc, char * argv [])
{
cout << argv[0] < 1)
return main (argc – 1, argv + 1);
else
return 0;
}
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;
}
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.
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…
[sourcecode language='cpp']
int main() {
return -1;
}
[/sourcecode]