Skip to content
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

Wrong block receives attributes with attr_list #779

Closed
bitstein opened this issue Jan 19, 2019 · 1 comment
Closed

Wrong block receives attributes with attr_list #779

bitstein opened this issue Jan 19, 2019 · 1 comment
Labels
extension Related to one or more of the included extensions. invalid Invalid report (user error, upstream issue, etc). wontfix The issue will not be fixed for the stated reasons.

Comments

@bitstein
Copy link

I am trying to create blockquotes that use Bootstrap 4 classes for proper rendering. However, the attr_list is giving an inner paragraph block element the attribute rather than the entire blockquote.

Input:

> Some things are in our control and others not.
>
> <footer class="blockquote-footer">Epictetus, <em>The Enchiridion</em></footer>
{: .blockquote}

Expected output:

<blockquote class="blockquote">
  <p>Some things are in our control and others not.</p>
  <footer class="blockquote-footer">Epictetus, <em>The Enchiridion</em></footer>
</blockquote>

Actual output:

<blockquote>
<p>Some things are in our control and others not.</p>
<p class="blockquote"></p><footer class="blockquote-footer">Epictetus, <em>The Enchiridion</em></footer><p></p>
</blockquote>
@waylan
Copy link
Member

waylan commented Jan 20, 2019

This is expected behavior. Issues #227 and #312 discuss the expected behavior for lists and tables respectively.

Regarding lists I explained that:

...the markdown syntax has no concept of a ul or ol. They are simply implied by the fact that we have list items.

And tables:

...how would one differentiate between attributes defined on a row, or on a table. The syntax only defines the cells, the rows and table are inferred.

It is not possible to assign attributes to elements which don't actually exist in the document. Of course, that is not exactly true for blockquotes. The problem, however, is that lazy blockquotes are completely valid. Consider this first paragraph of and example in the Markdown rules:

> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

That is one paragraph which is wrapped in a blockquote. It does not matter that the second and third lines do not start with a angle bracket (>). Now let's add an attr_list to that:

> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
{: .blockquote}

Does that attr_list apply to the paragraph or the blockquote? It is not clear. One could argue for some variation which differentiated an attr_list applied to the blockquote and one applied to the paragraph, but the differences would be non-obvious. And that more-or-less leaves us where we are with lists and tables. And that consistency if fine by me.

From a technical standpoint, the way the extension works is that Markdown parses the document as normal, which results in the following HTML:

<blockquote>
  <p>
    This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
    consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
    Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
    {: .blockquote}
  </p>
</blockquote>

Then, the extension steps through the document and applies the attr_list to its parent element. Of course, in this case, that would be the paragraph, not the blockquote. In other words, the extension has no way of knowing if the line with the attr_list originally started with a > or not, so there is no way to change behavior based on that. Therefore, I'm inclined to not make such a change.

@waylan waylan added extension Related to one or more of the included extensions. wontfix The issue will not be fixed for the stated reasons. invalid Invalid report (user error, upstream issue, etc). labels Jan 20, 2019
@waylan waylan closed this as completed Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension Related to one or more of the included extensions. invalid Invalid report (user error, upstream issue, etc). wontfix The issue will not be fixed for the stated reasons.
Projects
None yet
Development

No branches or pull requests

2 participants