The HTML I output doesn't have CSS. What's the reason?
Describe the bug
context my code from markdown_it import MarkdownIt from mdit_py_plugins.front_matter import front_matter_plugin from mdit_py_plugins.footnote import footnote_plugin from mdit_py_plugins.texmath import texmath_plugin md = ( MarkdownIt() .use(front_matter_plugin) .use(footnote_plugin) .use(texmath_plugin) .enable('image') .enable('table') )
all_the_text = open('markdown.md').read() tokens = md.parse(all_the_text) html_text = md.render(all_the_text)
expectation The code is highlighted and the mathematical formula is displayed normally
I checked the output HTML, no head tag, no CSS, no JS file. Why? What do I need to do?
Reproduce the bug
1.code is like this: from markdown_it import MarkdownIt from mdit_py_plugins.front_matter import front_matter_plugin from mdit_py_plugins.footnote import footnote_plugin from mdit_py_plugins.texmath import texmath_plugin md = ( MarkdownIt() .use(front_matter_plugin) .use(footnote_plugin) .use(texmath_plugin) .enable('image') .enable('table') )
all_the_text = open('markdown.txt').read() tokens = md.parse(all_the_text) html_text = md.render(all_the_text)
List your environment
No response
I checked the output HTML, no head tag, no CSS, no JS file. Why? What do I need to do?
You have to add those things. Here is a little example:
import tempfile
import webbrowser
from markdown_it import MarkdownIt
md = MarkdownIt("gfm-like")
md_text = """\
# A heading
* some
* bullets
> A quote
`inline code`, **strong**, *emphasis*, ~~struck~~
```python
# Code block
print('Hi')
```
| A | Table |
| --- | ----- |
| foo | bar |
"""
html = f"""\
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
href="https://rawcdn.githack.com/typora/typora-default-themes/fad2650fd956bab56254043a2fe1c1e80796022f/themes/github.css">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/default.min.css">
</head>
<body>
{md.render(md_text)}
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</body>
</html>
"""
with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as f:
f.write(html.encode("utf-8"))
webbrowser.open(f"file://{f.name}")
