handle aside tag

This commit is contained in:
quenousimporte 2024-08-28 15:57:56 +02:00
parent 488417582a
commit 0b3c66b99b
1 changed files with 18 additions and 26 deletions

View File

@ -12,6 +12,18 @@
require 'settings.php';
require 'TPEpubCreator.php';
function get_clean_html($node)
{
$innerHTM = '';
foreach ($node->childNodes as $childNode){
$nodeHTML = $childNode->ownerDocument->saveHTML($childNode);
$nodeHTML = str_replace('<aside', '<b><i', $nodeHTML);
$nodeHTML = str_replace('</aside', '</i></b', $nodeHTML);
$innerHTML .= $nodeHTML;
}
return '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
}
function add_mp_article($url, $context, $epub)
{
if (isset($_POST['mptoday']) && $_POST['mptoday'] && !str_contains($url, (new DateTime('today'))->format('dmy')))
@ -65,14 +77,8 @@
else
{
$node = $nodes->item(0);
$innerHTML = '';
foreach ($node->childNodes as $childNode){
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
$result .= '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
$epub->AddPage($result, false, $title);
$nodehtml = get_clean_html($node);
$epub->AddPage($nodehtml, false, $title);
}
}
@ -488,15 +494,8 @@
else
{
$node = $nodes->item(0);
$innerHTML = '';
foreach ($node->childNodes as $childNode){
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
$result .= '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
$epub->AddPage($result, false, $title);
$nodehtml = get_clean_html($node);
$epub->AddPage($nodehtml, false, $title);
}
}
@ -563,15 +562,8 @@
else
{
$node = $nodes->item(0);
$innerHTML = '';
foreach ($node->childNodes as $childNode){
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
$result .= '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
$epub->AddPage($result, false, $title);
$nodehtml = get_clean_html($node);
$epub->AddPage($nodehtml, false, $title);
}
}
}