thephpleague / html-to-markdown

Convert HTML to Markdown with PHP
MIT License
1.77k stars 204 forks source link

Horizontal rules use non-standard format #218

Closed multiwebinc closed 2 years ago

multiwebinc commented 2 years ago

Version(s) affected

5.0.2

Description

According to https://www.markdownguide.org/basic-syntax/#horizontal-rules

To create a horizontal rule, use three or more asterisks (***), dashes (---), or underscores (___) on a line by themselves.

This library, instead, uses - - - - - -, which would appear to be non-standard from everywhere I could find.

This causes an issue (for example) with https://github.com/erusev/parsedown when you have an unordered list followed by a horizontal rule. When parsed as HTML, the <hr> is appended to an additional <li> inside the list instead of being after the list.

How to reproduce

<hr>

colinodell commented 2 years ago

This library aims to follow the CommonMark specification which as the authoritative source on valid Markdown. This spec does recognize both styles but it sounds like Parsedown might not support this spec?

Regardless, I'm not opposed to changing the output to be more friendly with non-CommonMark-compliant parsers so long as that output remains CommonMark-compliant. So if you or anyone else would like to modify that output to be --- or something similar I'd be open to accepting that PR :)

multiwebinc commented 2 years ago

Thanks @colinodell. I wasn't aware of that spec. I've therefore reported a bug in the Parsedown repo erusev/parsedown#818. Unfortunately, the code for the parser there hasn't been updated for 3 years now, so who knows...