HTML tags in TinyMCE Editor...

HTML tags in TinyMCE Editor...

by Matt Johnson -
Number of replies: 5
I want to keep the TinyMCE editor for my text fields except for in one area where I want HTML tags to be printed literally (its the Part 1 text box when using a formula question type)....

Is there a way to set TinyMCE so it won't print the HTML tags literally and use what is put in the field as plain text instead? Even when I switch to code view and paste it there it will still mess it up when the question is saved.

Any guidance is appreciated, thanks.
Average of ratings: -
In reply to Matt Johnson

Re: HTML tags in TinyMCE Editor...

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Matt,

In most, if not all, question types and with the Atto and TinyMCE editors, you can directly type tags such as <p>, <br>, etc., while in display mode, as shown here. This appearance is preserved when you save the question. Notice the difference when you switch to the source code mode: the '<' character is represented as the HTML character entity reference '&lt;', and the '>' character is represented as '&gt;'. However, real HTML tags in the source code are displayed as '<p>', '<br>', etc.

In reply to Matt Johnson

Re: HTML tags in TinyMCE Editor...

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Do you mean syntax highlighting. For that there is an additional plug-in, the filter Syntax Highligher.
In reply to Visvanath Ratnaweera

Re: HTML tags in TinyMCE Editor...

by Matt Johnson -
No not that, when I paste any javascript or HTML code into the textarea field it will output literally when saved. Only way around it is to go into my profile and change to no editor when saving questions which is cumbersome.
In reply to Matt Johnson

Re: HTML tags in TinyMCE Editor...

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you are using the TinyMCE editor and you want to add HTML, you have to first select "View" then "< > Source code" in the editor's menu.

If you are using the Atto editor and you want to add HTML, you have to first click on the "" button then on the "< / >" button in the editor's menu.

Average of ratings: Useful (1)
In reply to Dominique Bauer

Odp: Re: HTML tags in TinyMCE Editor...

by Piotr F -
And this is what not works smoothly in the newest TinyMCE in Moodle 4.3.4:

empty lines,
either tag p

or tag br
(can't type them fully, as it doesn't display them here)


are visible when typed either in the WYSIWYG editor (enter or shift enter) or in the source code,
but not printed out after saving.
They are still there, in the code, just not displayed.

I am putting this here as the subject of the thread seems adequate.

This is the reason I am considering going back to Atto.
And this is definitely TinyMCE related:
when switched back to Atto, all empty lines are printed fine after save.
When switching to TMCE again, they are shown fine until opened in Tiny, and saved.
Then they are gone from the output.

Does anybody know any workaround?
There are obvious pros to use TinyMCE, and I would like to keep it if possible.