Próbuję pozwolić trochę data-attribute
z HTMLPurifier dla całego span
ale nie sposób ...HTMLPurifier - pozwalają dane attibute
Mam ten ciąg:
<p>
<span data-time-start="1" data-time-end="5" id="5">
<word class="word">My</word>
<word class="word">Name</word>
</span>
<span data-time-start="6" data-time-end="15" id="88">
<word class="word">Is</word>
<word class="word">Zooboo</word>
</span>
<p>
Moja HTMLPurifier config:
$this->HTMLpurifierConfigInverseTransform = \HTMLPurifier_Config::createDefault();
$this->HTMLpurifierConfigInverseTransform->set('HTML.Allowed', 'span,u,strong,em');
$this->HTMLpurifierConfigInverseTransform->set('HTML.ForbiddenElements', 'word,p');
$this->HTMLpurifierConfigInverseTransform->set('CSS.AllowedProperties', 'font-weight, font-style, text-decoration');
$this->HTMLpurifierConfigInverseTransform->set('AutoFormat.RemoveEmpty', true);
ja oczyścić mój $value
tak:
$purifier = new \HTMLPurifier($this->HTMLpurifierConfigInverseTransform);
var_dump($purifier->purify($value));die;
i otrzymaj:
<span>My Name</span><span>Is Zoobo</span>
Ale jak oszczędzać atrybuty moje dane id
, data-time-start
, data-time-end
w moim span
?
muszę mieć to:
<span data-time-start="1" data-time-end="5" id="5">My Name</span data-time-start="6" data-time-end="15" id="88"><span>Is Zoobo</span>
starałem się przetestować ten config:
$this->HTMLpurifierConfigInverseTransform->set('HTML.Allowed', 'span[data-time-start],u,strong,em');
ale komunikat o błędzie:
użytkownika Ostrzeżenie: Atrybut „data-czas -start 'in element' span 'not obsługiwany (informacje na temat implementacji tego, patrz wsparcie forów)
Dzięki za pomoc !!
EDIT 1
Próbowałam pozwolić identyfikatora w czasie firdt z tej linii kodu:
$this->HTMLpurifierConfigInverseTransform->set('Attr.EnableID', true);
to nie działa dla mnie ...
EDIT 2
Dla atrybutów data-*
dodaję tę linię, ale nic się nie dzieje ened też ...
$def = $this->HTMLpurifierConfigInverseTransform->getHTMLDefinition(true);
$def->addAttribute('sub', 'data-time-start', 'CDATA');
$def->addAttribute('sub', 'data-time-end', 'CDATA');
Dzięki za odpowiedź! Po raz pierwszy próbowałem włączyć ID, ale '$ this-> HTMLpurifierConfigInverseTransform-> set ('Attr.EnableID', true);' nie działa ... Wtedy dla specjalnych atrybutów, zobaczę, ale wygląda na to, być dla mnie trudnym ... Jestem debiutantem ... – Zagloo
@Zagloo: Czy upewniłeś się, że podałeś swoją definicję ID i numer rewizji (słabo pamiętam, że nie powoduje to problemów) i wyłączyć pamięć podręczną definicji podczas pracy nad nim? Niestety nie mam pojęcia, dlaczego 'Attr.EnableID' nie będzie działał dla ciebie, poza niezgodnością wersji, ale jest to część HTML Purifier prawie na zawsze, więc nie sądzę, że to jest to. :( – pinkgothic