Beispiel #1
0
// LinebreaksToSpaces will reduce all newlines into spaces.
func LinebreaksToSpace(s string) string {
	s = strdel.TrailingSpaces(s)

	multiLinebreak := `(\r\n|\n)+`
	regMultiLinebreak := regexp.MustCompile(multiLinebreak)
	s = regMultiLinebreak.ReplaceAllString(s, " ")

	return s
}
Beispiel #2
0
// BrHtmlTagToLatexLinebreak will transform all br tags into latex \\
// linbreaks..
func BrHtmlTagToLatexLinebreak(s string) string {
	s = strdel.TrailingSpaces(s)

	br := `<br>|<br\/>`
	regBr := regexp.MustCompile(br)
	s = regBr.ReplaceAllString(s, ` \\ `)

	return s
}
Beispiel #3
0
// LinebreaksToTwoLinebreaks will reduce all multiple newlines into 2
// newlines.
func LinebreaksToTwoLinebreaks(s string) string {
	s = strdel.TrailingSpaces(s)

	//s = strings.Replace(s, " \n", "\n", -1)
	//s = strings.Replace(s, "\t\n", "\n", -1)
	//s = strings.Replace(s, "\f\n", "\n", -1)
	//s = strings.Replace(s, "\r\n", "\n", -1)

	// trim multipple linebreaks to two linebreaks
	multiLinebreak := `(\r\n|\n){3,}`
	regMultiLinebreak := regexp.MustCompile(multiLinebreak)
	s = regMultiLinebreak.ReplaceAllString(s, "\n\n")

	//s = strings.Replace(s, "\n\n\n\n\n\n\n\n\n", "\n\n", -1)
	//s = strings.Replace(s, "\n\n\n\n\n\n\n\n", "\n\n", -1)
	//s = strings.Replace(s, "\n\n\n\n\n\n\n", "\n\n", -1)
	//s = strings.Replace(s, "\n\n\n\n\n\n", "\n\n", -1)
	//s = strings.Replace(s, "\n\n\n\n\n", "\n\n", -1)
	//s = strings.Replace(s, "\n\n\n\n", "\n\n", -1)
	//s = strings.Replace(s, "\n\n\n", "\n\n", -1)

	return s
}