示例#1
0
def test_unordered_list_leading_space():
    lex = MainLexer()

    lex.process("    * Item")

    assert lex.tokens == [
        WS("    "),
        Literal("*"),
        WS(" "),
        Text("Item"),
        EOL,
        EOF,
    ]
示例#2
0
def test_escaped_quotes():
    lex = ArgumentsLexer()

    lex.process(r"Argument \"with\" quotes")

    assert lex.tokens == [
        Text("Argument"),
        WS(" "),
        Literal("\\"),
        Literal('"'),
        Text("with"),
        Literal("\\"),
        Literal('"'),
        WS(" "),
        Text("quotes"),
    ]
示例#3
0
def test_mixed_arguments():
    lex = ArgumentsLexer()

    lex.process("value1, value2,argument1=value1, argument2=value2")

    assert lex.tokens == [
        Text("value1"),
        Literal(","),
        WS(" "),
        Text("value2"),
        Literal(","),
        Text("argument1"),
        Literal("="),
        Text("value1"),
        Literal(","),
        WS(" "),
        Text("argument2"),
        Literal("="),
        Text("value2"),
    ]
示例#4
0
def test_multiple_unnamed_arguments():
    lex = ArgumentsLexer()

    lex.process("value1, value2")

    assert lex.tokens == [
        Text("value1"),
        Literal(","),
        WS(" "),
        Text("value2"),
    ]
示例#5
0
def test_spaces():
    lex = ArgumentsLexer()

    lex.process("argument1=value1 value2")

    assert lex.tokens == [
        Text("argument1"),
        Literal("="),
        Text("value1"),
        WS(" "),
        Text("value2"),
    ]
示例#6
0
def test_unlisted_header():
    lex = MainLexer()

    lex.process("==! Header")

    assert lex.tokens == [
        Literal("==!"),
        WS(" "),
        Text("Header"),
        EOL,
        EOF,
    ]
示例#7
0
def test_header_marker_in_header_text():
    lex = MainLexer()

    lex.process("= a=b")

    assert lex.tokens == [
        Literal("="),
        WS(" "),
        Text("a=b"),
        EOL,
        EOF,
    ]
示例#8
0
def test_multiple_header_markers():
    lex = MainLexer()

    lex.process("=== Header")

    assert lex.tokens == [
        Literal("==="),
        WS(" "),
        Text("Header"),
        EOL,
        EOF,
    ]
示例#9
0
def test_ordered_list_multiple_stars():
    lex = MainLexer()

    lex.process("### Item")

    assert lex.tokens == [
        Literal("###"),
        WS(" "),
        Text("Item"),
        EOL,
        EOF,
    ]
示例#10
0
def test_include_content_multiple_spaces_after_mark():
    lex = MainLexer()

    lex.process("<<      type:/path/to/it.jpg")

    assert lex.tokens == [
        Literal("<<"),
        WS("      "),
        Text("type:/path/to/it.jpg"),
        EOL,
        EOF,
    ]
示例#11
0
def test_include_content_with_arguments():
    lex = MainLexer()

    lex.process("<< type:/path/to/it.jpg(value1,argument2=value2)")

    assert lex.tokens == [
        Literal("<<"),
        WS(" "),
        Text("type:/path/to/it.jpg"),
        Literal("("),
        Text("value1,argument2=value2"),
        Literal(")"),
        EOL,
        EOF,
    ]
示例#12
0
def test_title_multiple_spaces_after_mark():
    lex = MainLexer()

    lex.process(
        dedent("""
            .     A title with spaces
            Some text
            """))

    assert lex.tokens == [
        Literal("."),
        WS("     "),
        Text("A title with spaces"),
        EOL,
        Text("Some text"),
        EOL,
        EOF,
    ]
示例#13
0
def test_title_with_space():
    lex = MainLexer()

    lex.process(
        dedent("""
            . A title
            Some text
            """))

    assert lex.tokens == [
        Literal("."),
        WS(" "),
        Text("A title"),
        EOL,
        Text("Some text"),
        EOL,
        EOF,
    ]
示例#14
0
def test_process_whitespace():
    lex = BaseLexer()

    lex.process("a   b")

    assert lex.tokens == [Text("a"), WS("   "), Text("b"), EOL, EOF]