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

HTML block parsing in consistency #236

Closed
roydukkey opened this issue Aug 24, 2013 · 5 comments
Closed

HTML block parsing in consistency #236

roydukkey opened this issue Aug 24, 2013 · 5 comments

Comments

@roydukkey
Copy link

Here is what I don't understand: Why does marked parse some features in HTML blocks and not others?

Example 1

 <div>
 ## Markdown header
 *Markdown header*
 **Markdown header**
 </div>

Outputs

 <div>
 ## Markdown header
 <em>Markdown header</em>
 <strong>Markdown header</strong>
 </div>

Example 2

 <div>
 ## Markdown header
 *Markdown header*
 **Markdown header**
 </div>
 <script>
 var nubbin;
 </script>

Output

 <p><div></p>
 <h2 id="markdown-header">Markdown header</h2>
 <p><em>Markdown header</em>
 <strong>Markdown header</strong>
 </div></p>
 <script>
 var nubbin;
 </script>

I would like, most, to see these issues being fixed, allowing HTML blocks to be truly untouched. Then, begin further discussion on other topics like #66, #133, #115.

@chjj
Copy link
Member

chjj commented Aug 25, 2013

This:

<div>
## Markdown header
*Markdown header*
**Markdown header**
</div>

<script>
var nubbin;
</script>

Will give you the behavior you're looking for. A block-level element needs 2 line feeds after it to be recognized as a block-level element. Block-level markdown is not allowed inside block-level inline html. The problem with your second piece of markdown was, the first <div> tag was being seen as its own self-closing tag.

The author is expected to give 2 line feeds after the closing tag of their block element. It just makes it much easier to deal with nested divs. Marked could be smarter about this at the cost of performance. I'll see if I can come up with something as performant, but smarter. It's going to actually need to keep state and set up a stack with the current element on the top (the original markdown.pl does not do this at all. try giving it some nested divs and watch what happens).

@roydukkey
Copy link
Author

How about Example 1? I would consider the output incorrect. I would expect anything inside an HTML block to remain untouched.

@chjj
Copy link
Member

chjj commented Aug 25, 2013

Example 1 is correct. Only inline markdown is allowed within inline html (markdown.pl does not allow any markdown inside html, this a marked extension). I'd recommend creating separate issue for that.

@donleyp
Copy link

donleyp commented Aug 21, 2015

Is there a way to disable this "extension"?

@joshbruce
Copy link
Member

See #956

Closing as stale, please open a new issue with reference is you are still using marked and have the same request. Thank you.

@UziTech: Here's one of those moments I'm curious about regarding the continued use of marked "in the wild". Marked looks unkempt according to the cross-project PR referenced above. Having said that, the PR is still open after a year. And that project is starting show signs of either be stale, completely stable, or unused.

Given what I assume to be low usage numbers for Elm, in general, I would not be surprised. Anyway, just considering the possibilities of false positives for marked's prevalence in the wild on active projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants