Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Can you mix semantic HTML and Markdown?

A topic by Wysardry created Jan 26, 2024 Views: 223 Replies: 5
Viewing posts 1 to 2

I need to be able to include semantic HTML block elements - such as SECTION - within my Markdown documents. Would this cause problems with the preview feature of Deepdwn?

I know that Python (and PHP) Markdown Extra can cope with that using special 'markdown="1"' and 'markdown="block"' attributes, but there aren't many editors with a preview that supports that and YAML front matter.

(1 edit)

Hello!

I’m not totally familiar with Python’s (or PHP’s) markdown implementation, but my understanding is that, by default, markdown will not be parsed inside block level HTML elements there.

In general, Deepdwn’s goal is to meet the commonmark spec, where that is not the case. You can read about the way that mixed HTML and markdown are handled here: https://spec.commonmark.org/0.30/#html-block.

I think the spec isn’t especially easy to understand, but you can take a look at the examples below that, that are a bit easier to understand.

That said, Deepdwn limits the HTML elements and attributes that will appear in the preview and exports. That may be an issue for you, depending on your use case.

Hope that helps!

(2 edits)

I'm hoping to use Deepdwn with Nikola, which is a static site generator written in Python. This allows the use of Python-Markdown Extra which is similar to PHP Markdown Extra.

Using either of those extensions allows the following code to interpret the markdown and HTML correctly:-

<SECTION markdown="1">
## A level two heading
A paragraph with **bold** and *italics*.
</SECTION>

It looks like you have to jump through a few more hoops to do something similar in CommonMark.

Edit: Hmm. This site seems to remove the blank line between the heading and the paragraph. Imagine there is one there.

(1 edit)

So, you can certainly use Deepdwn to write your markdown for Nikola, and it won’t prevent you from adding arbitrary HTML tags and attributes to your document, but its preview isn’t going to interpret the markdown in the same way that Nikola/Python-MarkdownExtra does.

For instance,

<SECTION markdown="1">

## A level two heading
A paragraph with **bold** and *italics*.
</SECTION>

Will be interpreted the same as

<SECTION>

## A level two heading
A paragraph with **bold** and *italics*.
</SECTION>

Because Deepdwn doesn’t consider the markdown attribute on the section at all.

Also note the empty line after the section node, this is required in commonmark to interpret the following lines as markdown, instead of more HTML.

Thanks. I'll have to experiment with Nikola to see if it will parse CommonMark style syntax correctly.

If it doesn't, I would likely be better off using an editor that supports Markdown Extra, even if it doesn't render YAML code correctly.

Do you have any plans to add the Raspberry Pi to the list of supported platforms?

Do you have any plans to add the Raspberry Pi to the list of supported platforms?

Probably not any time soon. I don’t have a good way to incorporate an ARM build into the build and deploy process for raspberry pi, or a suitable device for performance testing/optimization right now.