Exemplo n.º 1
0
func TestStringMergeSpaces(t *testing.T) {
	for _, td := range dataStringMergeSpaces {
		got := tekstus.StringMergeSpaces(td.text, true)

		assert(t, td.exp, got, true)
	}
}
Exemplo n.º 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
}