private function parseLiteral(&$content, $restore = false)
{
$regex = $this->getRegex($restore ? 'restoreliteral' : 'literal');
if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) {
if (!$restore) {
$count = count($this->literal);
// 替换literal标签
foreach ($matches as $match) {
$this->literal[] = substr($match[0], strlen($match[1]), -strlen($match[2]));
$content = str_replace($match[0], "<!--###literal{$count}###-->", $content);
$count++;
}
} else {
// 还原literal标签
foreach ($matches as $match) {
$content = str_replace($match[0], $this->literal[$match[1]], $content);
}
// 清空literal记录
$this->literal = [];
}
unset($matches);
}
return;
}