summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2021-02-15 07:08:13 +0000
committerRob Austein <sra@hactrn.net>2021-02-15 07:08:13 +0000
commit3bfd6f7d2c45b44ae3ef0616f40368d59eae0c68 (patch)
treedb830f09cf00b4b1d5c0dfc538f26e5b639aa57e
parent6cbd48ea560b2cc4b906efcc13ad3a14a8d8e815 (diff)
Convert whacky [[span()]] links
[[span()]] is poorly documented, and the Cryptech Wiki only used it because somebody was trying to force TracWiki to do something it really didn't want to do. Trying to write a general [[span()]] parser for this is over the top, just handle this screwball case.
-rw-r--r--pelican/content/WikiStart.md10
-rwxr-xr-xtrac2md.py10
2 files changed, 14 insertions, 6 deletions
diff --git a/pelican/content/WikiStart.md b/pelican/content/WikiStart.md
index b2d8f3e..77030a1 100644
--- a/pelican/content/WikiStart.md
+++ b/pelican/content/WikiStart.md
@@ -54,26 +54,26 @@ offering [financial support](https://cryptech.is/funding/) to keep the
work flowing.
# More Information
-## [[span(style=color: brown,[QuickStart Quick Start Guide])]]
+## [Quick Start Guide](QuickStart)
* including pointers to the git repositories, information on how to set up and configure the board and software, and HSM requirements
-## [[span(style=color: brown,[DevelopersGuide Developers Guide])]]
+## [Developers Guide](DevelopersGuide)
* including the architecture diagrams, and known information
-## [[span(style=color: brown,[ProjectStatus Project Status])]]
+## [Project Status](ProjectStatus)
* including information on the chip design and prototypes as well as the pilot project(s)
-## [[span(style=color: brown,[ProjectMetadata Project Metadata])]]
+## [Project Metadata](ProjectMetadata)
* including information on presentations and meeting notes, technical references, and related work
-## [[span(style=color: brown,[ProjectArchive Project Archive])]]
+## [Project Archive](ProjectArchive)
* including information on dormant and far-future work
diff --git a/trac2md.py b/trac2md.py
index dd519eb..a8a632b 100755
--- a/trac2md.py
+++ b/trac2md.py
@@ -23,6 +23,8 @@ wikilink_3_pattern = re.compile(r"\[\[(?:wiki:)?([^][]+)\]\]|\[wiki:([^][]+)\]")
strikethrough_pattern = re.compile(r"~~(.*)~~")
camelcase_pattern = re.compile(r"!((?:\w|[#])+)")
+span_pattern = re.compile(r"\[\[span\((?:[^][]*,)*\[([^(), ]+)([^(),]+)\]\)\]\]")
+
wikiheading_patterns = tuple(
(level, re.compile("^{} (.*)[ \t]*=*$".format("=" * level)))
for level in range(1, 7))
@@ -87,6 +89,7 @@ def convert_strike(line):
pass
return line
+
def convert_image(line, slug):
image_result = image_pattern.search(line)
if image_result:
@@ -102,12 +105,14 @@ def convert_image(line, slug):
pass
return line
+
def convert_linebreak(line):
# Markdown spec says linebreak is <SPACE><SPACE><RETURN>, who am I to argue?
if line.endswith("\\\\"):
line = line[:-2] + " "
return line
+
def WikiToMD(content, slug):
# Line breaks in Markdown must be at end of line, so add newlines as needed
@@ -190,7 +195,10 @@ def WikiToMD(content, slug):
prev_indent = 0
# Convert CamelCase
- line = camelcase_pattern.sub("\\1", line)
+ line = camelcase_pattern.sub(r"\1", line)
+
+ # Convert (limited subset of) spans
+ line = span_pattern.sub(r"[[\1|\2]]", line)
# Convert headers
line = convert_headers(line)