WikifyGoogleSidewikiWithGroovyorig = """ GroovyWikifyGoogleSidewiki?:
Let's WikifyGoogleSidewiki with some additional GroovyCode?. What about a '''really''' GroovyGoogleSidewiki?
This text serves for testing this GroovySnippet? which transforms a text with some typical WikiSyntax, that is not yet supported by Google's SideWiki: * CamelCase * ''ItalicizedText'' * ''' ''BoldItalicizedText'' ''' (containing '''Camel ''case'' or not''' ) * BracketLinks such as: [http://www.usemod.com/cgi-bin/mb.pl?WikifyGoogleSidewiki WikifyGoogleSidewiki] * Bold BracketLinks such as:''' [http://www.usemod.com/cgi-bin/mb.pl?WikifyGoogleSidewiki WikifyGoogleSidewiki] ''' * GoogleTagLinks? like this Tag+Tic+ Toc+
contributed by FridemarPache (CC 2009) with * CreativeCommonsAuthorCredit?, * CreativeCommonsShareAlike?, * CreativeCommonsDerivedWorksAllowed?.
"""
UrlChars?=/-a-zA-Z0-9\/:._&?/
BracketLink? = /(?:w*?)\[([$UrlChars?]+)( )(.+?)\]/
WikiWord = /(?:w*?)\b([a-zA-Z0-9_]+:)?((?:[A-Z](?:[?a-z0-9])+){2,})\b(?:w*?)/ // A WikiWord can have an optional freeform WikiPrefix
TagCombination =/(?:w*?)(([a-zA-Z0-9_]+\+)+)(?:w*?)/
GooglePrefix? = """http://google.com/search?q="
Boldizer ="""(?:''')((?s).*?)(?:''')"""
Italizer = """(?:'')((?s).*?)(?:'')"""
def markAsBold(s) {
return "<b>$s</b>"
}
def markAsItalized(s) {
return "<i>$s</i>"
}
def makeHtmlLinks(orig) {
orig.replaceAll(/$BracketLink?|$WikiWord/) {
fullMatch, a,b,c, d,e ->
/* println """
fullMatch:$fullMatch::
(a $a) (b $b) (c $c)
(d $d) (e $e)
""" */
if ((a)&&(b)&& (c)) return """<a href="$a">$c</a>"""
if (e) {
temp=(d)?d+e:e
return """<a href="$GooglePrefix$temp">$temp</a>"""
}
}
}
def boldize(orig) {
orig.replaceAll(/$Boldizer/) {
fullMatch, a ->
// println "BOLD fullMatch:$fullMatch:: (a $a)"
if (a) return ("<b>$a</b>")
} }
def italize(orig) {
orig.replaceAll(/$Italizer/) {
fullMatch, a ->
// println "fullMatch:$fullMatch:: (a $a)"
if (a) return ("<i>$a</i>")
} }
def makeTagLinks(orig) {
orig.replaceAll(/$TagCombination/) {
fullMatch, a, b ->
/* println """
fullMatch:$fullMatch::
(a $a) (b $b) EndTagLinks?
""" */
if (a)
return ("""<a href="$GooglePrefix?$a">$a</a>""")
}
}
def WikifyGoogleSidewikiWithGroovy(orig) { // println() tb=boldize(orig) ti=italize(tb) t=makeHtmlLinks(ti) s=makeTagLinks(t) println (s) }
WikifyGoogleSidewikiWithGroovy(orig)
// [GoogleSideWiki:WikifyGoogleSidewikiWithGroovy]
// [GoogleSideWiki:Result string of WikifyGoogleSidewikiWithGroovy]