add support for <sup>, <sub>, and <small> for latex conversion
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 6 Sep 2022 10:48:20 +0000 (03:48 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 6 Sep 2022 10:48:20 +0000 (03:48 -0700)
openpower/pandoc_img.py

index 0b135e08148c9f73fb519d680927c060752572dc..7ecedaee2ec51e9847be89f3c186024f5838878c 100755 (executable)
@@ -110,9 +110,21 @@ def inlinenotes(k, v, f, meta):
     if k == 'Link':
         out.write("     link type %s\n" %
                   (type(v[1][0])))
-    if k == 'RawInline' and v[0] == 'html' \
-            and re.fullmatch(r"< *br */? *>", v[1]):
-        return [RawInline('latex', r'\\')]
+    if k == 'RawInline' and v[0] == 'html':
+        if re.fullmatch(r"< *br */? *>", v[1]):
+            return [RawInline('latex', r'\\')]
+        if re.fullmatch(r"< *sup *>", v[1]):
+            return [RawInline('latex', r'\textsuperscript{')]
+        if re.fullmatch(r"< */ *sup *>", v[1]):
+            return [RawInline('latex', '}')]
+        if re.fullmatch(r"< *sub *>", v[1]):
+            return [RawInline('latex', r'\textsubscript{')]
+        if re.fullmatch(r"< */ *sub *>", v[1]):
+            return [RawInline('latex', '}')]
+        if re.fullmatch(r"< *small *>", v[1]):
+            return [RawInline('latex', r'{\small ')]
+        if re.fullmatch(r"< */ *small *>", v[1]):
+            return [RawInline('latex', '}')]
 
 
 if __name__ == "__main__":