Well it would but first things first… VERY nice. I really like the DominoWiki – the wiki is really easy to install, configure and work with. I think I’ll introduce the other guys at the office to the concept.
|
After proper credit has been given let me get back to the initial focus of the post. The wiki should mainly be used to share code examples within my team of developers but I like code to look like code which it doesn’t when you just paste it into DominoWiki. My first and obvious problem was that all datatypes showed up as WikiWords. This is understandable due to their CamelCase nature. The fix was easy though – enclose all code in the <nowiki> tag which basically tells DominoWiki not to parse the text. Nice. This a new problem emerged – the code was displayed using the same font as the rest of the text. This made it hard to read and see what was introduction and what was code. Hmmm… Using the <code> HTML tag inside the <nowiki> tag helped me there. I now had nice Courier formatted code. But wait a minute… Didn’t Julian Robichaux do a script library for converting LotusScript code into HTML so it would display on the web like it does in the Domino Designer. Well I believe he did. 🙂 I went and fetched the code and hacked a little at the WikiPage.class script library. Now I can embed the <lotusscript> tag inside a <nowiki> tag and have nice formatted LotusScript in my wiki.
Really nice if I have to say so myself. |
(Click image to open a bigger version) |
Below is the patched version of the wikiFormat method from the WikiPage.class script library (remember to also get the ls2html script library from http://www.nsftools.com (I had to make small tweaks to the library to make it compile under Notes 6.5.4). The code has been formatted with ls2html – what else… 🙂
.lotusscript { font-family: courier; font-size: 9pt; color: black; }
.ls-comment { color: green; }
.ls-quote { color: black; }
.ls-datatype { color: black; }
.ls-operator { color: blue; }
.ls-keyword { color: blue; }
.ls-statement { color: blue; }
.ls-function { color: blue; }
.ls-class { color: black; }
.ls-constant { color: purple; }
Public Function wikiFormat (txt As String) As String '** call all of the wiki formatting functions, in a somewhat specific '** order (we also need to ignore anything in a <nowiki></nowiki> '** block, so you'll see the logic for that in here as well) Dim s1 As String, s2 As String, s3 As String, s4 As String Dim a1 As Variant Dim i As Integer Dim pos As Long Dim style As StyleDef Const NOWIKI_START = "&lt;nowiki&gt;" Const NOWIKI_END = "&lt;/nowiki&gt;" Const LS_START = "&lt;lotusscript&gt;" Const LS_END = "&lt;/lotusscript&gt;" 'create default style as I like it (using courier for code) Call GetDefaultLsStyleDef(style) style.script = "font-family: courier,sans-serif; font-size: 9pt; color: black;" '** convert rn linefeeds to just n s1 = parseLinefeeds(txt) '** remove all user-entered HTML from the page s1 = removeHTML(s1) '** ignore things that are within <nowiki></nowiki> sections a1 = Split(s1, NOWIKI_START, -1, 5) For i = 0 To Ubound(a1) If (i = 0) Then '** text before the first <nowiki> tag (if any), so we need to '** parse the whole block of text s1 = a1(i) s2 = "" Else '** check to see if there's a </nowiki> tag in here anywhere; '** if there is, we only want to parse everything after it, but if '** there's not we have to assume that all the text in this block '** is inside of the <nowiki> block, so we'll ignore everything '** in that case. pos = Instr(1, a1(i), NOWIKI_END, 5) If (pos > 0) Then s1 = Mid(a1(i), pos + Len(NOWIKI_END)) s2 = Left(a1(i), pos - 1) Else s1 = "" s2 = a1(i) End If End If s1 = parseWikiWords(s1) s1 = parseLists(s1) s1 = parseRules(s1) '** it's possible that the user would expect us to only look for '** bold, italic, and header matches along a single line. If that's '** the case, you can adjust the matchCondition filter. matchCondition = "*" matchCriteria = True 'matchCondition = "*[" & chr(10) & "]*" ' on a single line only 'matchCriteria = False s1 = parseBold(s1) s1 = parseItalics(s1) s1 = parseHeaders(s1) s1 = parseMonospace(s1) '** parse anything inside of single or double brackets ( [ ] or [[ ]] ) s1 = parseBrackets(s1) s3 = s3 & s2 & s1 Next a1 = Split(s3, LS_START, -1, 5) For i = 0 To Ubound(a1) If (i = 0) Then '** text before the first <lotusscript> tag - just add it to the '** result string s4 = s4 & a1(i) Else '** check to see if there's a </lotusscript> tag in here anywhere; '** if there is, we only want to get the text before it, but if '** there's not we have to assume that all the text in this block '** is inside of the <lotusscript> block, so we'll get all remaining '** text in that case. pos = Instr(1, a1(i), LS_END, 5) If (pos > 0) Then '** there is a </lotusscript> tag s1 = Mid(a1(i), pos + Len(LS_END)) 'text after the ending tag s2 = Left(a1(i), pos - 1) 'text before the ending tag Else '** no stop tag - get rest of text s1 = "" s2 = a1(i) End If '** convert s2 using lotusscript2html s2 = ConvertStringEx(s2, style, False) '** add to s4 s4 = s4 & s2 & s1 End If Next s3 = s4 '** a few additional fixes s3 = fixAmp(s3) s3 = fixRelativeLinks(s3) '** put back any "safe" HTML that was fixed s3 = allowSafeHTML(s3) '** convert linefeeds to <p> or <br> s3 = parseParas(s3) wikiFormat = s3 End Function
