Marking Text as Code


(Serge) #1

Hi,

I’m making documentation and I’d like to put html code on the page, as you’d do with a code tag.

This is described here as working:

https://matrix.squiz.net/manuals/content-types/chapters/edit-editor#subscript-superscript

However it doesn’t seem to work with html code. As soon as I put html tags within the code tag, they get stripped out or the result doesn’t get shown (it gets interpreted instead).

Any idea of a workaround?


(Peter McLeod) #2

Hi
Are you are entering it in the source editor or the wysywg editor?
When you paste / or type the code into the wysiwyg editor it should convert to to html entities and display correctly.
Alternatively if you need a work around, could use a textarea and style it as needed.
Thanks
Peter


(Bart Banda) #3

Markdown is also a good alternative to add code documentation.
When I add code to pages on matrix.squiz.net, I just use the PRE tag and enter code into that in the WYSIWYG.


(Serge) #4

v.5.4.4.2

I’ve used raw html content container, and tried: pre, code, textarea and some others that should tell the code to be formatted as pasted.

You can try it for yourself, see if you can manage to show this on a page as text:

<link type="text/css" href="mysource_files/jquery.mmenu.all.css" rel="stylesheet">

Maybe it is an editplus setting someone else has set that would tell it to strip all non WYSIWYG tags out? Is there any such thing?


(Nic Hubbard) #5

You still have to convert that to HTML entities as the RAW HTML container will still think you are pasting in HTML, rather than wanting to show it to the frontend user.

Use: https://mothereff.in/html-entities


(Serge) #6

Then Squiz Matrix documentation needs to be rectified because it does not mention this issue. It says to wrap code within the code tag and that’s it.

Eg: We do not support the basic ability to display HTML code as provided in most WYSIYWG and wiki editors. You will have to rely on a 3rd party tool to circumvent that issue by converting into htmlentities.


(Nic Hubbard) #7

You said you are pasting into a RAW HTML container though. That be nature is only HTML and isn’t going to format any of the code you paste in.

If you paste HTML into the WYSIWYG editor that will change the code to HTML entities (not in source mode). Have you tried that?