Repository navigation
miscellaneous issue52 improvements - #266
Conversation
There was a problem hiding this comment.
Hmm, I missed this before. Is this always the case? Because it is only the case some of the time in PHP Markdown Extra - which this should be emulating. For example, in PHP’s implementation a heading (h1-6) before the raw HTML block does require a blank line, while a paragraph does. I realize that the difference in the implementation has some effect on these edge cases, but I try to go with what feels less buggy. So, for example, if the document author leaves out the blank line after a paragraph, that feels more like a bug- unless, of course, the docs specifically say otherwise. Unfortunately, PHP’s docs make no mention of this requirement.
So my question to you is, did you change the behavior, or has Python-markdown always had this behavior? If this has previously Been the case, then let's leave it for now, but if not, then I'm inclined to consider this a regression and back out the changes.
There was a problem hiding this comment.
This was a requirement before my initial PR. To me, this seems like an unsurprising limitation of the blockparser, which depends on line breaks for pattern matching. Here's what I get with the official package:
No linebreak before block:
import markdown
example = """\
before
<div markdown="1" name="Example">
The text of the `Example` element.
</div>
after
"""
output = markdown.markdown(example, extensions=['extra'])
print ("""-----------------------------------------------
%s
-------------------------------------------------""") % output
Result:
-----------------------------------------------
<p>before
<div markdown="1" name="Example">
The text of the <code>Example</code> element.
</div></p>
<p>after</p>
-------------------------------------------------
Linebreak before block:
import markdown
example = """\
before
<div markdown="1" name="Example">
The text of the `Example` element.
</div>
after
"""
output = markdown.markdown(example, extensions=['extra'])
print ("""-----------------------------------------------
%s
-------------------------------------------------""") % output
Result:
-----------------------------------------------
<p>before</p>
<div name="Example">
<p>The text of the <code>Example</code> element.</p>
</div>
<p>after</p>
-------------------------------------------------
There was a problem hiding this comment.
Right, which is the exact same behavior as PHP's implementation. However, if the input is:
#before
<div markdown="1" name="Example">
The text of the `Example` element.
</div>
after
Then the output should be (because this is what PHP does):
<h1>before</h1>
<p><div markdown="1" name="Example">
The text of the <code>Example</code> element.
</div></p>
<p>after</p>
But it is actually this:
<h1>before</h1>
<p><div markdown="1" name="Example">
The text of the <code>Example</code> element.
</div></p>
<p>after</p>
So that is a bug in this implementation. My point is that it should not be a hard and fast rule that a blank line must come between a raw block and the preceding block. So the docs shouldn't document it as a rule. Of course, it could be documented as a recommendation. Perhaps something like "To avoid unexpected results, it is generally best to include a blank line before and after any raw html blocks." This doesn't make it a hard and fast rule. It still stands even if the above bug is later fixed. And it is generally good advice anyway.
There was a problem hiding this comment.
Ok, I think I understand the distinction you're making: Markdown's rules are completely external to this implementation. Anything else is a bug or recommendation.
There was a problem hiding this comment.
I'm sorry. I've been leading you the wrong way. I forgot that markdown has the following rule:
The only restrictions are that block-level HTML elements — e.g.
<div>,<table>,<pre>,<p>, etc. — must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces.
The 'markdown=1" feature is supposed to be a copy of PHP's implementation and I was checking against that. But apparently PHP's implementation goes outside markdown's syntax rules and is a little overzealous in some cases.
So yes, you were initially correct, a blank line before and after is required. However, as that is the case for all raw html blocks, whether 'markdown=1' or not, I'm not sure why we need to document it for the extension specifically. Just stating that 'any block level raw html block as defined in the syntax rules with markdown=1 will work' should be sufficient.
Again, sorry for the confusion. That's what I get for trying to respond from my mobile device.
|
Content issues aside, I hope I correctly pushed that commit. I'm still a git noob. |
|
I believe I've addressed all concerns. |
|
I finally noticed how massively I screwed up this branch the other night. I fixed it up and removed the offending lines. |
miscellaneous issue52 improvements
Just cleans up some of my previously merged code.