Skip to content

Issues with Blocks extensions and md_in_html #2572

@lmartellotto

Description

@lmartellotto

Description

Hello!

Help, I'm lost 😅 I don't know if it's a bug or if I just don't write correctly my code.

Context: in a .md file in a mkdocs project where pymdown-extensions is used.
It seems impossible to put HTML content in a Block Tab which is itself in a HTML div. See below the steps.

I need some help 🥺
Thanks!

Minimal Reproduction

  1. Block Tabs containing HTML tags are OK:
/// tab | STRONG
<strong>Hello i'm in a tab!</strong>
///

/// tab | P
<p>Hello i'm a p in a tab!</p>
///

Result:

<div class="tabbed-set tabbed-alternate" data-tabs="1:2" style="--md-indicator-x: 0px; --md-indicator-width: 95px;">
  <input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio">
  <input id="__tabbed_1_2" name="__tabbed_1" type="radio">
  <div class="tabbed-labels tabbed-labels--linked"><label for="__tabbed_1_1"><a href="#__tabbed_1_1" tabindex="-1">STRONG</a></label><label for="__tabbed_1_2"><a href="#__tabbed_1_2" tabindex="-1">P</a></label></div>
  <div class="tabbed-content">
     <div class="tabbed-block">
        <p><strong>Hello i'm in a tab!</strong></p>
     </div>
     <div class="tabbed-block">
        <p>Hello i'm a p in a tab!</p>
     </div>
  </div>
  <div class="tabbed-control tabbed-control--prev" hidden=""><button class="tabbed-button" tabindex="-1" aria-hidden="true"></button></div><div class="tabbed-control tabbed-control--next" hidden=""><button class="tabbed-button" tabindex="-1" aria-hidden="true"></button></div>
</div>
  1. HTML div containing HTML tags are OK:
<div class="my-div" markdown>
<strong>Hello i'm in a simple div!</strong>
<p>Hello i'm a 'p' in a simple div!</p>
</div>

Result:

 <div class="my-div">
 <p><strong>Hello i'm in a simple div!</strong></p>
 <p>Hello i'm a 'p' in a simple div!</p>
 </div>
  1. HTML div containing Block Tabs containing HTML tags are NOT OK:
<div class="my-div" markdown>

/// tab | :desktop_computer: STRONG
<strong>Hello i'm in a tab which in in a div!</strong>
///

/// tab | :desktop_computer: P
<p>Hello i'm a 'p' in a tab which in in a div!</p>
///

</div>

Result:

 <div class="my-div">
   <div class="tabbed-set tabbed-alternate" data-tabs="1:2" style="--md-indicator-x: 0px; --md-indicator-width: 95px;">
     <input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio">
     <input id="__tabbed_1_2" name="__tabbed_1" type="radio">
     <div class="tabbed-labels tabbed-labels--linked"><label for="__tabbed_1_1"><a href="#__tabbed_1_1" tabindex="-1">STRONG</a></label><label for="__tabbed_1_2"><a href="#__tabbed_1_2" tabindex="-1">P</a></label></div>
     <div class="tabbed-content">
        <div class="tabbed-block">
           <p><strong>Hello i'm in a tab!</strong></p>
        </div>
        <div class="tabbed-block">
        </div>
     </div>
     <div class="tabbed-control tabbed-control--prev" hidden=""><button class="tabbed-button" tabindex="-1" aria-hidden="true"></button></div><div class="tabbed-control tabbed-control--next" hidden=""><button class="tabbed-button" tabindex="-1" aria-hidden="true"></button></div>
   </div>
<p>Hello i'm a p in a tab!</p>
<p>///</p>
</div>

The <p> tag is outside the Block Tab, and I don't understand why. I've tried to add some space around <div> tags too.

Version(s) & System Info

  • Operating System: MacOs & Linux
  • Python Version: 3.8
  • Package Version:
    • pymdown-extensions 10.14
    • mkdocs 1.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: confirmedConfirmed bug report or approved feature request.T: bugBug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions