-
Notifications
You must be signed in to change notification settings - Fork 137
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
List item content wrapped in paragraphs #226
Comments
Thank you for putting this to our attention. |
@ndreynolds on a personal note Babelmark 2 has been a most valuable tool (and I had an Earmark dingus running for a couple of years) |
Sure, then I'll open a similar issue in ExDoc to start the discussion, and we can go from there.
I can set one up. I saw Gigalixir has a free tier, which seems like a good fit for this. It would certainly be helpful to have when testing this. Will give it a go later. |
That would just be great.
…--
Non datemi consigli che so sbagliare da solo
(Giuseppe Di Stefano)
On Sun, Mar 31, 2019 at 11:13 PM Nick Reynolds ***@***.***> wrote:
Sure, then I'll open a similar issue in ExDoc to start the discussion, and
we can go from there.
Sadly I do not have the time to setup a dingus right now, would be nice
exposure of Elixir, but time is such a sparse resource cry
I can set one up. I saw Gigalixir has a free tier, which seems like a good
fit for this. It would certainly be helpful to have when testing this. Will
give it a go later.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#226 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEldwSw3G7ejErKCsR2eG16PLpBCHAGks5vcSUKgaJpZM4cUFIY>
.
|
Backward incompatibility accepted here by @josevalim. |
@RobertDober I'd be happy to take on the challenge if you don't mind. I have some time this week. It seems like this is where I ought to start looking: https://github.com/pragdave/earmark/blob/master/lib/earmark/html_renderer.ex#L129 I'd play with it some today and try to understand what would need to be changed. |
@ndreynolds looks about the right spot. I appreciate how you handled this so far and do not mind at all if you take this on. |
I dug into this a bit more and found this in the CommonMark spec:
https://spec.commonmark.org/0.28/#loose So it's a bit more nuanced than I thought, but this is pretty clear from an implementation standpoint. I think it means we need to identify whether the list is loose or tight and then apply (or not apply) the |
Great |
Please make your PR against https://github.com/pragdave/earmark/tree/226-loose-tight-lists |
This is related to issue pragdave#226. The CommonMark spec says the following about lists: > A list is loose if any of its constituent list items are separated by > blank lines, or if any of its constituent list items directly contain > two block-level elements with a blank line between them. Otherwise a > list is tight. (The difference in HTML output is that paragraphs in a > loose list are wrapped in <p> tags, while paragraphs in a tight list > are not.) In Earmark, many lists without blank line separators are rendered as if they were loose. For example, given a nested list, the outer list is always treated as loose even when there are no blank lines. This appears to be an issue with any item that has multiple content blocks. Another issue to consider with nested lists: we need to determine whether or not a list is loose or tight at each level independently based on their direct constituents (as described above). So it's possible to have nested lists with many levels that each have varying looseness/tightness. This commit adds tests derived from the CommonMark spec to better cover these edge cases. Some are currently failing because of the problems above.
@RobertDober done, I created #229 with failing tests, so we can discuss further there if you like. |
Updates the logic for how lists are parsed and rendered to HTML to match the following specification from CommonMark: > A list is loose if any of its constituent list items are separated by > blank lines, or if any of its constituent list items directly contain > two block-level elements with a blank line between them. Otherwise a > list is tight. (The difference in HTML output is that paragraphs in a > loose list are wrapped in <p> tags, while paragraphs in a tight list > are not.) * Adds `tight` (`true`/`false`) to `%Block.List{}`. A tight list is not loose. Based on the CommonMark semantics found in the spec. * Adds `blanks` (`true`/`false`) to `%Block.ListItem{}`, which is used along with existing `spaced` field to compute `tight`. * Instead of removing `<p>` tags with a regex, adds `within_tight_list` to the `%Context{}`. This is updated whenever entering a list, and then used to decide whether or not to output the tags when a `%Block.Para{}` is rendered. * Updates parser tests with the `tight` field. * Updates test expectations in cases where a tight list has `<p>` tags. Fixes pragdave#226
Redundant to #249 |
I noticed an interesting discrepancy between Earmark and other markdown parsers I've tried. Probably related to #93, but it seems a bit different. Take the following Markdown example:
Pandoc, CommonMark, Python Markdown, and redcarpet all produce the following HTML:
whereas Earmark produces this:
You can see that Earkmark adds paragraph tags whenever the list item contains a nested list. Using this comparison tool, I only see one other implementation (Gambas) with this behavior:
http://johnmacfarlane.net/babelmark2/?text=*+Groceries%0A++*+Produce%0A++++*+Apples%0A++++*+Carrots
I noticed it because it leads to inconsistent vertical spacing in the lists in my library's documentation (using ExDoc), since
p
elements have a1em
top and bottom margin by default in most browsers. Here's a visual example from my project:In comparison to the GitHub version, the Earmark version looks very disconnected to me.
Is this something you'd be open to changing? If so, I'd be happy to try creating a PR that adjusts the output to match the other implementations.
The text was updated successfully, but these errors were encountered: