make compliant with mistune update

pull/3/head
Yax 2 years ago
parent fc61c0b9c7
commit ae83dbaf80

@ -40,11 +40,11 @@ import unicodedata
from email import utils from email import utils
from pathlib import Path from pathlib import Path
import mistune
import requests import requests
import mistune
from pygments import highlight from pygments import highlight
from pygments.formatters import html
from pygments.lexers import get_lexer_by_name from pygments.lexers import get_lexer_by_name
from pygments.formatters import html
# set user locale # set user locale
locale.setlocale(locale.LC_ALL, "") locale.setlocale(locale.LC_ALL, "")
@ -52,19 +52,15 @@ locale.setlocale(locale.LC_ALL, "")
# initialize markdown # initialize markdown
class HighlightRenderer(mistune.HTMLRenderer):
class HighlightRenderer(mistune.Renderer):
options = {"escape": False, "hard_wrap": True}
def block_code(self, code, lang=None): def block_code(self, code, lang=None):
if not lang: if lang:
return "\n<pre><code>%s</code></pre>\n" % mistune.escape(code)
lexer = get_lexer_by_name(lang, stripall=True) lexer = get_lexer_by_name(lang, stripall=True)
formatter = html.HtmlFormatter() formatter = html.HtmlFormatter()
return highlight(code, lexer, formatter) return highlight(code, lexer, formatter)
return '<pre><code>' + mistune.escape(code) + '</code></pre>'
markdown = mistune.create_markdown(renderer=HighlightRenderer())
markdown = mistune.Markdown(renderer=HighlightRenderer())
def fread(filename): def fread(filename):

32
poetry.lock generated

@ -27,7 +27,7 @@ python-versions = ">=3.5"
[[package]] [[package]]
name = "mistune" name = "mistune"
version = "2.0.3" version = "2.0.4"
description = "A sane Markdown parser with useful plugins and renderers" description = "A sane Markdown parser with useful plugins and renderers"
category = "main" category = "main"
optional = false optional = false
@ -61,7 +61,7 @@ use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"]
[[package]] [[package]]
name = "urllib3" name = "urllib3"
version = "1.26.10" version = "1.26.11"
description = "HTTP library with thread-safe connection pooling, file post, and more." description = "HTTP library with thread-safe connection pooling, file post, and more."
category = "main" category = "main"
optional = false optional = false
@ -78,31 +78,19 @@ python-versions = "^3.8"
content-hash = "16357752f231675078b90f65812ed06814c93bbf28d5e2066a912c83e2566fb1" content-hash = "16357752f231675078b90f65812ed06814c93bbf28d5e2066a912c83e2566fb1"
[metadata.files] [metadata.files]
certifi = [ certifi = []
{file = "certifi-2022.6.15-py3-none-any.whl", hash = "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"}, charset-normalizer = []
{file = "certifi-2022.6.15.tar.gz", hash = "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"},
]
charset-normalizer = [
{file = "charset-normalizer-2.1.0.tar.gz", hash = "sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413"},
{file = "charset_normalizer-2.1.0-py3-none-any.whl", hash = "sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5"},
]
idna = [ idna = [
{file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"},
{file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"},
] ]
mistune = [ mistune = [
{file = "mistune-2.0.3-py2.py3-none-any.whl", hash = "sha256:e3964140c0775535fba50bd616fe180920044a64bc21850253267b07bff89924"}, {file = "mistune-2.0.4-py2.py3-none-any.whl", hash = "sha256:182cc5ee6f8ed1b807de6b7bb50155df7b66495412836b9a74c8fbdfc75fe36d"},
{file = "mistune-2.0.3.tar.gz", hash = "sha256:d7605b46b6156b53b7d52a465202b29a6f00f4ea4130ad5d25e9d5547d6b7e50"}, {file = "mistune-2.0.4.tar.gz", hash = "sha256:9ee0a66053e2267aba772c71e06891fa8f1af6d4b01d5e84e267b4570d4d9808"},
]
pygments = [
{file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"},
{file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"},
]
requests = [
{file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"},
{file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"},
] ]
pygments = []
requests = []
urllib3 = [ urllib3 = [
{file = "urllib3-1.26.10-py2.py3-none-any.whl", hash = "sha256:8298d6d56d39be0e3bc13c1c97d133f9b45d797169a0e11cdd0e0489d786f7ec"}, {file = "urllib3-1.26.11-py2.py3-none-any.whl", hash = "sha256:c33ccba33c819596124764c23a97d25f32b28433ba0dedeb77d873a38722c9bc"},
{file = "urllib3-1.26.10.tar.gz", hash = "sha256:879ba4d1e89654d9769ce13121e0f94310ea32e8d2f8cf587b77c08bbcdb30d6"}, {file = "urllib3-1.26.11.tar.gz", hash = "sha256:ea6e8fb210b19d950fab93b60c9009226c63a28808bc8386e05301e25883ac0a"},
] ]

@ -58,7 +58,6 @@ Voici le *template* Hugo des commentaires qui utilise la fonction **getJSON** po
de la page en cours : de la page en cours :
```html ```html
{% raw %}
<div id="stacosys-comments"> <div id="stacosys-comments">
{{ $restParam := (printf "/comments?token=%v&url=%v" .Site.Params.widgets.stacosys_token .URL) }} {{ $restParam := (printf "/comments?token=%v&url=%v" .Site.Params.widgets.stacosys_token .URL) }}
{{ $resp := getJSON .Site.Params.widgets.stacosys_url $restParam }} {{ $resp := getJSON .Site.Params.widgets.stacosys_url $restParam }}
@ -80,13 +79,11 @@ de la page en cours :
</p> </p>
{{ end }} {{ end }}
</div> </div>
{% endraw %}
``` ```
et un exemple de données renvoyée par Stacosys : et un exemple de données renvoyée par Stacosys :
```json ```json
{% raw %}
{ {
"data": [ "data": [
{ {
@ -103,7 +100,6 @@ et un exemple de données renvoyée par Stacosys :
} }
] ]
} }
{% endraw %}
``` ```
Il reste une interaction entre le serveur HTTP et Stacosys pour poster des Il reste une interaction entre le serveur HTTP et Stacosys pour poster des

Loading…
Cancel
Save