Repository: trentm/python-markdown2 (language: python)

Issue:
Impossible to use stylesheets
**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.




Discussion / hints:
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:
```html
<script> // like this
</script>

abc <script> // and not like this
</script>

<script>
console.log('or this')</script>
```

Fix patch:
diff --git a/CHANGES.md b/CHANGES.md
index dc355cee..38983901 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,7 +2,7 @@
 
 ## python-markdown2 2.4.11 (not yet released)
 
-(nothing yet)
+- [pull #524] Fix angles being escaped in style blocks (issue #523)
 
 
 ## python-markdown2 2.4.10
diff --git a/lib/markdown2.py b/lib/markdown2.py
index 686fe29e..87b9858c 100755
--- a/lib/markdown2.py
+++ b/lib/markdown2.py
@@ -715,7 +715,7 @@ def _detab(self, text):
     # _block_tags_b.  This way html5 tags are easy to keep track of.
     _html5tags = '|article|aside|header|hgroup|footer|nav|section|figure|figcaption'
 
-    _block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del'
+    _block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style'
     _block_tags_a += _html5tags
 
     _strict_tag_block_re = re.compile(r"""


Test patch:
diff --git a/test/tm-cases/script-and-style-blocks.html b/test/tm-cases/script-and-style-blocks.html
new file mode 100644
index 00000000..a855b8ba
--- /dev/null
+++ b/test/tm-cases/script-and-style-blocks.html
@@ -0,0 +1,13 @@
+<script>
+    if (1 > 2) {
+        console.log('<p>abcdef</p>');
+    }
+</script>
+
+<style>
+    pre > code {
+        font-family: 'Comic Sans MS';
+    }
+</style>
+
+<p>Some other text</p>
diff --git a/test/tm-cases/script-and-style-blocks.text b/test/tm-cases/script-and-style-blocks.text
new file mode 100644
index 00000000..73c508e7
--- /dev/null
+++ b/test/tm-cases/script-and-style-blocks.text
@@ -0,0 +1,13 @@
+<script>
+    if (1 > 2) {
+        console.log('<p>abcdef</p>');
+    }
+</script>
+
+<style>
+    pre > code {
+        font-family: 'Comic Sans MS';
+    }
+</style>
+
+Some other text