This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openserverless-site.git


The following commit(s) were added to refs/heads/main by this push:
     new 4954184  tomarkdown
4954184 is described below

commit 4954184f83a64d25e209e59a02b3e8d3d639b102
Author: Michele Sciabarra <[email protected]>
AuthorDate: Sun Jul 14 18:09:39 2024 +0200

    tomarkdown
---
 content/en/docs/tomarkdown.xsh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/content/en/docs/tomarkdown.xsh b/content/en/docs/tomarkdown.xsh
new file mode 100644
index 0000000..10f2820
--- /dev/null
+++ b/content/en/docs/tomarkdown.xsh
@@ -0,0 +1,25 @@
+# use: nix-shell -p xonsh -p pandoc 
+# then run with: xonsh tomarkdown.xsh
+
+from pathlib import Path
+import re
+
+adocs=$(find . -name _index.adoc).splitlines()
+
+for adoc in adocs:
+    print(adoc)
+    base = adoc[:-4]
+    body = Path(base+"adoc").read_text()
+    pattern = re.compile(r'^---\s*\n(.*?)\n---\s*\n(.*)', re.DOTALL)
+    match = pattern.match(body)
+    if match: 
+        front_matter = match.group(1).strip()
+        rest_of_content = match.group(2).strip()
+        Path(base+"tmp").write_text(rest_of_content)
+        out=$(asciidoctor -b docbook -o - @(base)tmp | pandoc -f docbook -t 
markdown -o - -)
+        Path(base+"md").write_text(f"---\n{front_matter}\n---\n{out}")
+        rm -v @(base)tmp
+        mv -v @(base)adoc @(base)orig
+
+
+

Reply via email to