Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to preserve trailing whitespace #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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