gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.86k stars 7.54k forks source link

Invalid HTML when code block with inline HTML has a newline #6570

Closed XhmikosR closed 4 years ago

XhmikosR commented 4 years ago

Sorry if this has been already reported or even fixed. I recently started looking into updating to the latest Hugo version on Bootstrap. This works fine with blackfriday but generates invalid HTML with goldmark:

<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">

      <div class="modal-header">
        <h5 class="modal-title h4" id="myLargeModalLabel">Large modal</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
    </div>
  </div>
</div>
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
<pre><code>  &lt;div class=&quot;modal-header&quot;&gt;
    &lt;h5 class=&quot;modal-title h4&quot; id=&quot;myLargeModalLabel&quot;&gt;Large modal&lt;/h5&gt;
    &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;
      &lt;span aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/span&gt;
    &lt;/button&gt;
  &lt;/div&gt;
  &lt;div class=&quot;modal-body&quot;&gt;
    ...
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

If I remove the newline after <div class="modal-content">, then it works fine with goldmark too.

moorereason commented 4 years ago

@XhmikosR, I believe Goldmark is following the CommonMark spec. See this demo of your issue from the official CommonMark site.

XhmikosR commented 4 years ago

I see, thanks. I didn't know this was invalid per the specs, and everything up until now worked. Although to be fair, I had to do some similar changes when we switched to Hugo.

Feel free to close this if you guys think it works as it should.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.