docs: Create a markdown-it plugin

This commit is contained in:
Quentin Boyer 2024-09-11 19:12:19 +02:00 committed by Matt Sturgeon
parent 6665521525
commit cab2a30ae1
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
12 changed files with 751 additions and 0 deletions

View file

@ -0,0 +1,25 @@
import pytest
from gfm_alerts_to_admonitions import gfm_alert_to_admonition
from markdown_it import MarkdownIt
@pytest.mark.parametrize("kind", ["tip", "note", "important", "warning", "caution"])
def test_parse(data_regression, kind):
input = f"> [!{kind.upper()}]\n> This is an *alert*"
md = MarkdownIt("commonmark").use(gfm_alert_to_admonition)
tokens = md.parse(input)
data_regression.check([t.as_dict() for t in tokens])
def test_case():
def make_input(kind):
return f"> [!{kind}]\n> tip"
md = MarkdownIt("commonmark").use(gfm_alert_to_admonition)
reference = [t.as_dict() for t in md.parse(make_input("TIP"))]
lower = [t.as_dict() for t in md.parse(make_input("tip"))]
mixed = [t.as_dict() for t in md.parse(make_input("tIp"))]
assert lower == reference
assert mixed == reference