I have written a JavaScript Syntax Highlighter for Stata code, named Statax, as a part of the Weaver package. It accurately highlights Stata commands, functions, strings, local and global macros, and numbers, braces, operators (not on the default CSS). Also a Stata package is written to allow you simply convert your do and ado files to HTML and highlight the syntax. The package is named Statax and can be installed from SSC server.
To make using the program easy, I have made it available online so that everyone can source it from my website's server. This will ensure that you will always run the most recent updated version. Although the program can be downloaded and installed manually as well. The JavaScript works as an addition to the SHJS.
In order to include the JavaScript engine in your webpage:
For downloading the program and seeing examples, visit the Statax web page. http://www.haghish.com/statax/statax.php
here is an example, using the Wrangler style:

Code:
ssc instal statax
In order to include the JavaScript engine in your webpage:
- Add the following script to the heading of your HTML document. <script type= "text/javascript" src= 'http://haghish.com/statax/Statax.js' ></script>
- Next include your Stata code withing the <pre> tag and sh_stata class as shown below. for example:
Code:
<pre class= "sh_stata" >
. Stata code
. Stata code
...
<pre>
here is an example, using the Wrangler style:
Comment