Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR correctly formats the Markdown in #13, but creates (uncovers?) an issue with escaped square brackets in the label. I didn't want to change other code, so I've added six round-trip-failure exceptions, just to prove that at least reference links print correctly.
The new issue arises with input like:
being formatted and printed as:
A guard clause at the top of normalizeLabel sees the bracket in
ref\[(from parseLinkLabel) as invalid and returns the empty string, so the link (and title) are mapped to the empty string in the links map; and my code also tries to associate the parsed link with the empty string:markdown/link.go
Lines 398 to 405 in 868a055
Removing that guard allows those six tests to pass, along with the new ref-link tests, and doesn't affect any other test.
Given that parseLinkLabel allows escaped brackets (I believe it allows all escaped chars), can a label with a bracket be used as a key?
Removing that guard clause also makes the BigTest/nested_brackets test take about 5s on my machine to run. Does that test mean anything, given that there's a 999-char limit on a label?
I'd be happy to reconsider my approach my to reference links.
I also saw a TODO in normalizeLabel about using the normalized label only as a key in the links map, and printing the original label. If that work fits in the scope of this issue/PR, I'd work on that.
Thanks.