Skip to content

Commit 836a1c7

Browse files
committed
update
1 parent 8b1bf32 commit 836a1c7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

md2mu.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
}
1818

1919
def parse_underlined(inline, m, state):
20-
print(inline, m, state)
2120
text = m.group(2)
2221
print('rrr')
2322
state.append_token({'type': 'underlined', 'raw': text})
2423
return m.end()
2524

2625
def parse_underlined(self, m, state) -> int:
27-
print(state)
2826
pos = m.end()
2927
marker = m.group(0)
3028
mlen = len(marker)
@@ -142,6 +140,13 @@ def block_error(self, token: Dict[str, Any], state: BlockState) -> str:
142140
def list(self, token: Dict[str, Any], state: BlockState) -> str:
143141
return render_list(self, token, state)
144142

143+
def m2μ():
144+
m2μr = Markdown2Micron()
145+
m2μ = Markdown(renderer=m2μr)
146+
m2μ.inline.register('underlined', UNDERLINED, parse_underlined, before='emphasis')
147+
m2μ.renderer.register('underlined', render_underlined)
148+
return m2μ
149+
145150
def main():
146151

147152
parser = argparse.ArgumentParser(description="Converts a Markdown file to Micron format")
@@ -152,13 +157,10 @@ def main():
152157

153158
with open(args.md_file, 'r') as mdf:
154159
md_str = mdf.read()
155-
m2μr = Markdown2Micron()
156-
m2μ = Markdown(renderer=m2μr)
157-
m2μ.inline.register('underlined', UNDERLINED, parse_underlined, before='emphasis')
158-
m2μ.renderer.register('underlined', render_underlined)
160+
md2mu = m2μ()
159161

160162
with open(args.mu_file, 'w') as muf:
161-
md_str = muf.write(m2μ(md_str))
163+
md_str = muf.write(md2mu(md_str))
162164

163165
if __name__ == "__main__":
164166
main()

0 commit comments

Comments
 (0)