Skip to content

Conversation

charith-elastic
Copy link

I am using my own set of templates to produce Asciidoc documents. Removing all trailing whitespace from the rendered document causes problems with Asciidoc rendering so this PR adds an option to preserve them.

It also adds a safeIdentifier template function to strip special characters from anchor identifiers. This is because some tools don't accept identifiers such as type.domain.com/v1

Also adds a `safeIdentifier` template function to strip special
characters from anchor identifiers.
@@ -601,6 +608,7 @@ func render(w io.Writer, pkgs []*apiPackage, config generatorConfig) error {
"hiddenMember": func(m types.Member) bool { return hiddenMember(m, config) },
"isLocalType": isLocalType,
"isOptionalMember": isOptionalMember,
"safeIdentifier": func(s string) string { return regexp.MustCompile("[[:punct:]]+").ReplaceAllLiteralString(s, "-") },
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unused?

@ahmetb
Copy link
Owner

ahmetb commented Dec 14, 2020

Yeah we can totally do this. The only reason we remove trailing spaces on each line is to prevent github markdown from misrendering it. I left one comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants