bmoliveira / MarkdownKit

A simple and customizable Markdown Parser for Swift
MIT License
783 stars 136 forks source link

Fix links and parentheses don't work well together #90

Closed gaebel closed 3 years ago

gaebel commented 3 years ago

Continues #79, Fixes #78

Summary by @AndreasVerhoeven

  • we count the number of opening and closing parentheses in the link
  • if we have more closing parentheses than opening parentheses
  • AND if there are closing parentheses at the end of the link, we assume they should originally have been outside of the link and be part of the regular text

This seems to work well in practice: Almost all links with parentheses have them balanced (e.g. wikipedia links), and links surrounded by () now work correctly as well

I've fixed the merge conflicts and changed the replaceDefault method to use generics

In addition to that:

Planning to add:

benjohnde commented 3 years ago

Ah, never mind :) LGTM!