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

Some HTML <div> content wrapped in <p> unnecessarily #2247

Closed
nkalvi opened this issue Jun 26, 2015 · 5 comments
Closed

Some HTML <div> content wrapped in <p> unnecessarily #2247

nkalvi opened this issue Jun 26, 2015 · 5 comments

Comments

@nkalvi
Copy link

nkalvi commented Jun 26, 2015

F. ex.
With Pandoc 1.14.0.4

echo '<div>
 <span>test</span>
</div>' | pandoc'

results in:

<div>
<p><span>test</span></p>
</div>

where as Pandoc 1.13.0.1 produces expected output:

<div>
<span>test</span>
</div>
@jgm
Copy link
Owner

jgm commented Jun 26, 2015 via email

@nkalvi
Copy link
Author

nkalvi commented Jun 26, 2015

Thanks again @jgm for clarifying.

Yes, I can get the expected results with -f markdown-native_divs.
But I feel that having this (and native_spans) turned off by default may be better.
Some former users may see unexpected changes in some output when upgrading to 1.14.x or higher.

@jgm
Copy link
Owner

jgm commented Jun 27, 2015

I just checked: native_divs has been in pandoc since 1.13, and changing the default now would not be a good idea.

This raises the question why you're seeing a difference between 1.13.0.1 and 1.14. Clearly something changed in how native_divs behaves.

I believe this is due to 598d3ee, see #1591.
This change was in 1.13.2.

@nkalvi
Copy link
Author

nkalvi commented Jun 27, 2015

I didn't see that it was in 1.13 - yes, it's better not to change the default.

Yes, it does look like it is related to the change prompted by #1591.
While it makes sense to wrap 'plain' content inside div without requiring extra blank line,
wrapping inline elements in p seems unnecessary.

I'm sorry, I cannot see (don't know Haskell yet) from the diff in the reader why it affects only inline HTML elements. F.ex.

With the following input h1 doesn't get wrapped in <p> in the output:

<div>
  <h1>testing</h1>
</div>

while iframe in the following does:

<div>
  <iframe src="http://www.w3schools.com"></iframe>
</div>

BTW, it looks like it happens when the inline element is indented (i.e. does not start at the left margin).
Indentation doesn't seem to affect block elements.

@nkalvi nkalvi changed the title HTML block content wrapped in <p> unnecessarily Some HTML <div> content wrapped in <p> unnecessarily Jun 27, 2015
@jgm
Copy link
Owner

jgm commented Jun 28, 2015

The h1 doesn't get wrapped because this by itself would be an HTML block, not a paragraph:

<h1>testing</h1>

The iframe does get wrapped because this would not be parsed as an HTML block; the iframe tags get parsed as inline HTML:

  <iframe src="http://www.w3schools.com"></iframe>

You can check this using pandoc -t native:

[Para [RawInline (Format "html") "<iframe src=\"http://www.w3schools.com\">",RawInline (Format "html") "</iframe>"]]

Unfortunately iframe is one of those tags that can be used either in block or inline contexts. In CommonMark we're working out a better way of dealing with these, so authors will at least have the option of getting them treated as block tags.

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

2 participants