user2607347
user2607347

Reputation: 29

How to add Code Gadget on Google Sites

I have a google Site and I'm wondering how I can display code in a code block on my site, some thing similar to how code is displayed on stackoverflow or stackexchange. I've looked out for a google gadgets but couldn't find one. Any idea if there is already a gadget that does that or should I have to get one created.

public class code() {

//This is my Code

}

Upvotes: 0

Views: 513

Answers (2)

Jordan Rhea
Jordan Rhea

Reputation: 1206

You can open the HTML window on a page and use the code wrapped with a pre element. You can also add a style block in there to restyle how that code element will be displayed. Here is an example of a fiddle

<style>
pre {
  padding: 5px;
  background-color: black;
  color: white;
}
</style>
<p>
This is an example of a code block
</p>
<pre><code>
  public function exampleCode() {
    // this is where your code goes
  }
</code></pre>

Upvotes: 1

IGratch
IGratch

Reputation: 301

That's CSS and the 4 spaces just triggers it! If you know where your submitting the code you could probably just run a find and replace to "/n " and " " and make it to be the block id of code which would be a view-able change

Upvotes: 0

Related Questions