def test_that_multiline_environments_have_correct_pos(self):
     formulas = mp.parse_environments('j$$a\nb$$,\n$$c$$')
     self.assertTrue((1, 2) in formulas.keys(), "expected (1, 2) to be in the " +
             "list of formulas, got " + repr(formulas))
     self.assertTrue((3, 1) in formulas.keys())
     # the same with the second environment slightly shiftet
     formulas = mp.parse_environments('j$$a\nb$$,\nchar$$c$$')
     self.assertTrue((1, 2) in formulas.keys(), "expected (1, 2) to be in the " +
             "list of formulas, got " + repr(formulas))
     self.assertTrue((3, 5) in formulas.keys())
 def test_one_formula_per_line_works(self):
     formulas = mp.parse_environments("Here is $$\\tau$$.")
     self.assertEqual(len(list(formulas.keys())), 1)
     self.assertTrue(
         r"\tau" in formulas.values(),
         "expected \\tau, found: " + repr(formulas.values()),
     )
 def test_that_two_formulas_per_line_are_recognized(self):
     formulas = mp.parse_environments("Here is $$\\tau$$ and $$\\pi$$.")
     self.assertEqual(
         len(formulas.keys()),
         2,
         "expected two formulas, got " + repr(formulas),
     )
     self.assertTrue("\\tau" in formulas.values())
     self.assertTrue("\\pi" in formulas.values())
 def test_that_two_formulas_per_line_have_correct_pos(self):
     formulas = mp.parse_environments("Here is $$\\tau$$ and $$\\pi$$.")
     self.assertTrue(
         (1, 9) in formulas,
         "expected (1,9) as position, found " + repr(formulas.keys()),
     )
     self.assertTrue(
         (1, 22) in formulas,
         "expected (1,22) as position, found " + repr(formulas.keys()),
     )
 def test_that_three_environments_per_line_work(self):
     formulas = mp.parse_environments("u\nok $$first$$, then $$second$$ and in the end $$third$$.")
     self.assertTrue((2, 4) in formulas)
     self.assertTrue((2, 20) in formulas)
     self.assertTrue((2, 46) in formulas)
 def test_that_escaped_dollars_are_ignored(self):
     self.assertFalse(mp.parse_environments(r'It has \$\$been\$\$ escaped'))
 def test_that_normal_text_does_not_contain_formulas(self):
     self.assertFalse(mp.parse_environments('This is \na bit of\n Text'))