You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2018/05/02 14:21:01 UTC
incubator-ponymail-site git commit: Docco
Repository: incubator-ponymail-site
Updated Branches:
refs/heads/asf-site 404c47c21 -> 4f0c5e2d8
Docco
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail-site/commit/4f0c5e2d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail-site/tree/4f0c5e2d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail-site/diff/4f0c5e2d
Branch: refs/heads/asf-site
Commit: 4f0c5e2d8b2584bb9b611f7f256ddfea199e4385
Parents: 404c47c
Author: Sebb <se...@apache.org>
Authored: Wed May 2 15:20:38 2018 +0100
Committer: Sebb <se...@apache.org>
Committed: Wed May 2 15:20:38 2018 +0100
----------------------------------------------------------------------
source/generate.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail-site/blob/4f0c5e2d/source/generate.py
----------------------------------------------------------------------
diff --git a/source/generate.py b/source/generate.py
index 3d32e85..a19dd4d 100644
--- a/source/generate.py
+++ b/source/generate.py
@@ -2,6 +2,17 @@
import markdown, codecs, os, sys, re, time, io
+"""
+Script to process the markdown files:
+- converts text enclosed in ~~~ to <pre>
+- adds anchor links to <h1-6>
+- fixes references to UPPERCASE.md files
+- applies markdown processing
+- writes the files as lower-case .html to content/ tree
+
+Note: only .md files will be copied to content/
+Static files such as css and images are assumed to be already present under content/
+"""
template = ""
with open("template.html", "r") as tmpl:
@@ -19,10 +30,14 @@ def runDir(path):
outfile = f.replace(".md", ".html").lower().replace("//", "/")
outfile = path.replace("markdown", "", 1) + outfile
text = input_file.read()
+ # convert sections enclosed in ~~~ to <pre> blocks
text = re.sub(r"~~~([\s\S]+?)~~~", "<pre>\\1</pre>", text, flags=re.MULTILINE)
+ # convert references to UPPERCASE.md files to lower-case.html
+ # e.g. Refer to the [General installation documentation](INSTALLING.md)
+ # => Refer to the [General installation documentation](installing.html)
text = re.sub(r"([A-Z/]+)\.md", lambda x: x.group(1).lower() + ".html", text, flags =re.MULTILINE)
html = markdown.markdown(text)
- # Convert h1-h6 into links
+ # Convert h1-h6 into anchors with paragraph mark hover links
html = re.sub(r"<h([1-6])>(.+?)</h[1-6]>", lambda x:
"<h%s id='%s'>%s<a href='#%s' style='color: rgba(0,0,0,0);'>¶</a></h%s>" % (
x.group(1),
@@ -32,6 +47,7 @@ def runDir(path):
x.group(1)
)
, html)
+ # merge the transformed file with the template
html = template.replace("%CONTENT%", html, 1)
print("Writing %s..." % outfile)
bpath = os.path.dirname(outfile)