Skip to content

Commit

Permalink
Fixes tutor tag replacement/extraction (#194)
Browse files Browse the repository at this point in the history
* Fixes tutor tag replacement/extraction
  • Loading branch information
d0c-s4vage committed Dec 12, 2022
1 parent b2b3d73 commit 0a6667a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 0 additions & 2 deletions lookatme/render/markdown_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ def render_heading_close(token: Dict, ctx: Context):
> space chips
</TUTOR:EXAMPLE>
## Style
Block quotes can be styled with slide metadata. This is the default style:
Expand Down
4 changes: 1 addition & 3 deletions lookatme/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def get_md(self, rendered_example=True) -> str:

res_md = []
last_idx = 0
regex = (
r"<(?P<tag>TUTOR:(?P<type>[A-Z_]+))(?P<attrs>.*)>(?P<inner>.*)</(?P=tag)>"
)
regex = r"<(?P<tag>TUTOR:(?P<type>[A-Z_]+))(?P<attrs>[^>]*)>(?P<inner>.*)</(?P=tag)>"
for match in re.finditer(regex, slides_md, re.MULTILINE | re.DOTALL):
res_md.append(slides_md[last_idx : match.start()])
match_groups = match.groupdict()
Expand Down
17 changes: 17 additions & 0 deletions tests/test_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,20 @@ def test_tutor(mocker):
"""
).strip()
assert style_yaml in md_text


def test_tutor_with_gt_in_example():
tutor = tutorial.Tutor(
"name",
"group",
"<TUTOR:EXAMPLE>> test</TUTOR:EXAMPLE>",
impl_fn=lambda _: 10,
order=99999,
)
md_text = tutor.get_md()

md_example = "> ~~~markdown\n> > test\n> ~~~"
assert md_example in md_text

md_rendered = "\n> test"
assert md_rendered in md_text

0 comments on commit 0a6667a

Please sign in to comment.