This commit is contained in:
wyn
2026-05-26 18:01:32 +08:00
parent fa878334cd
commit 7a3a1ed8c9
651 changed files with 4599 additions and 32312 deletions

View File

@@ -10,6 +10,7 @@ use PhpOffice\Math\Element;
use PhpOffice\Math\Exception\InvalidInputException;
use PhpOffice\Math\Exception\NotImplementedException;
use PhpOffice\Math\Math;
use PhpOffice\Math\Reader\Security\XmlScanner;
class MathML implements ReaderInterface
{
@@ -22,8 +23,17 @@ class MathML implements ReaderInterface
/** @var DOMXPath */
private $xpath;
/** @var XmlScanner */
private $xmlScanner;
public function __construct()
{
$this->xmlScanner = XmlScanner::getInstance();
}
public function read(string $content): ?Math
{
$content = $this->xmlScanner->scan($content);
$content = str_replace(
[
'⁢',
@@ -35,7 +45,7 @@ class MathML implements ReaderInterface
);
$this->dom = new DOMDocument();
$this->dom->loadXML($content, LIBXML_DTDLOAD);
$this->dom->loadXML($content);
$this->math = new Math();
$this->parseNode(null, $this->math);