Hey Ross, my guess is that either TinyMCE (or whatever richtext editor you
are using) or Bleach is doing this.

Take a look at
https://bitbucket.org/stephenmcd/mezzanine/src/85053c4590cd57c218718f9a99ee7f1ab2100319/mezzanine/core/defaults.py?at=default#cl-253

If Bleach is the culprit then adding canvas to that setting should fix it.
Putting something like:

register_setting(    name="RICHTEXT_ALLOWED_TAGS",
description=_("List of HTML tags that won't be stripped from "
"``RichTextField`` instances."),    editable=False,
    append=True,
    default=("canvas",),
 )

In your own default.py file will add canvas to the allowed list.

If TinyMCE is the culprit I'm not sure how to fix it but you may be able to
fix it by customizing the tinymce setup file,
https://bitbucket.org/stephenmcd/mezzanine/src/85053c4590cd57c218718f9a99ee7f1ab2100319/mezzanine/core/static/mezzanine/js/tinymce_setup.js?at=default

On Fri, Oct 31, 2014 at 12:00 PM, Ross Laird <[email protected]> wrote:

> Turns out that the tag is not being stripped out but the display of the
> tag inside the editor is being changed.
> When I add <canvas> ... </canvas> within the editor, then save, then
> re-open the HTML editing window, the canvas tag is changed to <p> ... </p>.
> I see the p tag, and no canvas tag, in the editor.
> But when I add the canvas tag inside the editor, save it, then look at the
> source code of the resulting page (on the site), the canvas tag is indeed
> there (and there is no p tag at that location).
> So, the canvas tag is being accepted properly; but it is being shown as a
> p tag inside the text editor.
>
> On Thursday, 30 October 2014 20:10:14 UTC-7, MattQ wrote:
>>
>> Add this line to your view:
>> print( page.portfolioitem.content)
>> And see the results in the console. You'll see right away if the tags are
>> already stripped or not. If so, they were stripped upstream prior to
>> getting saved in the db. Otherwise, if the tags are there, then you can
>> focus on why the template is stripping them.
>>  On Oct 30, 2014 7:58 PM, "Ross Laird" <[email protected]> wrote:
>>
>>> But sadly, still no...
>>>
>>> On Thursday, 30 October 2014 19:56:21 UTC-7, Ross Laird wrote:
>>>>
>>>> Oh, silly, silly. I should try this:
>>>>
>>>> {{ page.portfolioitem.content|safe }}
>>>>
>>>> On Thursday, 30 October 2014 19:50:48 UTC-7, Ross Laird wrote:
>>>>>
>>>>> Thanks for the reply. At least it sounds like there is a way to do
>>>>> this. However --
>>>>>
>>>>> I've tried this:
>>>>>
>>>>>      {{ page.portfolioitem.content|richtext_filters|safe }}
>>>>>
>>>>> and this:
>>>>>
>>>>>      {{ page.portfolioitem.content|richtext_filters|var|safe }}
>>>>>
>>>>> and this:
>>>>>
>>>>>      {{ page.portfolioitem.content||var|safe }}
>>>>>
>>>>> None of these seem to work.
>>>>>
>>>>> Am I missing something very simple?
>>>>>
>>>>>
>>>>> On Thursday, 30 October 2014 19:29:19 UTC-7, MattQ wrote:
>>>>>>
>>>>>> For me it was Django built-in templating system that was stripping my
>>>>>> tags. I solved this by using "safe" template filter.
>>>>>> {{ var | safe }}
>>>>>>
>>>>>> here's the docs:
>>>>>> https://docs.djangoproject.com/en/dev/ref/templates/builtins
>>>>>> /#std:templatefilter-safe
>>>>>>
>>>>>> Hope this helps.
>>>>>> -matt
>>>>>>
>>>>>> On Thu, Oct 30, 2014 at 7:21 PM, Ross Laird <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> I'd like to render some charts, using Chart.js, but I can't seem to
>>>>>>> get the canvas tag to be preserved when I enter it into a rich text 
>>>>>>> page. I
>>>>>>> have tinyMCE set up to accept all tags, and I have also added canvas to 
>>>>>>> the
>>>>>>> ALLOWED_TAGS in defaults.py (thinking that this might not actually be a
>>>>>>> tinyMCE issue). But *something *continues to strip out these tags.
>>>>>>> Anybody have an idea what's going on?
>>>>>>>
>>>>>>> I suppose I might have to create a custom template for this, if I
>>>>>>> can't get it working through the interface.
>>>>>>>
>>>>>>> Ross
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Mezzanine 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.
>>>>>>>
>>>>>>
>>>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Mezzanine 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.
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Mezzanine 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine 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.

Reply via email to