Use of greater than > and less than < characters in post result in mangled code
Our forum requires that developers be able to post their code in their post for us to review and assist as necessary. Unfortunately, the use of the greater than > and less than < characters in post results in mangled code. For example:
Posted code:
<!DOCTYPE html>
Displayed code:
<!DOCTYPE html>
document.write("Hello World!");
I have disabled wysiwyg but "Simple HTML" is still enabled. I'd like to allow users to post their code and have it appear in its raw form even if the code contains HTML characters. I've read the the thread about disabling HTML tags and but obviously fear the loss of videos on existing posts...altho there was one comment: "old posts work because Vanilla stores the "Format" used for a single message." I've also read this thread about Markdown but want to make sure that doing this resolves the problem and not create more problems. I could simply try these and see what happens but I don't have access to make these changes so I want to make sure I've got a good solution before presenting it to the power that be.
What will work?
Any help will be much appreciated!
Answers
Well, I think I've got the answer. No Markdown...just disable HTML and see what happens.
grep is your friend.
Like so
<pre><!DOCTYPE html></pre>
grep is your friend.
another way
<!DOCTYPE html>
<- four space indentgrep is your friend.
Obviously the formatter is not physic it doesn't know when you want the markup to be rendered or as source. it also not it's job to render. Html has it own way of representing code.
<pre></pre>
for a script, and<code></code>
for in line script.grep is your friend.
hmm there is a bug I remember
<pre><b>test</b></pre>
-><code><b>test</b><code>
->test
<pre><b>test</b></pre>
->not ideal but you have to replace
<
with<
grep is your friend.
It is hard to say that the above is a bug becuase in a way that is the expected behaviour in html (if not the browser wouldn't render it so), certainly without pre-processing.
post client side solution would be
that is assuming you are not using some other post processing like prettify.
grep is your friend.
Yes, agreed that this is not a bug and is expected behavior. Decision to disable HTML occurred when I posted my question and the raw code didn't get posted (via Markdown) which was not a surprise. Appreciate you responding to this although we can't expect our users to modify their code to be able to post in our forum - most just copy and paste. I'll propose the post client solution and see what happens. Again, thanks for the quick response!