From ea802aa91e40ea6150773d4c7618f450a64a8ca8 Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 22 Jul 2021 00:38:53 +0200 Subject: docs: Setup mkdocs with mkdocs-material theme This changes the framework used to generate the klipper3d site. Signed-off-by: Damien Martin --- docs/_klipper3d/mkdocs_hooks.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/_klipper3d/mkdocs_hooks.py (limited to 'docs/_klipper3d/mkdocs_hooks.py') diff --git a/docs/_klipper3d/mkdocs_hooks.py b/docs/_klipper3d/mkdocs_hooks.py new file mode 100644 index 00000000..5b122a1d --- /dev/null +++ b/docs/_klipper3d/mkdocs_hooks.py @@ -0,0 +1,18 @@ +import re + +def transform(markdown: str, page, config, files): + in_list = False + lines = markdown.splitlines() + for i in range(len(lines)): + lines[i] = lines[i].replace('](../', + f"]({config['repo_url']}blob/master/") + lines[i] = re.sub(r"\\", "
", lines[i]) + # check that lists at level 0 are not indented (no space before *|-|1.) + if len(lines[i]) == 0: + in_list = False + elif re.match(r"^(\*|-|\d+\.) ", lines[i]): + in_list = True + if not in_list: + lines[i] = re.sub(r"^\s+(\*|-|\d+\.) ", r"\1 ", lines[i]) + output = "\n".join(lines) + return output -- cgit v1.2.3-70-g09d2