srchub-old

Syntaxhighlight


You are looking at an old revision of the page Syntaxhighlight. This revision was created by Natalie Adams.

How to use syntax highlighting

Introduction

srchub has 2 systems for syntaxhighlighting.

  • Syntaxhighlighter - http://alexgorbatchev.com/SyntaxHighlighter/
  • Prettyprint - https://code.google.com/p/google-code-prettify/

Syntaxhighliter

This is used when viewing source. You can use it in documentation/wiki as well.

If you would like to have links to lines in your sample code you can wrap your code in a <div id="highlight"> tag

For example:

1
2
3
4
5
6
7
<div id="highlight">
<pre class="brush: css">
 
/* some css */
 
</pre>
</div>

Note: for C/C++ examples if you are including a header file then you need to use the script tag rather than a pre tag.

Example:

1
2
3
<script type="syntaxhighlighter" class="brush: cpp">
 
</script>

Pros: Looks nicer, ability to select different themes from your project management page

Cons: Have to specify the language

Pretty print

Pretty print is a generic highlighter.

<pre class="prettyprint">
// some code
</pre>
// some code

Pros: It's simple

Cons: The highlighting isn't as good as syntaxhighlighter

Created: 11 years 28 days ago
by Natalie Adams

Updated: 10 years 3 months ago
by Natalie Adams

Labels:
Other:Featured

Old Revisions

Page rendered in 0.06218s using 26 queries.