Insert code block in paragraph without breaking

html piece

<p>part 1</p>
<pre><code>code
</code></pre>
<p>part 2</p>

is easy to get from markdown. But is there anyway for markdown to generate something like this

<p>part 1
<pre><code>code
</code></pre>
part 2</p>

so that I can set in my css file with

p {
    text-indent: 2em;
}

to make a paragraph indent.

It’s literally not possible to make what you describe happen.

For starters, <p> elements may not contain <pre> elements per the HTML spec.

More importantly, even if you were to write <p> <pre>code</pre> </p>, browsers will turn that into*:

<p> </p>
<pre>code</pre>
<p> </p>

* or whatever the automatic tag insertion rules specify

1 Like

Thanks for your replying. After a short learn about html, I think I need to add a “class” attributes for the <p> tag which I want to make indent.

But standard Markdown seems do not directly support attributes. I have to type html manually

<p class="para">part 1</p>

    code here
part 2

leads to what I want

<p class="para">part 1</p>
<pre><code>code here
</code></pre>
<p>part 2</p>