syntax highlighting in markdown

This commit is contained in:
Christoph J. Scherr 2023-09-27 23:10:49 +02:00
parent ff231dfbc1
commit 56cd5943d2
3 changed files with 13 additions and 1 deletions

View File

@ -8,3 +8,5 @@ RUN apt update && apt install -y gettext && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY . /app/
RUN mkdir -p /app/static
RUN pygmentize -S nord -f html -a .codehilite > /app/static/codehighlight.css

View File

@ -14,7 +14,14 @@ EXTENSIONS = [
"meta",
"toc"
]
MD = markdown.Markdown(extensions=EXTENSIONS)
EXTENSION_CONFIGS = {
'codehilite': {
'linenums': True,
'pygments_style': 'monokai'
},
}
MD = markdown.Markdown(extensions=EXTENSIONS, extension_configs=EXTENSION_CONFIGS)
class Category(models.Model):
"""
@ -44,6 +51,7 @@ class BlogPost(Searchable):
featured = models.BooleanField(default=False)
slug = models.SlugField()
# TODO autodiscover new blog posts based on markdown files?
def regenerate(self):
"""

View File

@ -11,6 +11,8 @@
{% compress css %}
<link type="text/x-scss" href="/static/bs5/scss/bootstrap.scss" rel="stylesheet" media="screen">
<link rel="stylesheet" href="/static/bsi1/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="/static/codehighlight.css">
<link rel="stylesheet" href="/static/custom.css">
{% endcompress %}
<script>
const setTheme = theme => {