-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Should kramdown treat dd
elements like other list entries?
#482
base: master
Are you sure you want to change the base?
Conversation
It should be noted that this change breaks previous CSS-based workarounds. If users never put empty lines before definitions and put the following kludge in their (S)CSS: /* Fix vertical spacing in <dd>text<p>More text</p></dd> */
dd > p:first-child { margin-top: $parskip; } Then they would have to remove that now (or change |
I find that this behavior is actually specified (source). However, my impression is that this behavior might be the reason for style rules like the |
I have introduced a boolean option
By the way, the option handling framework is really convenient. No duplicated descriptions! Thanks for that. I'd like your input on whether the proposed option semantics should, or should not, alternatively focus on that line and semantic criteria like |
By the way, I get 2838 test runs without MathjaxNode tests whereas the CI only does 2818 test runs with MathjaxNode tests included. The numbers are for Ruby 2.4. No obvious clue what the CI skips. |
Thanks for all the input - however, I need some time to think through all of it. |
Without the new option, as is the default, the first paragraph in a multi-paragraph dd entry is not marked as a :p block unless explicitly requested with an empty line before the dd entry. With the new option, having more than one paragraph in the dd entry causes the first paragraph to be p-marked as well. The explicit syntax with a preceding empty line remains available, but is only necessary for single-paragraph items with this option.
Merged changes from master, then rebased and squashed. |
This version also handles EOB-separated paragraphs inside :dd elements. Also undoes the SCSS color manipulation (fixed in separate branch)
Changed
While I was at it, I noticed that a This needs review. I have assumed that the children (created by I have verified that the generated I have also removed the color function change to |
Added more tests for the :auto_dd_para option. Take a look at
You might notice that an |
I have looked at your changes and I agree that such an option might be useful. However, I'm always cautious when the parser is involved since the generated AST should be the same for all kramdown documents regardless of set options (except the for the few parser options there are). And this option would generate a different AST. |
Yes, it is a parser option affecting the AST. It deliberately changes the grammar in order to get rid of (presumably unintented) mixed block/inline sequences. |
I'll have to update the wording in the specification to more closely match the implementation. The current (semantic) implementation is said to take effect when there are several blocks. In more visual terms, it actually takes effect when there are block boundaries before the end, which I think is the most intuitive or least surprising behavior, and perhaps the only one that thoroughly gets rid of mixed block/inline sequences. If you can think of any counterintuitive syntax cases enabled by the current implementation, I'd like to hear about that. |
Just noticed the following: $ kramdown <<EOF
$ * text
$ ^
$ text
$ EOF
<ul>
<li>text
<p>text</p>
</li>
</ul> That is, other list types actually use the lexical criterion (need blank line) instead of the semantic one (contains block boundaries). |
I have time this weekend, will take a closer look and then decide. New release will also probably be done. Thanks for your patience! |
No need to hurry this one. This auto-para branch still needs work. The current state solves most inline+block issues with |
Not sure whether this is intended behavior. It certainly irritates me:
A multi-paragraph definition does not wrap
<p>
around the first paragraph. As a consequence, the first paragraph does not get themargin-bottom
that<p>
is often styled with, as e.g. in theminima
theme used in a default Jekyll setup. Which is how I noticed the issue.Fortunately, the documentation specifies a way to explicitly request paragraph wrapping, by preceding the definition with a blank line:
But for other lists that handling is automatic. To achieve the same for definition lists, I added the following:
If I understand it correctly, the patched
elsif
branch is entered only when add
entry is continued with a non-blank source line.This patch only changes the output in cases where it previously contained a mixture of non-wrapped inline text adjacent to block elements, which supposedly should be avoided. The explicit wrapping form is still possible, but only necessary for single-paragraph items with this patch.
The kramdown documentation features 84 places where this change has an effect. I have made a diff of the resulting
htmldoc
.Unfortunately, the
htmldoc
CSS usesmargin-top
for<p>
which makes multi-paragraph definitions look bad: The definition term is spaced closer to the preceding text than to its own definition entry. But that is due to the unconditional style rule. Here is a quick fix:But note that this style change also applies to explitly paragraphed definition lists. Compare the explicitly paragraphed example in the documentation with the output after the style change. I consider this an improvement.
Yet I cannot rule out the possibility that I am trying to fix something which is not broken. Perhaps the previous behavior has all been intended to provide users with a way to mix inline with block content in
<dd>
elements? If so, please point me to some rationale. Thanks.