コード例 #1
0
ファイル: test_plugin_math.py プロジェクト: ryan100/ecromedos
    def test_handleMathNodeLatex(self):
        root = etree.fromstring("<root><m>Formula Here</m></root>")

        config = {
            "latex_bin": "/usr/bin/latex",
            "dvipng_bin": "/usr/bin/dvipng",
            "tmp_dir": "/tmp"
        }

        plugin = math.getInstance(config)
        plugin.process(root.find("./m"), "latex")

        tree = etree.ElementTree(element=root)
        result = etree.tostring(tree, encoding="utf-8", method="xml")

        expected_result = b'<root><m><copy>Formula Here</copy></m></root>'
        self.assertEqual(result, expected_result)
コード例 #2
0
ファイル: test_plugin_math.py プロジェクト: tobijk/ecromedos
    def test_handleMathNodeLatex(self):
        root = etree.fromstring("<root><m>Formula Here</m></root>")

        config = {
            "latex_bin": "/usr/bin/latex",
            "dvipng_bin": "/usr/bin/dvipng",
            "tmp_dir": "/tmp"
        }

        plugin = math.getInstance(config)
        plugin.process(root.find("./m"), "latex")

        tree = etree.ElementTree(element=root)
        result = etree.tostring(tree, encoding="utf-8", method="xml")

        expected_result = b'<root><m><copy>Formula Here</copy></m></root>'
        self.assertEqual(result, expected_result)
コード例 #3
0
ファイル: test_plugin_math.py プロジェクト: ryan100/ecromedos
    def test_handleMathNodeXHTML(self):
        root = etree.fromstring("<root><m>Formula Here</m></root>")

        with tempfile.TemporaryDirectory() as tmpdir:
            config = {
                "latex_bin": "/usr/bin/latex",
                "dvipng_bin": "/usr/bin/dvipng",
                "tmp_dir": tmpdir
            }
            plugin = math.getInstance(config)
            plugin.process(root.find("./m"), "xhtml")
            plugin.flush()
        #end with

        tree = etree.ElementTree(element=root)
        result = etree.tostring(tree, encoding="utf-8", method="xml")

        expected_result = b'<root><copy><img src="m000001.gif" alt="formula" class="math" style="vertical-align: -1px;"/></copy></root>'
        self.assertEqual(result, expected_result)
        os.unlink("m000001.gif")
コード例 #4
0
ファイル: test_plugin_math.py プロジェクト: tobijk/ecromedos
    def test_handleMathNodeXHTML(self):
        root = etree.fromstring("<root><m>Formula Here</m></root>")

        with tempfile.TemporaryDirectory() as tmpdir:
            config = {
                "latex_bin":  "/usr/bin/latex",
                "dvipng_bin": "/usr/bin/dvipng",
                "tmp_dir":    tmpdir
            }
            plugin = math.getInstance(config)
            plugin.process(root.find("./m"), "xhtml")
            plugin.flush()
        #end with

        tree = etree.ElementTree(element=root)
        result = etree.tostring(tree, encoding="utf-8", method="xml")

        expected_result = b'<root><copy><img src="m000001.gif" alt="formula" class="math" style="vertical-align: -1px;"/></copy></root>'
        self.assertEqual(result, expected_result)
        os.unlink("m000001.gif")