From 58149abb7af44ad5340c24b8477eb8eb58e511c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:15:10 +0200 Subject: [PATCH 01/70] Enable custom fence with attr_list --- mkdocs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index caed243a..bf24296c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -22,12 +22,16 @@ markdown_extensions: - name: mermaid class: mermaid-experimental format: !!python/name:pymdownx.superfences.fence_code_format + - name: ponylang + class: ponylang + format: !!python/name:pymdownx.superfences.fence_code_format - pymdownx.snippets: base_path: ['code-samples'] check_paths: true - smarty - toc: permalink: true + - attr_list plugins: - search From 21ff2376a3d7775272386df2e8d5bd22f676fdd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:16:34 +0200 Subject: [PATCH 02/70] Modify example --- docs/getting-started/hello-world.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/hello-world.md b/docs/getting-started/hello-world.md index 09cdcc1b..fc9e8c50 100644 --- a/docs/getting-started/hello-world.md +++ b/docs/getting-started/hello-world.md @@ -17,7 +17,7 @@ __Does the name of the file matter?__ Not to the compiler, no. Pony doesn't care In your file, put the following code: -```pony +```ponylang snippet="hello-world-main.pony:1-3,5" dedent_subsections=false --8<-- "hello-world-main.pony" ``` From 44f84ad3181a5ac3df27f2c329ae53cbf884f3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:54:27 +0200 Subject: [PATCH 03/70] Test --- docs/getting-started/hello-world.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/hello-world.md b/docs/getting-started/hello-world.md index fc9e8c50..4e0e8acb 100644 --- a/docs/getting-started/hello-world.md +++ b/docs/getting-started/hello-world.md @@ -17,7 +17,7 @@ __Does the name of the file matter?__ Not to the compiler, no. Pony doesn't care In your file, put the following code: -```ponylang snippet="hello-world-main.pony:1-3,5" dedent_subsections=false +```ponylang snippet="hello-world-main.pony:1-3,6" dedent_subsections=false --8<-- "hello-world-main.pony" ``` From 7dad144c69920311febe7aee804ccf646273a9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:01:45 +0200 Subject: [PATCH 04/70] Ignore wayback machine timeout for now --- mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/mkdocs.yml b/mkdocs.yml index bf24296c..c0d0cefe 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -41,6 +41,7 @@ plugins: raise_error_excludes: 429: ["https://github.com/ponylang", "https://web.archive.org/*"] 404: ["https://github.com/ponylang"] + 504: ["https://web.archive.org/*"] theme: name: material From 857800f19f54821ff9f12b904af7adbdca4b88d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:13:07 +0200 Subject: [PATCH 05/70] Add keywords to spellcheck exceptions --- .spelling-wordlist.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.spelling-wordlist.txt b/.spelling-wordlist.txt index 9b45ba8d..1e6c08e1 100644 --- a/.spelling-wordlist.txt +++ b/.spelling-wordlist.txt @@ -10,6 +10,7 @@ booleans capybaras combinators compilable +dedent dereference deserialise deserialised @@ -52,6 +53,7 @@ polymorphism ponyc PonyCheck Ponylang +ponylang PonyTest POSIX preprocessor From f1645184093c9513a955d43c018b1394ae1cb0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:14:43 +0200 Subject: [PATCH 06/70] use attr_list style code fences --- docs/getting-started/hello-world.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/hello-world.md b/docs/getting-started/hello-world.md index 4e0e8acb..a93b3dc0 100644 --- a/docs/getting-started/hello-world.md +++ b/docs/getting-started/hello-world.md @@ -17,7 +17,7 @@ __Does the name of the file matter?__ Not to the compiler, no. Pony doesn't care In your file, put the following code: -```ponylang snippet="hello-world-main.pony:1-3,6" dedent_subsections=false +```{ .ponylang snippet="hello-world-main.pony:1-3,6" dedent_subsections=false } --8<-- "hello-world-main.pony" ``` From a0ca842c39a31c0e858798cf838444fd64601b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:26:58 +0200 Subject: [PATCH 07/70] Use standard pony syntax highlight --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index c0d0cefe..71fc8af9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -23,7 +23,7 @@ markdown_extensions: class: mermaid-experimental format: !!python/name:pymdownx.superfences.fence_code_format - name: ponylang - class: ponylang + class: pony format: !!python/name:pymdownx.superfences.fence_code_format - pymdownx.snippets: base_path: ['code-samples'] From 7a946195c3c57955398d746f0956fa185c2a78ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:33:13 +0200 Subject: [PATCH 08/70] Custom fences formatter and validator --- lib/superfences_ponylang/__init__.py | 5 +++++ mkdocs.yml | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 lib/superfences_ponylang/__init__.py diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py new file mode 100644 index 00000000..2da0e8cb --- /dev/null +++ b/lib/superfences_ponylang/__init__.py @@ -0,0 +1,5 @@ +def custom_formatter(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): + return '
%s
' % (language, class_name, options['opt'], html_escape(source)) + +def validate(language: str, options: dict) -> bool: + return True # TODO allowed attributes and values \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 71fc8af9..93f87ac4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,7 +24,8 @@ markdown_extensions: format: !!python/name:pymdownx.superfences.fence_code_format - name: ponylang class: pony - format: !!python/name:pymdownx.superfences.fence_code_format + format: !!python/name:lib.superfences_ponylang.format + validator: !!python/name:lib.superfences_ponylang.validate - pymdownx.snippets: base_path: ['code-samples'] check_paths: true From c4a4dca47c331cd31883d2cb6bef6d944ddea7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:34:58 +0200 Subject: [PATCH 09/70] Add module file --- lib/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/__init__.py diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 00000000..e69de29b From 25e25d31e1d53ffcb2f651b41b0a35a584e0a7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:44:46 +0200 Subject: [PATCH 10/70] Fix typo --- lib/superfences_ponylang/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index 2da0e8cb..cf59eff2 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -1,4 +1,4 @@ -def custom_formatter(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): +def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): return '
%s
' % (language, class_name, options['opt'], html_escape(source)) def validate(language: str, options: dict) -> bool: From 28952fea1a11e75f344c512116845883848232a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:45:16 +0200 Subject: [PATCH 11/70] Use file in route directory (no module) --- mkdocs.yml | 4 ++-- ponylang_custom_fence.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 ponylang_custom_fence.py diff --git a/mkdocs.yml b/mkdocs.yml index 93f87ac4..8779db5a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,8 +24,8 @@ markdown_extensions: format: !!python/name:pymdownx.superfences.fence_code_format - name: ponylang class: pony - format: !!python/name:lib.superfences_ponylang.format - validator: !!python/name:lib.superfences_ponylang.validate + format: !!python/name:ponylang_custom_fence.format + validator: !!python/name:ponylang_custom_fence.validate - pymdownx.snippets: base_path: ['code-samples'] check_paths: true diff --git a/ponylang_custom_fence.py b/ponylang_custom_fence.py new file mode 100644 index 00000000..cf59eff2 --- /dev/null +++ b/ponylang_custom_fence.py @@ -0,0 +1,5 @@ +def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): + return '
%s
' % (language, class_name, options['opt'], html_escape(source)) + +def validate(language: str, options: dict) -> bool: + return True # TODO allowed attributes and values \ No newline at end of file From bbd94c37ebcb3e39bbc717fc59f4df8e3192aa16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:05:08 +0200 Subject: [PATCH 12/70] Add -m argument to build command --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 1b6bb27d..d6665676 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,7 +8,7 @@ ID = "Your_Site_ID" [build] base = "" publish = "site/" - command = "mkdocs build" + command = "mkdocs build -m" [build.environment] PYTHON_VERSION = "3.8" From d5ac6d4690be8cb770c55e95b7cbd0fc72fe5144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:44:35 +0200 Subject: [PATCH 13/70] load local modules --- mkdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 8779db5a..93f87ac4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,8 +24,8 @@ markdown_extensions: format: !!python/name:pymdownx.superfences.fence_code_format - name: ponylang class: pony - format: !!python/name:ponylang_custom_fence.format - validator: !!python/name:ponylang_custom_fence.validate + format: !!python/name:lib.superfences_ponylang.format + validator: !!python/name:lib.superfences_ponylang.validate - pymdownx.snippets: base_path: ['code-samples'] check_paths: true From f669393e155078a76cde77790383021588000f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:44:41 +0200 Subject: [PATCH 14/70] reqs --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 070ed359..607a60c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ git+https://${INSIDERS_PAT}@github.com/squidfunk/mkdocs-material-insiders.git mkdocs-htmlproofer-plugin>=0.1.0 -mkdocs-ezlinks-plugin>=0.1.8 \ No newline at end of file +mkdocs-ezlinks-plugin>=0.1.8 +--find-links=lib \ No newline at end of file From eca6abfa7315106358c034e9a385fff5904d9bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:47:01 +0200 Subject: [PATCH 15/70] Remove unrecognized option from build command --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index d6665676..1b6bb27d 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,7 +8,7 @@ ID = "Your_Site_ID" [build] base = "" publish = "site/" - command = "mkdocs build -m" + command = "mkdocs build" [build.environment] PYTHON_VERSION = "3.8" From 88b96d58f4f07a03a7c4cea856b234903fe2fc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:52:56 +0200 Subject: [PATCH 16/70] Install lib module folder as part of build command --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 1b6bb27d..73c68a8c 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,7 +8,7 @@ ID = "Your_Site_ID" [build] base = "" publish = "site/" - command = "mkdocs build" + command = "pip install --no-index --find-links lib && mkdocs build" [build.environment] PYTHON_VERSION = "3.8" From fee9326ad7022776ad59311f43c18a44267cc482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:54:55 +0200 Subject: [PATCH 17/70] requirements in install command --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 73c68a8c..07971a53 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,7 +8,7 @@ ID = "Your_Site_ID" [build] base = "" publish = "site/" - command = "pip install --no-index --find-links lib && mkdocs build" + command = "pip install -r requirements.txt --find-links lib && mkdocs build" [build.environment] PYTHON_VERSION = "3.8" From b20f323700cc0e5299d84166e6113ffd336da31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:00:36 +0200 Subject: [PATCH 18/70] PYTHONPATH in build command --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 07971a53..ac671ccc 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,7 +8,7 @@ ID = "Your_Site_ID" [build] base = "" publish = "site/" - command = "pip install -r requirements.txt --find-links lib && mkdocs build" + command = "export PYTHONPATH=$PYTHONPATH:`pwd` && mkdocs build" [build.environment] PYTHON_VERSION = "3.8" From 1cea0d7f39f8afac8b616ac236ce4689dca56784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:06:33 +0200 Subject: [PATCH 19/70] Remove redundant --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 607a60c9..070ed359 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ git+https://${INSIDERS_PAT}@github.com/squidfunk/mkdocs-material-insiders.git mkdocs-htmlproofer-plugin>=0.1.0 -mkdocs-ezlinks-plugin>=0.1.8 ---find-links=lib \ No newline at end of file +mkdocs-ezlinks-plugin>=0.1.8 \ No newline at end of file From 4cceaa5de6d9297e191ce57afd80cf1e99ac0bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:06:44 +0200 Subject: [PATCH 20/70] static class --- lib/superfences_ponylang/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index cf59eff2..06c73ffa 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -1,5 +1,5 @@ def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): - return '
%s
' % (language, class_name, options['opt'], html_escape(source)) + return '
%s
' % (language, class_name, options['opt'], html_escape(source)) def validate(language: str, options: dict) -> bool: return True # TODO allowed attributes and values \ No newline at end of file From c34ae9db16ab4c73c47dc067d8251e3d2ab4790c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:11:57 +0200 Subject: [PATCH 21/70] Add validation --- lib/superfences_ponylang/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index 06c73ffa..8689c5a2 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -2,4 +2,8 @@ def format(source, language, css_class, options, md, classes=None, id_value='', return '
%s
' % (language, class_name, options['opt'], html_escape(source)) def validate(language: str, options: dict) -> bool: - return True # TODO allowed attributes and values \ No newline at end of file + allowed_options = { "snippet", "dedent_subsections" } #lambda v: v in ENGINES + for opt in options.keys(): + if opt not in allowed_options: + return False + return True \ No newline at end of file From 0ac65f12fdf893f4d872e45ed157084f3a5e0dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:19:41 +0200 Subject: [PATCH 22/70] use pygments --- lib/superfences_ponylang/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index 8689c5a2..04f8f741 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -1,5 +1,16 @@ +from pygments import highlight +from pygments.lexers import PythonLexer +from pygments.formatters import HtmlFormatter + def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): - return '
%s
' % (language, class_name, options['opt'], html_escape(source)) + return """ +
+        
+        %s
+    
+ """ % (language, class_name, options['opt'], html_escape(highlight(source, PythonLexer(), HtmlFormatter()))) def validate(language: str, options: dict) -> bool: allowed_options = { "snippet", "dedent_subsections" } #lambda v: v in ENGINES From ad2376280fc1b434823005f847039c319d26d1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:21:31 +0200 Subject: [PATCH 23/70] Add nav buttons --- lib/superfences_ponylang/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index 04f8f741..05d0513b 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -7,6 +7,8 @@ def format(source, language, css_class, options, md, classes=None, id_value='',
         
         %s
     
From c5ce12a7c0a3cff4a487c10d613ec743f4f0fd55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:23:50 +0200 Subject: [PATCH 24/70] debug --- lib/superfences_ponylang/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index 05d0513b..8319e891 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -3,6 +3,7 @@ from pygments.formatters import HtmlFormatter def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): + print(highlight(source, PythonLexer(), HtmlFormatter())) return """
         
""" % (language, class_name, options['opt'], html_escape(highlighted)) -def validate(language: str, options: dict) -> bool: +def validate(language: str, options: dict, attrs: dict, md) -> bool: return True allowed_options = { "snippet", "dedent_subsections" } #lambda v: v in ENGINES for opt in options.keys(): From efd8ff09edb458fe6c08f3a57bc0247f7bdc4ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:09:34 +0200 Subject: [PATCH 29/70] Imports --- lib/superfences_ponylang/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index d0cdc540..c8042d9d 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -2,6 +2,11 @@ from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter +from pymdownx.superfences import SuperFencesException +from pymdownx.superfences import _escape + +from mkdocs.exceptions import PluginError + def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): return "Hello world" try: @@ -18,7 +23,7 @@ def format(source, language, css_class, options, md, classes=None, id_value='', %s - """ % (language, class_name, options['opt'], html_escape(highlighted)) + """ % (language, class_name, options['opt'], _escape(highlighted)) # html_escape def validate(language: str, options: dict, attrs: dict, md) -> bool: return True From 540b3b09fe70ac055dfef0acb2660b25b8ab4ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:16:49 +0200 Subject: [PATCH 30/70] Don't validate --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 93f87ac4..ef6a0c7c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -25,7 +25,7 @@ markdown_extensions: - name: ponylang class: pony format: !!python/name:lib.superfences_ponylang.format - validator: !!python/name:lib.superfences_ponylang.validate + #validator: !!python/name:lib.superfences_ponylang.validate - pymdownx.snippets: base_path: ['code-samples'] check_paths: true From baa2d95005964503c10453c95ce2026b16fd5452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:18:35 +0200 Subject: [PATCH 31/70] Return actual markup --- lib/superfences_ponylang/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index c8042d9d..22d162ba 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -8,7 +8,6 @@ from mkdocs.exceptions import PluginError def format(source, language, css_class, options, md, classes=None, id_value='', attrs=None, **kwargs): - return "Hello world" try: highlighted = highlight(source, PythonLexer(), HtmlFormatter()) except: From 98bcee479944f39d0bbe814ccdadaadb3d757a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:26:29 +0200 Subject: [PATCH 32/70] return markup directly --- lib/superfences_ponylang/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/superfences_ponylang/__init__.py b/lib/superfences_ponylang/__init__.py index 22d162ba..90a07693 100644 --- a/lib/superfences_ponylang/__init__.py +++ b/lib/superfences_ponylang/__init__.py @@ -13,6 +13,8 @@ def format(source, language, css_class, options, md, classes=None, id_value='', except: raise SuperFencesException('Could not highlight source code "%s" passed' % (source)) + return highlighted + return """