SyntaxHighlighter 3.0.83

Fork Me On GitHub
whats new?
SyntaxHighlighter is an open source Java Script client side code syntax highlighter.
donate download installation autoloader configuration @syntaxhighlight

Upgrading from 1.5 to 3.x

If you have been using SyntaxHighlighter 1.5 for some time now, you already have a lot of content with the <pre /> tags configured the old 1.5 way. In order to maintain backward compatibility and allow you to move forward with the new version 3.x, you can use what I call a “transition proxy” provided in the shLegacy.js file.

shLegacy.js creates a proxy call compatible with 1.5. A call to dp.SyntaxHighlighter.HighlightAll('code') is transparently converted to a proper call to SyntaxHighlighter.all() together with 1.5 configuration options like class="html:collapse" to 3.x compatible on the fly.

How to

To get both 1.5 and 3.x highlighter elements to work on your site, you have to add shLegacy.js and keep the call to HighlightAll:

      <html>
      	<head>
      		<link type="text/css" rel="stylesheet" href="/Styles/shCore.css" />
      		<link type="text/css" rel="stylesheet" href="/Styles/shThemeDefault.css" />
      		<script type="text/javascript" src="/Scripts/shCore.js"></script>
      		<script type="text/javascript" src="/Scripts/shLegacy.js"></script>
      		<script type="text/javascript" src="/Scripts/shBrushJScript.js"></script>
      		<script type="text/javascript" src="/Scripts/shBrushBash.js"></script>
      		<script type="text/javascript" src="/Scripts/shBrushCpp.js"></script>
      		<script type="text/javascript">
      			SyntaxHighlighter.all();
      			dp.SyntaxHighlighter.HighlightAll('code');
      		</script>
      	</head>

      	...