Sample Code Interpreted as Bad HTML

This forum is for all Flare issues not related to any of the other categories.
Post Reply
smbaird
Jr. Propeller Head
Posts: 7
Joined: Wed Apr 20, 2016 11:52 am

Sample Code Interpreted as Bad HTML

Post by smbaird »

I had a piece of code I need to insert into a topic but it is being read as bad HTML code (invalid syntax). How can I get the code the render correctly in the topic? Anyone?
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Sample Code Interpreted as Bad HTML

Post by NorthEast »

smbaird wrote:I had a piece of code I need to insert into a topic but it is being read as bad HTML code (invalid syntax). How can I get the code the render correctly in the topic? Anyone?
At a guess, it's probably because the code isn't valid XHTML. XHTML is used for Flare's topic editor, and has some differences to HTML - e.g. you must always close tags.
See here: https://www.w3schools.com/html/html_xhtml.asp
smbaird
Jr. Propeller Head
Posts: 7
Joined: Wed Apr 20, 2016 11:52 am

Re: Sample Code Interpreted as Bad HTML

Post by smbaird »

Yes I realize that my sample code is not XHTML or even HTML. Is there a way to escape this string so that the XHTML parser doesn't try to read it is XHTML?
smbaird
Jr. Propeller Head
Posts: 7
Joined: Wed Apr 20, 2016 11:52 am

Re: Sample Code Interpreted as Bad HTML

Post by smbaird »

OK. digging for info on escaping, I discovered the the "<" in the code sample needs to be escaped as < Problem solved!
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Sample Code Interpreted as Bad HTML

Post by NorthEast »

You didn't say it was sample code (to be displayed as text).

Just paste the code in the XML Editor, rather than trying to paste it in the Text Editor.

If you want to preserve formatting, insert a pre tag first, then paste the sample code inside that, and choose the paste option Paste Inline Text.
ArdisRamey
Propeller Head
Posts: 54
Joined: Wed Sep 05, 2018 9:04 am

Re: Sample Code Interpreted as Bad HTML

Post by ArdisRamey »

The <pre> tag helps with almost everything - but it won't fix this problem when it comes to < and >.

What is the solution for < and > symbols that must appear in sample code as text?
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Sample Code Interpreted as Bad HTML

Post by NorthEast »

So what exactly is the problem you're having?

The < and > symbols work fine for me. If I enter < > in XML Editor view, then Flare converts these to < and > in the underlying HTML.
If you copy/paste the code from the output, it's put on the clipboard as < > correctly.
ArdisRamey
Propeller Head
Posts: 54
Joined: Wed Sep 05, 2018 9:04 am

Re: Sample Code Interpreted as Bad HTML

Post by ArdisRamey »

That may be another huge difference between the Text Editor and the XML Editor, then.

I author primarily in the Text Editor, and only hop into the XML Editor if I'm forced to to access functionality that's excluded from the Text Editor.

I'll have to give it a try in the XML Editor and see whether that fixes the problem.
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Sample Code Interpreted as Bad HTML

Post by NorthEast »

Yeah, whatever you enter in the text editor has to be valid (X)HTML.

In XML Editor view, create a pre tag, then paste the code sample inside using the paste option Paste Inline Text.
Post Reply