Sample Code Interpreted as Bad HTML
Sample Code Interpreted as Bad HTML
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?
Re: Sample Code Interpreted as Bad HTML
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.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?
See here: https://www.w3schools.com/html/html_xhtml.asp
Re: Sample Code Interpreted as Bad HTML
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?
Re: Sample Code Interpreted as Bad HTML
OK. digging for info on escaping, I discovered the the "<" in the code sample needs to be escaped as < Problem solved!
Re: Sample Code Interpreted as Bad HTML
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.
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.
-
- Propeller Head
- Posts: 54
- Joined: Wed Sep 05, 2018 9:04 am
Re: Sample Code Interpreted as Bad HTML
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?
What is the solution for < and > symbols that must appear in sample code as text?
Re: Sample Code Interpreted as Bad HTML
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.
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.
-
- Propeller Head
- Posts: 54
- Joined: Wed Sep 05, 2018 9:04 am
Re: Sample Code Interpreted as Bad HTML
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.
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.
Re: Sample Code Interpreted as Bad HTML
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.
In XML Editor view, create a pre tag, then paste the code sample inside using the paste option Paste Inline Text.