def test_unordered_list_leading_space(): lex = MainLexer() lex.process(" * Item") assert lex.tokens == [ WS(" "), Literal("*"), WS(" "), Text("Item"), EOL, EOF, ]
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"), ]
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"), ]
def test_multiple_unnamed_arguments(): lex = ArgumentsLexer() lex.process("value1, value2") assert lex.tokens == [ Text("value1"), Literal(","), WS(" "), Text("value2"), ]
def test_spaces(): lex = ArgumentsLexer() lex.process("argument1=value1 value2") assert lex.tokens == [ Text("argument1"), Literal("="), Text("value1"), WS(" "), Text("value2"), ]
def test_unlisted_header(): lex = MainLexer() lex.process("==! Header") assert lex.tokens == [ Literal("==!"), WS(" "), Text("Header"), EOL, EOF, ]
def test_header_marker_in_header_text(): lex = MainLexer() lex.process("= a=b") assert lex.tokens == [ Literal("="), WS(" "), Text("a=b"), EOL, EOF, ]
def test_multiple_header_markers(): lex = MainLexer() lex.process("=== Header") assert lex.tokens == [ Literal("==="), WS(" "), Text("Header"), EOL, EOF, ]
def test_ordered_list_multiple_stars(): lex = MainLexer() lex.process("### Item") assert lex.tokens == [ Literal("###"), WS(" "), Text("Item"), EOL, EOF, ]
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, ]
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, ]
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, ]
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, ]
def test_process_whitespace(): lex = BaseLexer() lex.process("a b") assert lex.tokens == [Text("a"), WS(" "), Text("b"), EOL, EOF]