trentm/python-markdown2

Impossible to use stylesheets

dims12 opened this issue · 2 comments

dims12 commented

Describe the bug
Native markdown supports stylesheets while markdown2 doesn't

To Reproduce
Add stylesheet at the beginning of MD file like this

<style>
code {
    white-space:pre;
    font-family: "Lucida Console", "Courier New", monospace;
    background-color: darkblue;
    color: lightyellow;
    line-height: 1;
}
pre > code {
    display: block;
}
</style>

add some inline code and code blocks then render it.

You will see that stylessheet will be corrupted with <p> tags and pre > code will be rendered as pre &gt; code.

Expected behavior
The stylesheet should move to the rendered file as is. The block code reagions should then get pre > code style, while inline code regions should get only code style.

Can probably add an extra to ignore certain html blocks. Markdown ignores script and style tags, although I don't know whether that's extra functionality or standard.
For ease of implementation I think it would end up requiring the blocks to be formatted nicely, with opening tags on a newline and closing tags on a final newline. EG:

<script> // like this
</script>

abc <script> // and not like this
</script>

<script>
console.log('or this')</script>

Ah, I'm overthinking this. The style tag is missing from the list of block tags. script is already in there so adding style is easy