Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_code_yaml(mocker):
"""Test code block rendering with yaml language
"""
mocker.patch.object(lookatme.config, "LOG")
fake_config = mocker.patch.object(lookatme.render.pygments, "config")
fake_config.STYLE = {
"style": "monokai",
}
rendered = render_markdown("""
```yaml
test: a value
test2: "another value"
array:
- item1
- item2
- item3
```""")
assert len(rendered) == 8
def test_headings(mocker):
"""Test basic header rendering
"""
mocker.patch.object(lookatme.config, "LOG")
fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
fake_config.STYLE = TEST_STYLE
rendered = render_markdown("""
# H1
## H2
### H3
---
""")
# three lines for the headings plus an extra line of padding after each
# and one line of padding before the first one
assert len(rendered) == 7
stripped_rows = [
b"",
* 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 test_table(mocker):
"""Test basic table rendering
"""
import lookatme.widgets.table
mocker.patch.object(lookatme.config, "LOG")
fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
mocker.patch.object(lookatme.widgets.table, "config", fake_config)
fake_config.STYLE = {
"table": {
"column_spacing": 1,
"header_divider": "-",
},
}
rendered = render_markdown("""
| H1 | H2 | H3 |
|:--------|:------:|-------:|
| 1value1 | value2 | value3 |
| 1 | 2 | 3 |
""")
assert len(rendered) == 4
def test_headings(mocker):
"""Test basic header rendering
"""
mocker.patch.object(lookatme.config, "LOG")
fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
fake_config.STYLE = TEST_STYLE
rendered = render_markdown("""
# H1
## H2
### H3
---
""")
# three lines for the headings plus an extra line of padding after each
# and one line of padding before the first one
assert len(rendered) == 7
stripped_rows = [
b"",
b"|H1|",