HTML tag allowed

Hi,
I would like to use attributes “class” and “id” with div and p tags in TinyMCE editor.

I modified in config.inc.php

allowed_html = "<a href|target> <em> <strong> <cite> <code> <div class|id> <ul> <ol> <li> <dl> <dt> <dd> <b> <i> <u> <img src|alt> <sup> <sub> <br> <p class|id>"

and tried to add in HTML view of the editor something link

<div  class="test"><p class="test">test</p></div>

When I update the code, OJS strips the class attribute only for the div tag, in that way

<div><p class="test">test</p></div>

and it seems to me very strange, but I can not figure how it happens…

I’m using ojs 2.4.6 and I tried different syntax tipes in config.

Andrea

Hi @marchitelli,

Generally permitting IDs can be risky, so by default HTMLPurifier (the library we use to strip unsafe HTML) doesn’t allow them. See this page for details, including some other options:

http://htmlpurifier.org/docs/enduser-id.html

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
in earlier versions of OJS (in 2.4.1 for sure) id attributes was allowed. Now, with an update of HTMLPurifier, id are stripped in DIVs, breacking the layout of some journals that used custom IDs…

I would like to allow IDs but I can’t find the file where this configuration should be set.

Can you help me? I think that could be a problem for other OJS managers, too.

Thanks,a
andrea

Hi @asmecher,
would you please provide us with a specific page where to actually inhibit code purification? The documentation page you suggested explains how we should proceed pretty well, but it’s not clear how the library and OJS intertwine. What is (are) the file(s) we should edit, since the ‘allowed_html’ flag does not cover all cases?

Thanks in advance,
G.

Hi @asmecher and @gbrunialti,
I found a partial solution.

The problem is beteween HTMLpurifier library and TinyMCE plugin. I used the configuration

extended_valid_elements : "div[id|class]",

in /ojs/plugins/generic/tinymce/TinyMCEPlugin.inc.php

Moreover, it is necessary to add

<div id|class>

in OJS config.inc.it and only at this point it works.

It seems a bug, because you are forced to set twice (in two different positions) this option and not only in config, as usual.

Best regards,
Andrea

Hi @marchitelli,

I’m having the same problem on OMP but with target element on links, after updating from 1.0.

May I ask where did you add “extended_valid_elements : “div[id|class]”,” part to TinyMCEPlugin.inc.php?

I’ve gone through http://archive.tinymce.com/wiki.php/Configuration3x:extended_valid_elements but I don’t understand how to use it.

Thanks in advance!