I've been looking at this problem myself. I took the formatter from
http://genisis329.googlepages.com/TWMath.html#CodeFormatter and
changed the keywords for SQL:
config.formatters.push(
{
keywords : {
"SELECT":"brown",
"WHERE":"brown",
"FROM":"brown",
"NULL":"brown",
"AS":"brown",
"WITH":"brown",
"READ":"brown",
"ONLY":"brown",
"DECODE":"darkblue",
"TO_CHAR":"darkblue",
"SUBSTR":"darkblue",
"AND":"darkblue",
"OR":"darkblue",
"|":"mediumvioletred",
"(":"mediumvioletred",
")":"mediumvioletred"
},
match: "<[Ss][Qq][Ll]>\\n",
lookahead: "<[Ss][Qq][Ll]>\\n((?:.|\\n)*?)\\n</[Ss][Qq][Ll]>",
handler : function(w)
{
var lookaheadRegExp = new RegExp(this.lookahead, "mg");
lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = lookaheadRegExp.exec(w.source);
if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
{
var e = createTiddlyElement(w.output, "pre");
var str = lookaheadMatch[1];
var Reg = /(\/\/.*?$)|(\/\*(.|\n)*?\*\/)|['] { 2 } | (
& #39; . *?
[^\\] & #39; ) | ["]{2}|(". *? [^\\]")|\w+|[\s\n]+|./mg;
var parts = str.match(Reg);
for(var i = 0; i < parts.length; i++)
{
if(parts[i].match(/^[\s\n]/)) {
parts[i] = parts[i].replace(/\t/g,"
").replace(/\n/g," <br/> ").replace(/\r/
g,"");
} else if(parts[i].match(/^(?:\/\/)|(?:\/\*)/))
{
parts[i] = " <span style =
\"color:green;\">" +
parts[i].htmlEncode().replace(/\ \n/g,"<br/>")+" ";
} else if(parts[i].charAt(0)=="\"" ||
parts[i].charAt(0) ==
"'")
{
parts[i] = "<span
style=\"color:teal;\">" +
parts[i].htmlEncode() + "</span>";
} else if(this.keywords[parts[i]])
{
parts[i] = "<span style= \"color:" +
this.keywords[parts[i]] + ";
\">" + parts[i].htmlEncode() + "</span>";
}
e.innerHTML = parts.join("");
w.nextMatch = lookaheadMatch.index +
lookaheadMatch[0].length;
}
}
}
}
);
Copy this into a tiddler, tag it with "systemConfig", and surround (in
this case) your SQL with "<sql></sql>".
It seems to really strain Firefox for large or multiple code snippets,
but it works.
If someone could shed some light on how to enbolden or italicize
within this formatter I'd be much appreciative.
Todd
On Oct 27, 11:27 am, FND <[EMAIL PROTECTED]> wrote:
> > How do I type in source code (C++, etc.) in to a tiddler so its
> > formatting is verbatim ?
>
> Also see the community wiki:
> http://www.tiddlywiki.org/wiki/TiddlyWiki_Markup#Preformatted
> http://www.tiddlywiki.org/wiki/Escaping#Wiki_Markup
>
> > Is it possible to get some syntax highlighting ?
>
> See this thread, for example:
> http://groups.google.com/group/TiddlyWiki/t/f88c3c41ae12ee5d
> Unfortunately, Syntaxify has not yet been updated for compatibility with
> the latest TW version.
>
> -- F.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---