{{ $wikiregex := "\\[\\[([^/]+?)\\]\\]" }} {{ .Scratch.Add "failed" slice }} {{ $content := "[[wikilink]]"}} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "wikilink" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Regular wikilinks" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "this is a [[wikilink]] inside some paragraph" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "this is a wikilink inside some paragraph" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Wikilinks inside paragraph" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "[[wikilink with spaces]]" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "wikilink with spaces" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Wikilinks with spaces" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "this is a [[wikilink with spaces]] inside some paragraph" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "this is a wikilink with spaces inside some paragraph" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Spaced wikilink inside paragraph" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "[[¿wikilink?]]" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "¿wikilink?" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Wikilinks with question marks" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "[[¿wikilink with spaces?]]" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "¿wikilink with spaces?" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Wikilink with question marks and spaces" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "[[wikilink:colons]]" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "wikilink:colons" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Wikilink with colons" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "[[wikilink with colons and: spaces]]" }} {{ $result := $content | replaceRE $wikiregex "$1" }} {{ $expectaction := "wikilink with colons and: spaces" }} {{ if ne $expectaction $result }} {{ .Scratch.Add "failed" "Wikilink with colons and spaces" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "t" }} {{ $regex := "." }} {{ $result := $content | findRE $regex }} {{ $result := index $result 0 }} {{ $expectaction := "t" }} {{ if ne $expectaction $result }} {{ $.Scratch.Add "failed" "Failied capturing single character with dot" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $content := "this whole sentence should be captured" }} {{ $regex := "." }} {{ $result := $content | findRE $regex }} {{ $result := index $result 0 }} {{ $expect := $content }} {{ if ne $expectaction $result }} {{ $.Scratch.Add "failed" "Whole sentence captured by dot" }} {{ partial "tests/fail.html" . }} {{ end}} {{ $content := "&¿?/'`:+$*" }} {{ $regex := "." }} {{ $expect := $content }} {{ $result := $content }} {{ if ne $expect $result }} {{ $.Scratch.Add "failed" "Capturing special characters with dot" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $target := "\\[\\[wikilink\\]\\]" }} {{ $content := "this text contains a [[wikilink]] "}} {{ $expect := "[[wikilink]]" }} {{ $result := $content | findRE $target }} {{ $result := index $result 0 }} {{ if ne $result $expect }} {{ $.Scratch.Add "failed" "Capture exact wikilink match" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $target := "\\[\\[wikilink\\?\\]\\]" }} {{ $content := "this text contains a [[wikilink?]] "}} {{ $expect := "[[wikilink?]]" }} {{ $result := $content | findRE $target }} {{ $result := index $result 0 }} {{ if ne $result $expect }} {{ $.Scratch.Add "failed" "Capture exact wikilink match" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $target := "?" }} {{ $result := $target | replaceRE "\\?" " " }} {{ $expect := " " }} {{ if ne $expect $result }} {{ $.Scratch.Add "failed" "Capturing single question mark" }} {{ partial "tests/fail.html" . }} {{ end }} {{ $target := "?" }} {{ $result := $target | replaceRE "\\?" "\\\\?" }} {{ $expect := "\\\\?" }} {{ if ne $expect $result }} {{ $.Scratch.Add "failed" "Adding escaping slashes to ? character" }} {{ partial "tests/fail.html" . }} {{ end }}