How to use the lookatme.render.pygments 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_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')",
    b'',
github d0c-s4vage / lookatme / tests / test_markdown.py View on Github external
def test_inline(mocker):
    """Test inline markdown
    """
    mocker.patch.object(lookatme.config, "LOG")
    fake_config = mocker.patch.object(lookatme.render.pygments, "config")
    mocker.patch.object(lookatme.render.markdown_inline, "config", fake_config)
    fake_config.STYLE = {
        "style": "monokai",
        "link": {
            "fg": "underline",
            "bg": "default",
        },
    }

    rendered = render_markdown("*emphasis*")
    assert len(rendered) == 3
    assert rendered[1][0][0].foreground == "default,italics"
    assert row_text(rendered[1]).strip() == b"emphasis"

    rendered = render_markdown("**emphasis**")
    assert len(rendered) == 3