Beispiel #1
0
func TestStringRemoveWikiMarkup(t *testing.T) {
	for _, td := range dataStringRemoveWikiMarkup {
		got := tekstus.StringRemoveWikiMarkup(td.text)

		assert(t, td.exp, got, true)
	}
}
Beispiel #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
}