Thursday, January 27, 2011

Blog Posts | Post your code nicely

On my way to try this

Google SyntaxHighlighter
http://code.google.com/p/syntaxhighlighter/wiki/Usage

Download latest version
http://code.google.com/p/syntaxhighlighter/downloads/list

Note: Blogger replaces line feeds by <br> so all your code will appear in line 01, unless you add (before HideAll!):

dp.SyntaxHighlighter.BloggerMode();


Here goes all code needed (with javascript, c# and xml code transformations):

<link href='http://mywebsiteurl/syntax/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://mywebsiteurl/syntax/shCore.js'/>
<script language='javascript' src='http://mywebsiteurl/syntax/shBrushCSharp.js'/>
<script language='javascript' src='http://mywebsiteurl/syntax/shBrushXml.js'/>
<script language='javascript' src='http://mywebsiteurl/syntax/shBrushJScript.js'/>
<script language='javascript'>
window.onload = function () {
dp.SyntaxHighlighter.ClipboardSwf = 'http://mywebsiteurl/syntax/clipboard.swf';
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
}
</script>


* This code is assuming you place all contents of Styles, JavaScript and Flash Folders within the same folder (syntax) inside mywebsiteurl site.

2 comments:

  1. Hey again tiago :) I have a problem with Java using Vista, but in XP (PC) It works just fine. Do you have any clue what should I do? Someone at work told me I should reinstall anything to do with programming in my laptop and try again.

    ReplyDelete
  2. Hi cartoner.

    First, you should understand that "JavaScript" is a Web oriented scripting language.

    "Java" is an actual object oriented programming language that we usually use to create complex applications. There are some programming interfaces that already include the SDKs and Java stuff needed, such as NetBeans (http://netbeans.org/downloads/index.html).
    Uninstalling and reinstalling everything (Java Runtimes, IDEs, etc) is always a way to make sure you get things working, but depending on your "problem" it could mean doing simpler things, such as installing Java RunTime (http://www.java.com/en/download/) or adding Java's path to the System Path (System properties, environment variables, system variables, path)

    ReplyDelete