SQL code in ScrewTurn Wiki: a workaround

ScrewTurn Wiki is an excellent free wiki engine that I love and that I’ve written a source code syntax highlighter plugin for.

Now some people who want to use the syntax highlighter for examples of T-SQL (Microsoft SQL Server’s dialect of SQL) encounter formatting problems when their code includes some SQL Server built-in funtions that begin with “@@”, as seen here:

PRINT 'Warning: No rows were updated';

ScrewTurn wiki delimits source code by double “@” characters. This in an unusual enough sequence that it works most of the time. But when you see how the above SQL code looks like in ScrewTurn wiki markup, you’ll see the problem:

.... text before the code block ....
PRINT 'Warning: No rows were updated';
.... text after the code block ....

ScrewTurn thinks the code block is over before “ROWCOUNT”, and that a new one begins before “…. text after”. Which makes it quite unusable for T-SQL code samples.

Now I’ve been using ScrewTurn for a while, and one thing I liked about the current version 3 was that it has a smaller set of different markup options. After all, wiki markup should primarily be easy to remember! In version 2, there were actually two ways of defining a code block: the syntax with the “@@” that’s now the only option documented for version 3, and one syntax that uses four squirly brackets, like so:

.... text before the code block ....
PRINT 'Warning: No rows were updated';
.... text after the code block ....

And guess what? That syntax still works. At least in the current version of ScrewTurn (

The four squirly brackets are not exactly equivalent to the “@@” markup; wiki markup inside the squirly code blocks are still interpreted. So to make the encoding waterproof, it’s best combined with the . The syntax highlighter plugin works with that kind of markup as well. So to get nicely formatted SQL code, I’d finally recommend this wiki markup:

.... text before the code block ....
{{{{<nowiki> sql
PRINT 'Warning: No rows were updated';
.... text after the code block ....

Does this solve the problem? How would a more intuitive solution look like? Please drop a comment!


Christian is a software architect/developer. He lives in Germany, reads a lot, and likes cycling.

Tagged with: , ,
Posted in Tools
8 comments on “SQL code in ScrewTurn Wiki: a workaround
  1. Tobias says:

    I’ve been using the four bracket+nowiki for a while, too – in fact I didn’t even know about the @@. It looks horrible and is complicated as you say. Double curlies are for inline code and you still need the nowiki tag.

    Intuitive would probably be a custom list with exceptions for the @@ tag.

    There are other things I hate about the wiki, like when you have list with sub-items and you have just one blank line between sub-items, the list is broken. The wiki should be able to guess what I wanted instead of displaying a big red warning.

    And image and file handling is a pain, I wish they’d let me upload and link to/display the image in one step in the editor. The image selector popup is okay, but a little clunky.

    I’d love if they would allow well-known BB forum tags, like [b] for bold and [i] for italic as an alternative, however I can remember the screwturn syntax for those pretty well – and you could argue that I can use HTML tags to begin with.

    My biggest pain of all is complex tables. My proverbial kingdom for a visual table editor.

    And one more thing: Last week an article got totally torn up when two people worked on it at the same time. Yes you get a warning, but it could be bigger.

    Phew, that ended up a rant – wasn’t my intention. Because as such, it’s really pretty robust.

    • Chris says:

      You’re right about tables – they are a real pain and the source of the most complaints from my users. A visual table editor would be great.

  2. David says:

    Christian, thank you for this! Even the STW forum didn’t have this answer. I’m going to post a link back to this page on the forum.

    Now I’m just going to have to figure out how to change some of the formatting to my preference. (e.g. I’d like to have functions colored in pink like SSMS, etc)

  3. David says:

    Now this is interesting, when you use the @@ symbols, SQL comments come out fine, but if you use {{{{ the SQL comments end up being wiki strike through commands and the text is crossed out

    • Christian says:

      Hi David,

      use in the &ltnowiki> tag in addition, this will disable any other wiki markup in the curly brackets. The “–” sequence that starts SQL comments is used by ScrewTurn for strikethroughs.

  4. Chris says:

    I’ll give this a try. THanks for posting this information

  5. Keith says:

    Beware if you switch to the Preview or Visual tab before saving– it will convert {{{{ to @@

  6. Sphinxy says:

    Tested, worked. Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: