-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix: escape brackets in documentation traits #401
Conversation
// KDoc comments use inline markdown. Replace square brackets with escaped equivalents so that they | ||
// are not rendered as invalid links | ||
private fun sanitize(str: String): String = str.replace(Regex("(\\[)(.*)(\\])"), "[$2]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctness: This regex won't capture nested braces or multiple braces on a line. For example:
a [ b [ c ] d ]
→a [ b [ c ] d ]
a [ b ] c [ d ]
→a [ b ] c [ d ]
This won't capture unpaired braces either, but I'm unclear if those are a problem or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unpaired braces shouldn't be a problem as far as I know since they won't be processed as inline markdown links.
732dbbb
to
00ac1ba
Compare
Issue #, if available:
fixes awslabs/aws-sdk-kotlin#153
Description of changes:
Added a new model preprocessor that sanitizes all
@documentation
traits and replaces all square bracket pairs with html escaped equivalents. Otherwise square brackets are treated as inline markdown in KDoc (which apparently can cause compile to fail if the link is an "invalid" identifier)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.