Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* item
* item
Hello there this is a paragraph
```python
code block
More text """ parser = Parser() slides = parser.parse_slides({}, input_data) assert len(slides) == 2
def render_markdown(markdown, height=50):
"""Returns the rendered canvas contents of the markdown
"""
loop = urwid.MainLoop(urwid.Pile([]))
renderer = lookatme.tui.SlideRenderer(loop)
renderer.start()
parser = Parser()
_, slides = parser.parse_slides({"title": ""}, markdown)
renderer.stop()
pile_contents = renderer.render_slide(slides[0], force=True)
renderer.join()
pile = urwid.Pile([urwid.Text("testing")])
pile.contents = pile_contents
return list(pile.render((height,)).content())
def test_parse_metadata_empty():
"""Test that metadata can be correctly parsed out of a markdown
presentation
"""
input_data = f"""
---
---
remaining
"""
parser = Parser()
input_data, meta = parser.parse_meta(input_data)
assert input_data.strip() == "remaining"
now = datetime.datetime.now()
assert meta["title"] == ""
assert meta["date"].year == now.year
assert meta["date"].month == now.month
assert meta["date"].day == now.day
assert meta["author"] == ""
## Heading 2
some text
## Heading 3
more text
## Heading 4
### Sub heading
#### Sub Heading
"""
parser = Parser()
meta = {"title": ""}
_, slides = parser.parse_slides(meta, input_data)
assert len(slides) == 4
assert meta["title"] == "Heading Title"
presentation
"""
title = "Presentation Title"
date = "9999-01-01"
author = "The Author"
input_data = f"""
---
title: {title}
date: {date}
author: {author}
---
remaining
"""
parser = Parser()
input_data, meta = parser.parse_meta(input_data)
assert input_data.strip() == "remaining"
assert meta["title"] == title
assert meta["date"].year == 9999
assert meta["date"].month == 1
assert meta["date"].day == 1
assert meta["author"] == author
input_data = r"""
## Heading 2
some text
## Heading 3
more text
## Heading 4
### Sub heading
#### Sub Heading
"""
parser = Parser()
meta = {"title": ""}
_, slides = parser.parse_slides(meta, input_data)
assert len(slides) == 3
assert meta["title"] == ""
def reload(self, data=None):
"""Reload this presentation
:param str data: The data to render for this slide deck (optional)
"""
if data is None:
with open(self.input_filename, "r") as f:
data = f.read()
parser = Parser()
self.meta, self.slides = parser.parse(data)
lookatme.contrib.load_contribs(self.meta.get("extensions", []))
self.styles = lookatme.themes.ensure_defaults(self.theme_mod)
dict_deep_update(self.styles, self.meta.get("styles", {}))
# now apply any command-line style overrides
if self.style_override is not None:
self.styles["style"] = self.style_override
lookatme.config.STYLE = self.styles