You can tune the tags and attributes that XML will allow.
XML has a parameter called "permitted_tags." It is a list of tags that XML
will not escape.
You could, at the top of your controller, create your own list of permitted
tags. Then call XML like this:
XML(row.contents, sanitize=True, permitted_tags=permitted_tags)
This is what the permitted_tags parameter looks like with the added entry
for em. You can find it in gluon/html.py around line 1536.
permitted_tags=[
'a',
'b',
'blockquote',
'br/',
'i',
'li',
'ol',
'ul',
'p',
'cite',
'code',
'pre',
'img/',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'table', 'tr', 'td', 'div',
'strong','span',
# entry below added
'em'
],
If you look at the XML class in html.py you will see another parameter
called "allowed_attributes." I suppose you could make your own dictionary
to allow a style attribute for some html tags and pass it in when you call
XML.
On Wednesday, July 2, 2014 5:30:18 AM UTC-4, Annet wrote:
>
> In a view I have the following line:
>
> {{=XML(row.contents, sanitize=True)}}
>
> When 'contents' contains an <em></em> element add by tinymce, this element
> isn't being rendered:
>
> <em>My text ....</em>
>
> Other elements like <p></p> <strong></strong> are being rendered correctly.
>
> Furthermore, when tinymce adds a style to an element:
>
> <p style="text-align: center;">My text ....</p>
>
> This is being rendered without the style:
>
> <p>My text ...</p>
>
> Is there a way to solve these issues.
>
>
> Regards,
>
> Annet
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.