Пример #1
0
def test_esc(sitedir: Path) -> None:
    (sitedir / "a.md").write_text(r"""
:jinja:`{{abcdef\`}}`
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    print(text)
    assert text == "{{abcdef`}}"

    (sitedir / "b.md").write_text(r"""
:jinja:`{{\\abcdef\\\\}}`
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "b.md"))
    print(text)
    assert text == r"{{\abcdef\\}}"
Пример #2
0
def test_multiline(sitedir: Path) -> None:
    (sitedir / "a.md").write_text("""
:jinja:`{{abc
def}}`
""")
    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    assert (text == """{{abc
def}}""")
Пример #3
0
def test_esc_head(sitedir: Path) -> None:
    (sitedir / "a.md").write_text(r"""
\:jinja:`{{abcdef\`}}`
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    print(text)
    assert text == "<p>:jinja:<code>&#123;&#123;abcdef\\</code>&#125;&#125;`</p>"
Пример #4
0
def test_target(sitedir: Path) -> None:
    (sitedir / "a.md").write_text("""
.. target:: abcdefg

hello
""")
    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    assert (text == """<div class="header_target" id="abcdefg"></div>
<p>hello</p>""")
Пример #5
0
def test_code(sitedir: Path) -> None:
    (sitedir / "a.md").write_text("""

    :jinja:`{{abcdef}}`
""")
    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    assert (
        text == """<div class="highlight"><pre><span></span><code>{{abcdef}}
</code></pre></div>""")
Пример #6
0
def test_fence2(sitedir: Path) -> None:
    (sitedir / "a.md").write_text("""

```python
{1:1}
```
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    print(text)
    assert ('&#123;</span><span class="mi">1</span><span class="p">:'
            '</span><span class="mi">1</span><span class="p">&#125;') in text
Пример #7
0
def test_split(sitedir: Path) -> None:
    sitedir.joinpath("a.md").write_text("""%%%% b.md
first
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))

    assert src.metadata["type"] == "article"
    assert src.contentpath == ((), "b.md")
    assert text == "<p>first</p>"

    sitedir.joinpath("a.md").write_text("""%%%% b.md
---
tags:
  - a
  - b
  - c
---
first
%%%% c.md
second
""")

    (
        (src1, text1),
        (src2, text2),
    ) = md.load(to_contentsrc(sitedir / "a.md"))

    assert src1.metadata["type"] == "article"
    assert src1.contentpath == ((), "b.md")
    assert src1.metadata["tags"] == ["a", "b", "c"]
    assert text1 == "<p>first</p>"

    assert src2.metadata["type"] == "article"
    assert src2.contentpath == ((), "c.md")
    assert text2 == "<p>second</p>"
Пример #8
0
def test_meta(sitedir: Path) -> None:
    sitedir.joinpath("a.md").write_text("""
title: title<>
tags: a,b,c
draft: false
date: 2017-1-1

adfas
:jinja:`{{ancdef}}`

{}
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))

    assert src.metadata["type"] == "article"
    assert src.metadata["title"] == "title<>"
Пример #9
0
def test_yaml(sitedir: Path) -> None:
    sitedir.joinpath("a.md").write_text("""---
title: title<>
tags:
    - a
    - b
    - c
---
test
""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))

    assert src.metadata["type"] == "article"
    assert src.metadata["title"] == "title<>"
    assert src.metadata["tags"] == ["a", "b", "c"]
    assert text == "<p>test</p>"
Пример #10
0
def test_noclose(sitedir: Path) -> None:
    (sitedir / "a.md").write_text("""a :jinja:`{{abc}} b""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    assert text == "<p>a :jinja:`&#123;&#123;abc&#125;&#125; b</p>"
Пример #11
0
def test_inline(sitedir: Path) -> None:
    (sitedir / "a.md").write_text("""a :jinja:`{{abc}}` b""")

    ((src, text), ) = md.load(to_contentsrc(sitedir / "a.md"))
    assert text == "<p>a {{abc}} b</p>"