yogthos / markdown-clj

Markdown parser in Clojure
Eclipse Public License 1.0
540 stars 120 forks source link

Apostrophe in URL causes parser to fail to parse automatic links #156

Open jonjanisch opened 4 years ago

jonjanisch commented 4 years ago

The automatic link parser fails if URLs contains an apostrophe.

Plain URL

The automatic link normally takes a URL like this: (md-to-html-string "Test: <https://www.google.com>")

And generates an anchor tag like this: "<p>Test: <a href=\"https://www.google.com\">https://www.google.com</a></p>"

URL with apostrophe

But if the link contains an apostrophe: (md-to-html-string "Test: <https://www.page.com/Bob's-page>")

It gets treated as plain text: "<p>Test: <https://www.page.com/Bob's-page></p>"

Alternative syntax [description](url) works fine

(md-to-html-string "Test: [https://www.page.com/Bob's-page](https://www.page.com/Bob's-page)")

"<p>Test: <a href='https://www.page.com/Bob's-page'>https://www.page.com/Bob's-page</a></p>"

I came across this while pasting some random github wiki page URLs into my app.

yogthos commented 4 years ago

Thanks for the report. I'll try take a look when I get a chance, but good to know there's a workaround in the meantime. Looks like the proper thing to do would be to consolidate the logic for handling both kinds of URL definitions.

jonjanisch commented 4 years ago

I was mistaken about [description](url) syntax working. It produces unmatched apostrophes.

"<p>Test: <a href='https://www.page.com/Bob's-page'>https://www.page.com/Bob's-page</a></p>"

If it used double quotes it would work fine:

"<p>Test: <a href="https://www.page.com/Bob's-page">https://www.page.com/Bob's-page</a></p>"

yogthos commented 4 years ago

yeah there's not escaping happening in the parser

caio-a-garcia commented 2 years ago

Hey. Clojure noob looking for an issue. Is this one up for grabs?

yogthos commented 2 years ago

It sure is :)

caio-a-garcia commented 2 years ago

Cool. I might need some help, but will dig into the code first.

yogthos commented 2 years ago

Oh yeah sure thing, I can help point you in the right direction if you get stuck on anything.