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/ COPY requirements.txt /app/
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
COPY . /app/ 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", "meta",
"toc" "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): class Category(models.Model):
""" """
@ -44,6 +51,7 @@ class BlogPost(Searchable):
featured = models.BooleanField(default=False) featured = models.BooleanField(default=False)
slug = models.SlugField() slug = models.SlugField()
# TODO autodiscover new blog posts based on markdown files?
def regenerate(self): def regenerate(self):
""" """

View File

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