1
0
Fork 0
mirror of https://github.com/Findus23/acronomy.git synced 2024-09-19 15:33:45 +02:00

support math in description

fixes #10
This commit is contained in:
Lukas Winkler 2020-07-06 21:04:07 +02:00
parent 0b4fb6d909
commit 074b36b2d5
Signed by: lukas
GPG key ID: 54DE4D798D244853
11 changed files with 67 additions and 4 deletions

View file

@ -91,7 +91,7 @@ AUTH_PASSWORD_VALIDATORS = [
]
LOGIN_REDIRECT_URL = "/"
LOGIN_URL = "/login/"
LOGIN_URL = "/account/login/"
LOGOUT_REDIRECT_URL = LOGIN_URL
# Internationalization

View file

@ -1,6 +1,12 @@
{% extends 'base.html' %}
{% load static %}
{% block extra_head %}
{% if "katex-display" in acro.description_html %}
<!-- Only embed katex if there is an equation on the page -->
<link rel="stylesheet" href="{% static "libs/katex.min.css" %}">
{% endif %}
{% endblock %}
{% block title %}{{ acro.name }}: {{ acro.full_name }} &dash; Acronomy{% endblock %}

View file

@ -6,9 +6,9 @@
{% block content %}
<div class="row">
<div class="row cardrow">
<div class="col-sm">
<div class="card ">
<div class="card">
<div class="card-header">
Acronyms of the Day
</div>

View file

@ -1,4 +1,5 @@
import markdown
import markdown_katex
def md_to_html(md: str) -> str:
@ -7,6 +8,7 @@ def md_to_html(md: str) -> str:
output_format="html5",
extensions=[
"nl2br",
markdown_katex.KatexExtension(insert_fonts_css=False,no_inline_svg=True),
"acros.utils.wikilinks"
]
)

View file

@ -5,6 +5,7 @@
"bootstrap": "^4.5.0",
"codemirror": "^5.54.0",
"jquery": "^3.5.1",
"katex": "^0.11.1",
"popper.js": "^1.16.1"
}
}

34
poetry.lock generated
View file

@ -284,6 +284,19 @@ version = "*"
[package.extras]
testing = ["coverage", "pyyaml"]
[[package]]
category = "main"
description = "katex extension for Python Markdown"
name = "markdown-katex"
optional = false
python-versions = ">=2.7"
version = "202006.1021"
[package.dependencies]
Markdown = ">=3.0"
pathlib2 = "*"
setuptools = "*"
[[package]]
category = "main"
description = "Rolling backport of unittest.mock for all Pythons"
@ -297,6 +310,17 @@ build = ["twine", "wheel", "blurb"]
docs = ["sphinx"]
test = ["pytest", "pytest-cov"]
[[package]]
category = "main"
description = "Object-oriented filesystem paths"
name = "pathlib2"
optional = false
python-versions = "*"
version = "2.3.5"
[package.dependencies]
six = "*"
[[package]]
category = "main"
description = "Python Imaging Library (Fork)"
@ -426,7 +450,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
testing = ["jaraco.itertools", "func-timeout"]
[metadata]
content-hash = "cdcdcb111c5b517e781302c281d1bc1af54fb423475aa09b2632b407692d155c"
content-hash = "4043edd86c5dcce243e6501dcf9cc90726c2eba313efa5341613cda12bb40735"
python-versions = ">=3.7,<4.0"
[metadata.files]
@ -585,10 +609,18 @@ markdown = [
{file = "Markdown-3.2.2-py3-none-any.whl", hash = "sha256:c467cd6233885534bf0fe96e62e3cf46cfc1605112356c4f9981512b8174de59"},
{file = "Markdown-3.2.2.tar.gz", hash = "sha256:1fafe3f1ecabfb514a5285fca634a53c1b32a81cb0feb154264d55bf2ff22c17"},
]
markdown-katex = [
{file = "markdown-katex-202006.1021.tar.gz", hash = "sha256:71d5525c8cf0510717ca79a5b80b82d2f7a1fc419333f74cfc3074429a177331"},
{file = "markdown_katex-202006.1021-py2.py3-none-any.whl", hash = "sha256:82b5fedb866f8fc2d66907d9046c936a2e7799e669b31ece99469b6e1e287de2"},
]
mock = [
{file = "mock-4.0.2-py3-none-any.whl", hash = "sha256:3f9b2c0196c60d21838f307f5825a7b86b678cedc58ab9e50a8988187b4d81e0"},
{file = "mock-4.0.2.tar.gz", hash = "sha256:dd33eb70232b6118298d516bbcecd26704689c386594f0f3c4f13867b2c56f72"},
]
pathlib2 = [
{file = "pathlib2-2.3.5-py2.py3-none-any.whl", hash = "sha256:0ec8205a157c80d7acc301c0b18fbd5d44fe655968f5d947b6ecef5290fc35db"},
{file = "pathlib2-2.3.5.tar.gz", hash = "sha256:6cd9a47b597b37cc57de1c05e56fb1a1c9cc9fab04fe78c29acd090418529868"},
]
pillow = [
{file = "Pillow-7.2.0-cp35-cp35m-macosx_10_10_intel.whl", hash = "sha256:1ca594126d3c4def54babee699c055a913efb01e106c309fa6b04405d474d5ae"},
{file = "Pillow-7.2.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:c92302a33138409e8f1ad16731568c55c9053eee71bb05b6b744067e1b62380f"},

View file

@ -19,6 +19,7 @@ gunicorn = "^20.0.4"
beautifulsoup4 = "^4.9.1"
django-bootstrap4 = "^2.0.0"
libsass = "^0.20.0"
markdown-katex = "^202006.1021"
[tool.poetry.dev-dependencies]
bpython = "^0.19"

1
static/libs/fonts Symbolic link
View file

@ -0,0 +1 @@
../../node_modules/katex/dist/fonts

1
static/libs/katex.min.css vendored Symbolic link
View file

@ -0,0 +1 @@
../../node_modules/katex/dist/katex.min.css

View file

@ -184,3 +184,10 @@ footer {
.aotd {
flex-direction: column;
}
.katex img {
display: block;
position: absolute;
width: 100%;
height: inherit;
}

View file

@ -22,11 +22,23 @@ codemirror@^5.54.0:
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.54.0.tgz#82b6adf662b29eeb7b867fe7839d49e25e4a0b38"
integrity sha512-Pgf3surv4zvw+KaW3doUU7pGjF0BPU8/sj7eglWJjzni46U/DDW8pu3nZY0QgQKUcICDXRkq8jZmq0y6KhxM3Q==
commander@^2.19.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
jquery@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
katex@^0.11.1:
version "0.11.1"
resolved "https://registry.yarnpkg.com/katex/-/katex-0.11.1.tgz#df30ca40c565c9df01a466a00d53e079e84ffaa2"
integrity sha512-5oANDICCTX0NqYIyAiFCCwjQ7ERu3DQG2JFHLbYOf+fXaMoH8eg/zOq5WSYJsKMi/QebW+Eh3gSM+oss1H/bww==
dependencies:
commander "^2.19.0"
popper.js@^1.16.1:
version "1.16.1"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"