How to use the lookatme.render function in lookatme

To help you get started, we’ve selected a few lookatme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d0c-s4vage / lookatme / tests / test_markdown.py View on Github external
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|",
github d0c-s4vage / lookatme / tests / test_file_loader.py View on Github external
def test_file_loader(tmpdir, mocker):
    """Test the built-in file loader extension
    """
    mocker.patch.object(lookatme.config, "LOG")
    fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
    mocker.patch.object(lookatme.render.pygments, "config", fake_config)
    fake_config.STYLE = TEST_STYLE

    tmppath = tmpdir.join("test.py")
    tmppath.write("print('hello')")

    rendered = render_markdown(f"""
```file
path: {tmppath}
relative: false
""")

stripped_rows = [
    b'',
    b"print('hello')",
github d0c-s4vage / lookatme / tests / test_markdown.py View on Github external
def test_lists(mocker):
    """Test list 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 = {
        "bullets": {
            "default": "*",
            "1": "-",
            "2": "=",
            "3": "^",
        },
    }

    rendered = render_markdown("""
* list 1
  * list 2
    * list 3
      * list 4
  * list 2
github d0c-s4vage / lookatme / tests / test_file_loader.py View on Github external
def test_file_loader_with_transform(tmpdir, mocker):
    """Test the built-in file loader extension
    """
    mocker.patch.object(lookatme.config, "LOG")
    fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
    mocker.patch.object(lookatme.render.pygments, "config", fake_config)
    fake_config.STYLE = TEST_STYLE

    tmppath = tmpdir.join("test.py")
    tmppath.write("""
Hello
Apples2
there
Apples3
there
Apples1
""")

    rendered = render_markdown(f"""
```file
path: {tmppath}
relative: false
github d0c-s4vage / lookatme / lookatme / contrib / terminal.py View on Github external
shlex.split(term_data["command"].strip()),
        main_loop=loop,
        encoding="utf8",
    )
    CREATED_TERMS.append(term)

    line_box = urwid.LineBox(urwid.BoxAdapter(term, height=term_data["rows"]))

    res = []

    if term_data["init_codeblock"] is True:
        fake_token = {
            "text": term_data["init_text"],
            "lang": term_data["init_codeblock_lang"],
        }
        res += lookatme.render.markdown_block.render_code(
            fake_token, body, stack, loop
        )
    
    res += [
        urwid.Divider(),
        line_box,
        urwid.Divider(),
    ]

    return res