Markdown import with HTML content renders weirdly

I’m trying to import by old blog to Micro.blog using the Markdown import and noticed a problem with rendering.

Here is a small version of a Markdown file that shows the problem:

---
title: "test output tracking import"
url: /writing/output-tracking-vs-mocks/
date: 2024-07-26
---
<p>In this blog post we’re going ...</p>
<h2 id="example-git-client">Example Git client</h2>
<p>The application implements two commands:</p>
<pre><code>myscm save  -&gt; git commit

myscm share -&gt; git push</code></pre>

The import modifies the pre-block: test output tracking import | Rickard Lindberg

  <article class="post-content e-content">
    <p>In this blog post we’re going ...</p>
<h2 id="example-git-client">Example Git client</h2>
<p>The application implements two commands:</p>
<pre><code>myscm save  -&gt; git commit
<p>myscm share -&gt; git push</code></pre></p>

  </article>

I would assume that it copy it verbatim.

However, if I paste the exact same file (except the front matter) in the post-box and hit preview, I get the correct result.

However, when I hist post, it renders wrong again: In this blog post we’re … | Rickard Lindberg

To me, it seems like the Markdown processor doesn’t respect thew newline in the pre-block and tries to make to separate paragraphs of it. But why doesn’t it happen in the preview?

Any suggestions as to how I can get my import to render the same would be helpful. Thanks!

Most markdown processors do not care what HTML block is there with a full blank line like that. Rather than doing pre and code by hand, I recommend doing a proper markdown code block with three back ticks then three back ticks to end.

This is just how Goldmark, the go markdown processor, works.

Right. Got it.

The problem is that not all my old posts are written in Markdown. So when I generate files from my old blog, I actually generate “pure” html in the Mardown files. I guess I could post-process the html to be Markdown-friendly.

But then I wonder if there is a way to import pure-html into Micro.blog?

When I tried to import via my RSS-feed, I got the same problem.

Although, when I read this spec, it leads me to believe that pre-tags should be handled properly for my example:

CommonMark Spec (Case 1)

But it might get confused by no newlines between the other block-types in my example.

I tried adding extra blank lines around the pre-block like this:

<p>In this blog post we’re going ...</p>
<h2 id="example-git-client">Example Git client</h2>
<p>The application implements two commands:</p>

<pre><code>myscm save  -> git commit

myscm share -> git push</code></pre>

hello

That renders correctly.

Yes that’s right. I was on my phone and didn’t notice that, but it was clear the original new line was triggering a new block.