find hide/show blocks and skip them in PDFs
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 May 2023 09:09:35 +0000 (10:09 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 1 May 2023 09:09:43 +0000 (10:09 +0100)
openpower/mdwn_inline.py

index e072ecb1b0807eae3183dffe4049327fa5b21c87..c0738b353f7a7802b7f9c3fd75da8bffda030f6a 100755 (executable)
@@ -32,12 +32,23 @@ wiki_path = os.path.split(openpower_path)[0]
 
 def recursive_inline(f, input_name, depth):
     assert depth < 10, "probably found an [[!inline]]-loop"
+    skip = False # found the pattern <!-- hide -->
     for line in f.readlines():
+        # skip hide/show
+        if skip:
+            if line.startswith("<!-- show -->"):
+                skip = False
+            continue
+        elif line.startswith("<!-- hide -->"):
+            skip = True
+            continue
+        # fix separation in comparison table
         if input_name.endswith("comparison_table.tex") and \
             line.startswith("\begin{itemize}"):
             o.write(line)
             o.write("\\itemsep -0.3em\n")
             continue
+        # find actual inlines
         if not line.startswith("[[!inline"):
             o.write(line)
             continue