"""Test cases for Arithmatex.""" from .. import util class TestArithmatexLimit(util.MdCase): """Test limiting Arithmatex inline and block inputs.""" extension = [ 'pymdownx.arithmatex' ] extension_configs = {'pymdownx.arithmatex': {'inline_syntax': ['round'], 'block_syntax': ['square']}} def test_round_only(self): """Test round only.""" self.check_markdown( "\\(1 + 2 + 3\\)", """
1 + 2 + 3
""" # noqa: E501 ) def test_square_only(self): """Test square only.""" self.check_markdown( r""" \[ 1 + 2 + 3 \] """, r"""$3+2\$
''', # noqa: E501 True ) def test_escaped_dollar_dollar_block(self): """Test escaping both dollars.""" self.check_markdown( r''' $$3+2\$\$ ''', r'''$$3+2$$
''', True ) def test_double_escaped_dollar_block(self): """Test double escaping a dollar.""" self.check_markdown( r''' $$3+2\\$$ ''', r'''\begin{align}3+2\end{align}
''', True ) def test_double_escaped_end_block(self): """Test double escaping an end.""" self.check_markdown( r''' \begin{align}3+2\\\end{align} ''', r'''[3+2\]
''', True ) def test_double_escaped_bracket_block(self): """Test double escaping a bracket.""" self.check_markdown( r''' \[3+2\\\] ''', r'''a $x$ b
''', # noqa: E501 True ) def test_hang_dollar(self): """ We are just making sure this works. Previously this pattern would hang. It isn't supposed to match due to the space before the last dollar, but it definitely shouldn't hang the process. """ self.check_markdown( r''' $z^{[1]} = \begin{bmatrix}w^{[1]T}_1 \\ w^{[1]T}_2 \\ w^{[1]T}_3 \\ w^{[1]T}_4 \end{bmatrix} \begin{bmatrix}x_1 \\ x_2 \\ x_3 \end{bmatrix} + \begin{bmatrix}b^{[1]}_1 \\ b^{[1]}_2 \\ b^{[1]}_3 \\ b^{[1]}_4 \end{bmatrix}= \begin{bmatrix}w^{[1]T}_1 x + b^{[1]}_1 \\ w^{[1]T}_2 x + b^{[1]}_2\\ w^{[1]T}_3 x + b^{[1]}_3 \\ w^{[1]T}_4 x + b^{[1]}_4 \end{bmatrix} $ ''', # noqa: E501 r'''$z^{[1]} = \begin{bmatrix}w^{[1]T}_1 \ w^{[1]T}_2 \ w^{[1]T}_3 \ w^{[1]T}_4 \end{bmatrix} \begin{bmatrix}x_1 \ x_2 \ x_3 \end{bmatrix} + \begin{bmatrix}b^{[1]}_1 \ b^{[1]}_2 \ b^{[1]}_3 \ b^{[1]}_4 \end{bmatrix}= \begin{bmatrix}w^{[1]T}_1 x + b^{[1]}_1 \ w^{[1]T}_2 x + b^{[1]}_2\ w^{[1]T}_3 x + b^{[1]}_3 \ w^{[1]T}_4 x + b^{[1]}_4 \end{bmatrix} $
''', # noqa: E501 True )