Skip to content

Commit

Permalink
handle semicolon at the end of block strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfast committed Feb 2, 2024
1 parent 66ce052 commit 6551abb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/midgy/language/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,18 @@ def fence_noncode(self, token, env):
# close the fence group and comment out the last fence dashes
# this syntax restricuts from using line continuations like indented code blocks
# if the comment were dropped then we could use continuations
yield ") # "
yield from self.generate_block_lines(env, token.map[1])
yield ")"
yield " # "
rest = self.generate_block_lines(env, token.map[1])
if token.meta["next_code"] is None:
last = next(rest)
yield last[:-1]
# ipython test for semi colon at the end of any line,
# not the end of a valid python expression
yield ";"
yield last[-1]
else:
yield from rest

def front_matter(self, token, env):
"""render front matter as python code with an optional variable name"""
Expand Down

0 comments on commit 6551abb

Please sign in to comment.