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
Printer-friendly version
yzt | 25-Jan-08 at 1:25 am | Permalink
Does it work in comments? Let’s see.
yzt | 25-Jan-08 at 1:26 am | Permalink
Good. Pretty coloring. But why it doesn’t recognize “bool” as a keyword?!
MatGill | 25-Jan-08 at 3:08 am | Permalink
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;
}
MatGill | 25-Jan-08 at 3:10 am | Permalink
#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;
}
MatGill | 25-Jan-08 at 3:11 am | Permalink
Is this HTML. Yes it is!
MatGill | 25-Jan-08 at 3:12 am | Permalink
Test
int main() {return 0;}
MatGill | 25-Jan-08 at 3:22 am | Permalink
int main() {return 0;}
MatGill | 25-Jan-08 at 3:24 am | Permalink
Ok, I’m not getting it. It doesn’t let me pre in here.
yzt | 25-Jan-08 at 11:30 am | Permalink
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;
}
yzt | 25-Jan-08 at 11:32 am | Permalink
Obviously, that didn’t work. What’s wrong with
yzt's alter-ego | 25-Jan-08 at 1:54 pm | Permalink
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
}
yzt's alter-ego | 25-Jan-08 at 2:24 pm | Permalink
It seems that unregistered users can’t use some tags (all tags?) in their comments.
nemo | 25-Jan-08 at 2:52 pm | Permalink
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
}
nemo | 25-Jan-08 at 2:58 pm | Permalink
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;
}
nemo | 25-Jan-08 at 3:03 pm | Permalink
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;
}
nemo | 25-Jan-08 at 3:04 pm | Permalink
#include
using namespace std;
int main (int argc, char * argv [])
{
cout << argv[0] < 1)
return main (argc - 1, argv + 1);
else
return 0;
}
yzt | 25-Jan-08 at 3:05 pm | Permalink
nemo | 25-Jan-08 at 3:10 pm | Permalink
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;
}
MatGill | 25-Jan-08 at 9:29 pm | Permalink
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.
yzt | 03-Feb-08 at 10:54 am | Permalink
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…
MatGill | 07-Jun-08 at 11:56 pm | Permalink
[sourcecode language='cpp']
int main() {
return -1;
}
[/sourcecode]