4

I'm trying to paste some example XML snippets into a blog post on blogger, but every time I save or preview the post, blogger seems to remove my XML tags and just display the parameters. I can't find a way of retaining code, there is no "code" button on the WYSIWYG editor

For example,

<MyTag>
 <myValue>some value</myValue>
</MyTag>

Becomes

some value

I've tried to surround it with the pre tag but that doesn't work either

Any ideas? I'd rather not have to screenshot code as that rules out copy/pasting in the future

migrated from superuser.com May 13 '11 at 23:55

This question came from our site for computer enthusiasts and power users.

7

I've been using tohtml to format code for a while, and I just tested its output with blogger and it works. It will even give you syntax highlighting.

2

&lt; and &gt should go in place of the angle brackets.

This isn't an issue with blogger, rather your web browser interpreting the <>s as tags, and so not displaying them. &lt; and &gt; mean < and >, respectively, to your web browser.

  • Thanks Phoshi, I was considering using that but didn't like the idea of doing that over a 50+ line snippet of code ;) – James.Elsey Nov 8 '09 at 21:31
  • Ouch! You could try a find&replace, I suppose? :P – Phoshi Nov 8 '09 at 21:42
2

Copy and paste source code onto: http://formatmysourcecode.blogspot.com/

It replaces any non-alphanumeric characters in your text, so you can then copy/paste it into your blog

0

You can also paste your code to gist and a pretty link is available to display gist code in your blog, for example :

<script src="https://gist.github.com/Ameausoone/4714699.js"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy