Is it possible to provide Code highlighting on sites.google.com websites?
Asked Answered
C

5

14

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?

Commerce answered 7/12, 2009 at 5:54 Comment(0)
H
12

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.

Handcraft answered 31/3, 2011 at 10:17 Comment(3)
This is similar to what we do; instead of tohtml we use Quick Highlighter (with the 'Combine Style and HTML Code' checkbox checked) because we like the output better; instead of copying the colored output we copy the HTML, and paste it into the html view of the Google Sites editor. This works very well, but as you say, is pretty painful if you're looking to edit the code often.Fadden
You guys are awesome, thanks a lot for your links! I can now make the codes on my blog look nice! codeofaninja.com . Again thanks a lot! :)Lavish
Quick Highlighter is unusable for TSQL as it adds spaces within bracketed [Fieldnames].Frijol
D
4

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.

Divinize answered 14/2, 2012 at 13:24 Comment(0)
I
4

Yes, you can! Just select the desired text, and go to "Formatting" -> "Code" OR "Block Code"

Inadvertent answered 28/2, 2019 at 11:5 Comment(0)
A
3

I've found an alternative way.

If you use IntelliJ, just copy the code from the IntelliJ editor and paste it into your Google site text (not in html mode).

Works out-of-the-box!

Ardeb answered 30/9, 2015 at 18:27 Comment(0)
M
2

You can insert gadgets into Google Sites pages. You could create a gadget that did syntax highlighting using any number of open source javascript syntax highlighters.

Not an ideal solution but would get you what you want. Lemme know if you want further pointers.

Michal answered 7/12, 2009 at 6:9 Comment(1)
Check out the gadgets API here: code.google.com/apis/gadgets/docs/gs.html And the gadgets editor here: code.google.com/apis/gadgets/docs/tools.html#GGE And here's a javascript code highlighter: code.google.com/p/syntaxhighlighterMichal

© 2022 - 2024 — McMap. All rights reserved.