"""Test caret.""" from .. import util class TestCaretSmart(util.MdCase): """Test escaping cases for Caret with smart enabled.""" extension = [ 'pymdownx.caret' ] extension_configs = { "pymdownx.caret": { "smart_insert": True } } def test_case_1(self): """Test case 1.""" self.check_markdown( R"x^2^ + y^2^ = 4", "

x2 + y2 = 4

", True ) def test_case_2(self): """Test case 2.""" self.check_markdown( R"Text^superscript^", "

Textsuperscript

", True ) def test_case_3(self): """Test case 3.""" self.check_markdown( R"Text^superscript failed^", "

Text^superscript failed^

", True ) def test_case_4(self): """Test case 4.""" self.check_markdown( R"Text^superscript\ success^", "

Textsuperscript success

", True ) def test_case_5(self): """Test case 5.""" self.check_markdown( R"Test: ^^ Won't insert ^^", "

Test: ^^ Won't insert ^^

", True ) def test_case_6(self): """Test case 6.""" self.check_markdown( R"Test: ^^Will insert^^", "

Test: Will insert

", True ) def test_case_7(self): """Test case 7.""" self.check_markdown( R"Test: \^\^Escaped\^\^", "

Test: ^^Escaped^^

", True ) def test_case_8(self): """Test case 8.""" self.check_markdown( R"Test: ^^This will all be inserted ^^because of the placement of the center carets.^^", "

Test: This will all be inserted ^^because of the placement of the center carets.

", True ) def test_case_9(self): """Test case 9.""" self.check_markdown( R"Test: ^^This will all be inserted ^^ because of the placement of the center carets.^^", "

Test: This will all be inserted ^^ because of the placement of the center carets.

", True ) def test_case_10(self): """Test case 10.""" self.check_markdown( R"Test: ^^This will NOT all be inserted^^ because of the placement of the center caret.^^", "

Test: This will NOT all be inserted because of the placement of the center caret.^^

", True ) def test_case_11(self): """Test case 11.""" self.check_markdown( R"Test: ^^This will all be inserted^ because of the token is less than that of the caret.^^", "

Test: This will all be inserted^ because of the token is less than that of the caret.

", True ) def test_complex_cases(self): """Test some complex cases.""" self.check_markdown( R''' ^^^I'm\ insert\ and\ sup^ I am just insert.^^ ^^^I'm\ insert\ and\ sup!^^\ I\ am\ just\ sup.^ ^sup\ and\ ^^sup\ insert^^^ and ^sup^ ^^insert and ^sup\ insert^^^ and ^sup^ ^^^I'm\ sup\ and\ insert^ I am just insert.^^ ^sup^ ^^^I'm\ insert\ and\ sup!^^\ I\ am\ just\ sup.^ ^sup^ ^sup\ and\ ^^sup\ insert^^^ and not sup^ ^^insert and ^sup\ insert^^^ and not sup^ ^sup\ and\ ^^sup\ insert^^^ ^^insert and ^sup\ insert^^^ ^sup\ ^^sup\ insert^^\ sup^ ^^^sup\ and\ insert^ insert^^: foo bar ^^insert^^ ^^^sup\ and\ insert^^\ sup^ foo bar ^^insert^^ ^sup\ and\ ^^sup\ insert^^^ ^^insert^^ ^^insert and ^sup\ insert^^^ ^^insert^^ ''', '''

I'm insert and sup I am just insert.

I'm insert and sup! I am just sup.

sup and sup insert and sup

insert and sup insert and sup

I'm sup and insert I am just insert. sup

I'm insert and sup! I am just sup. sup

sup and sup insert and not sup^

insert and sup insert and not sup^

sup and sup insert

insert and sup insert

sup sup insert sup

sup and insert insert: foo bar insert

sup and insert sup foo bar insert

sup and sup insert insert

insert and sup insert insert

''', True ) class TestCaretNoSmart(util.MdCase): """Test escaping cases for Caret without smart enabled.""" extension = [ 'pymdownx.caret' ] extension_configs = { "pymdownx.caret": { "smart_insert": False } } def test_case_1(self): """Test case 1.""" self.check_markdown( R"x^2^ + y^2^ = 4", "

x2 + y2 = 4

", True ) def test_case_2(self): """Test case 2.""" self.check_markdown( R"Text^superscript^", "

Textsuperscript

", True ) def test_case_3(self): """Test case 3.""" self.check_markdown( R"Text^superscript failed^", "

Text^superscript failed^

", True ) def test_case_4(self): """Test case 4.""" self.check_markdown( R"Text^superscript\ success^", "

Textsuperscript success

", True ) def test_case_5(self): """Test case 5.""" self.check_markdown( R"Test: ^^ Won't insert ^^", "

Test: ^^ Won't insert ^^

", True ) def test_case_6(self): """Test case 6.""" self.check_markdown( R"Test: ^^Will insert^^", "

Test: Will insert

", True ) def test_case_7(self): """Test case 7.""" self.check_markdown( R"Test: \^\^Escaped\^\^", "

Test: ^^Escaped^^

", True ) def test_case_8(self): """Test case 8.""" self.check_markdown( R"Test: ^^All will ^ be insert^^", "

Test: All will ^ be insert

", True ) def test_case_9(self): """Test case 9.""" self.check_markdown( R"Test: ^^All will^\^^ be insert with superscript in middle^^", "

Test: All will^ be insert with superscript in middle

", True ) def test_case_10(self): """Test case 10.""" self.check_markdown( R"Test: ^^All will ^\^^ be insert with superscript in middle^^", "

Test: All will ^ be insert with superscript in middle

", True ) def test_complex_cases(self): """Test some complex cases.""" self.check_markdown( R''' ^^^I'm\ insert\ and\ sup^ I am just insert.^^ ^^^I'm\ insert\ and\ sup!^^\ I\ am\ just\ sup.^ ^sup\ and\ ^^sup\ insert^^^ and ^sup^ ^^insert and ^sup\ insert^^^ and ^sup^ ^^^I'm\ sup\ and\ insert^ I am just insert.^^ ^sup^ ^^^I'm\ insert\ and\ sup!^^\ I\ am\ just\ sup.^ ^sup^ ^sup\ and\ ^^sup\ insert^^^ and not sup^ ^^insert and ^sup\ insert^^^ and not sup^ ^sup\ and\ ^^sup\ insert^^^ ^^insert and ^sup\ insert^^^ ^sup\ ^^sup\ insert^^\ sup^ ^^^sup\ and\ insert^ insert^^: foo bar ^^insert^^ ^^^sup\ and\ insert^^\ sup^ foo bar ^^insert^^ ^sup\ and\ ^^sup\ insert^^^ ^^insert^^ ^^insert and ^sup\ insert^^^ ^^insert^^ ''', '''

I'm insert and sup I am just insert.

I'm insert and sup! I am just sup.

sup and sup insert and sup

insert and sup insert and sup

I'm sup and insert I am just insert. sup

I'm insert and sup! I am just sup. sup

sup and sup insert and not sup^

insert and sup insert and not sup^

sup and sup insert

insert and sup insert

sup sup insert sup

sup and insert insert: foo bar insert

sup and insert sup foo bar insert

sup and sup insert insert

insert and sup insert insert

''', True )