handle aside tag
This commit is contained in:
parent
488417582a
commit
0b3c66b99b
44
epub.php
44
epub.php
|
@ -12,6 +12,18 @@
|
||||||
require 'settings.php';
|
require 'settings.php';
|
||||||
require 'TPEpubCreator.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)
|
function add_mp_article($url, $context, $epub)
|
||||||
{
|
{
|
||||||
if (isset($_POST['mptoday']) && $_POST['mptoday'] && !str_contains($url, (new DateTime('today'))->format('dmy')))
|
if (isset($_POST['mptoday']) && $_POST['mptoday'] && !str_contains($url, (new DateTime('today'))->format('dmy')))
|
||||||
|
@ -65,14 +77,8 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$node = $nodes->item(0);
|
$node = $nodes->item(0);
|
||||||
|
$nodehtml = get_clean_html($node);
|
||||||
$innerHTML = '';
|
$epub->AddPage($nodehtml, false, $title);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,15 +494,8 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$node = $nodes->item(0);
|
$node = $nodes->item(0);
|
||||||
|
$nodehtml = get_clean_html($node);
|
||||||
$innerHTML = '';
|
$epub->AddPage($nodehtml, false, $title);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,15 +562,8 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$node = $nodes->item(0);
|
$node = $nodes->item(0);
|
||||||
|
$nodehtml = get_clean_html($node);
|
||||||
$innerHTML = '';
|
$epub->AddPage($nodehtml, false, $title);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue