Exemple #1
0
func TestStringRemoveURI(t *testing.T) {
	for _, td := range dataStringRemoveURI {
		got := tekstus.StringRemoveURI(td.text)

		assert(t, td.exp, got, true)
	}
}
Exemple #2
0
/*
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, "&nbsp;", " ", -1)
	text = strings.TrimSpace(text)
	text = tekstus.StringMergeSpaces(text, true)

	return text
}