Welcome! » Log In » Create A New Profile

Can I keep the name attribute without having id's?

Posted by joelguesclin 
Can I keep the name attribute without having id's?
November 09, 2016 07:00PM

I have some rather old HTML which was generated using something like CKeditor (it was probably TinyMCE or maybe even something older). The text (held in a database) makes extensive use of footnotes: long articles with references to footnotes that appear at the bottom. For some reason the 'a' tags have the 'name' attribute, but not the 'id' attribute, so that a reference from a footnote reference number back to the footnote looks like this:

<a href="/ri/054_decadence_part04.html#_ftnref2" name="_ftn2">[2]</a>

The footnote itself, in the text, is the same but the other way round. So, although I have set up the configuration like this:

    $config->set(&#039;Attr.EnableID&#039;, true);
    $config->set(&#039;HTML.Allowed&#039;, &#039;p,b,a[href][name],img[src][alt]&#039;);

The "name" still gets removed. Is there any way round this?

Re: Can I keep the name attribute without having id's?
November 10, 2016 12:37AM

Your %HTML.Allowed syntax is not correct; use a pipe to separate values.

Re: Can I keep the name attribute without having id's?
November 10, 2016 02:29AM

Thanks - so I tried it like this:

    $config->set(&#039;Attr.EnableID&#039;, true);
    $config->set(&#039;HTML.Allowed&#039;, &#039;p,b,a[href|name],img[src|alt]&#039;);

But the "name" still gets stripped out. Is there some way of putting in id's if there aren't any? I'm basing myself on this bit of the documentation by the way

Edited 1 time(s). Last edit at 11/10/2016 03:17AM by joelguesclin.

Re: Can I keep the name attribute without having id's?
November 10, 2016 10:06AM

Oh oops, the problem is that the id validator is rejecting names with leading underscore. Set %HTML.Attr.Name.UseCDATA to true.

Re: Can I keep the name attribute without having id's?
November 11, 2016 07:34AM

Cool, that works, thanks

Sorry, you do not have permission to post/reply in this forum.