func()

in renderer/asciidoctor.go [143:160]


func (adr *AsciidoctorRenderer) RenderFieldDoc(text string) string {
	// Escape the pipe character, which has special meaning for asciidoc as a way to format tables,
	// so that including | in a comment does not result in wonky tables.
	out := strings.ReplaceAll(text, "|", "\\|")

	// Trim any leading and trailing whitespace from each line.
	lines := strings.Split(out, "\n")
	for i := range lines {
		lines[i] = strings.TrimSpace(lines[i])
		// Replace newlines with hard line breaks so that newlines are rendered as expected for non-empty lines.
		// See: https://docs.asciidoctor.org/asciidoc/latest/blocks/hard-line-breaks
		if lines[i] != "" {
			lines[i] = lines[i] + " +"
		}
	}

	return strings.Join(lines, "\n")
}