func TestStringMergeSpaces(t *testing.T) { for _, td := range dataStringMergeSpaces { got := tekstus.StringMergeSpaces(td.text, true) assert(t, td.exp, got, true) } }
/* WikiText will remove URI, wiki syntax and and mark-up, multiple spaces in text and return it. */ func WikiText(text string) string { text = tekstus.StringRemoveURI(text) text = tekstus.StringRemoveWikiMarkup(text) text = strings.Replace(text, "\r\n", "\n", -1) text = strings.Replace(text, "[", " ", -1) text = strings.Replace(text, "]", " ", -1) text = strings.Replace(text, "{", " ", -1) text = strings.Replace(text, "}", " ", -1) text = strings.Replace(text, "|", " ", -1) text = strings.Replace(text, "=", " ", -1) text = strings.Replace(text, "#", " ", -1) text = strings.Replace(text, "'s", " ", -1) text = strings.Replace(text, "'", " ", -1) text = strings.Replace(text, "<ref>", " ", -1) text = strings.Replace(text, "</ref>", " ", -1) text = strings.Replace(text, "<br />", " ", -1) text = strings.Replace(text, "<br/>", " ", -1) text = strings.Replace(text, "<br>", " ", -1) text = strings.Replace(text, "<nowiki>", " ", -1) text = strings.Replace(text, "</nowiki>", " ", -1) text = strings.Replace(text, " ", " ", -1) text = strings.TrimSpace(text) text = tekstus.StringMergeSpaces(text, true) return text }