Пример #1
0
def test_layout_smart_wrapping(page_layout):
    strings = ["first", "second", "third"]
    output = page_layout + la.Section(
        children=[
            la.Row(children=[*strings, "fourth"]),
            "another bit of content",
            la.Row(children=[la.Column(children=["fifth"]), "sixth"]),
        ]
    )
    expected = page_layout
    expected += la.Section(
        children=[
            la.Row(children=[*[co.Markdown(x) for x in strings], "fourth"]),
            co.Markdown("another bit of content"),
            la.Row(
                children=[
                    la.Column(children=[co.Markdown("fifth")]),
                    la.Column(children=[co.Markdown("sixth")]),
                ]
            ),
        ]
    )
    print(output)
    print()
    print(expected)
    assert output == expected
Пример #2
0
def page_basic_layout() -> la.Page:
    page = la.Page(
        title="Test Page",
        children=la.Section(
            title="Section One",
            children=la.Row(
                title="Row One",
                children=la.Column(children=co.Markdown("markdown content")),
            ),
        ),
    )
    return page
Пример #3
0
def test_set_column_extra_children():
    expected = la.Page(
        children=la.Section(
            children=la.Row(
                children=la.Column(children=["markdown", "content", "tuple"]),
            ),
        ),
    )
    output_page = la.Page()
    output_page[0][0][0] = ("markdown", "content", "tuple")
    print(output_page)
    assert output_page == expected
Пример #4
0
def section_layout(image_content) -> la.Section:
    return la.Section(image_content)
Пример #5
0
def page_layout(content_list_fn) -> la.Page:
    return la.Page(
        title="jazz",
        children=la.Section(children=la.Row(
            children=[la.Column(children=[x]) for x in content_list_fn])),
    )
Пример #6
0
_irises_path = str(Path("tests/resources/irises.jpg").absolute())
_markdown_path = str(Path("tests/resources/markdown.md").absolute())

with Path(_irises_path).open("rb") as f:
    _irises_binary = BytesIO(f.read())

# Add new content classes here
content_list = [
    (co.Markdown("this _is_ some **markdown**")),
    (co.RawHTML("<p>Raw HTML</p>")),
]

# Add new layout classes here
layout_list = [
    (la.Page(children=[*content_list])),
    (la.Section(children=[*content_list])),
    (la.Row(children=[*content_list])),
    (la.Column(children=[*content_list])),
    (la.Card(children=[*content_list])),
    (la.CardSection(children=[*content_list])),
    (la.CardRow(children=[*content_list])),
    (la.Spacer()),
    (la.PageBreak()),
]

# Add new adaptor types here
adaptor_list = [
    ("this is markdown", co.Markdown),
    ({
        "key": "value"
    }, dict),
Пример #7
0

layout_add_list = [
    (
        la.Column(),
        "miles davis",
        la.Column(children=co.Markdown("miles davis")),
    ),
    (
        la.Row(),
        co.Markdown("ornette coleman"),
        la.Row(children=la.Column(children=co.Markdown("ornette coleman"))),
    ),
    (
        la.Page(children=["charles mingus"]),
        la.Section(children=["thelonious monk"]),
        la.Page(
            children=[
                la.Section(children=["charles mingus"]),
                la.Section(children=["thelonious monk"]),
            ]
        ),
    ),
    (
        la.Section(title="jazz"),
        la.Row(
            children=[
                la.Column(children=["john coltrane"]),
                la.Column(children=["wayne shorter"]),
            ]
        ),