Is it possible to do Code Syntax highlighting on sites.google.com websites like the way we do it on Blogger.com or Wordpress.com?
You can change how your text looks, add numbered or bulleted lists, or insert links in new Google Sites. On a computer, open a site in new Google Sites. At the top right, click Pages, then choose the page you want to edit. Highlight the text, or click where you want to insert a list or link.
Add HTML, CSS, or JavaScript code to your siteOn a computer, open a site in new Google Sites. Embed. You can also add an embed as an entire page.
Use the Insert menu, then HTML Box. Once the Insert HTML Box editor appears add the code you want to use. Google Sites checks the code, while you edit, for errors and will not add the code to the page until correct. Once finished use the Save button on the Insert HTML Box.
Although you do NOT need to code to build a Google site, it covers the design principles you need to consider to enable users to fully engage with your work.
Unfortunately there is until now no support for syntax highlighting within Google Sites. As a workaround you could use http://tohtml.com/ and enter your code there and copy the colored output (not the HTML) directly into your Google Sites page.
This works perfectly, as long as you don't need to edit large pieces of the code regularly.
I have tried creating a gadget myself with Google Code Prettify, and there were a few issues.
One is that classes aren't supported, so you will have to follow what Stack Overflow is doing to prettify. http://www.codingthewheel.com/archives/syntax-highlighting-stackoverflow-google-prettify
The other problem I faced was the interaction between the iframe and the parent frame. You will notice that there is a domain permission problem, and so you will be unable to access the parent.document from your iframe.
This should save some people a few hours of hacky testing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With