feat: implement custom comment syntax

This commit is contained in:
Tim Grelka
2024-12-07 09:32:56 +01:00
parent 63a8418ae9
commit 19135655ca
4 changed files with 29 additions and 27 deletions
+8
View File
@@ -0,0 +1,8 @@
import sys
import mistletoe
from fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
if __name__ == "__main__":
with open(sys.argv[1]) as fin, open(sys.argv[2], "w") as fout:
fout.write(mistletoe.markdown(fin, FiftyOhmHtmlRenderer))
+21
View File
@@ -0,0 +1,21 @@
from mistletoe import HtmlRenderer
from mistletoe.block_token import BlockToken
class FiftyOhmHtmlRenderer(HtmlRenderer):
def __init__(self):
super().__init__(Comment)
def render_comment():
return None
class Comment(BlockToken):
@staticmethod
def start(line):
return line.startswith("%")
@classmethod
def read(cls, lines):
next(lines)
return None