8000 GitHub - haghish/statax at 1.7
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

haghish/statax

Repository files navigation

Statax : JavaScript and LaTeX syntax highlighter engine for Stata

statax is a syntax highlighter for Stata. The packages includes two separate engines (JavaScript and LaTeX) to highlight Stata commands in HTML- and LaTeX-based documents. A plenty of Stata package produce documents or presentation slides in HTML and LaTeX and the engines can simply be wired to these packages to highlight the syntax of Stata commands. For example, weaver and MarkDoc packages require statax for syntax highlighting. Long story short, syntax highlighters might improve code comprehension and encourage learners to pay more attention to the code.

statax can acurately distinguish several different elements in Stata syntax such as:

  1. commands
  2. functions
  3. local and global macros
  4. strings
  5. numbers
  6. operators
  7. comments
  8. curly brackets

The JavaScript engine is hosted on my website and can be easily added to any webpage. See Statax Homepage for details. in brief, all you have to do to load the javaScript in your HTML document is adding the following code:

<script type="text/javascript" src='http://haghish.com/statax/Statax.js'></script>

And writing your Stata code in:

<pre class="sh_stata">
	. Stata code
	. Stata code
	...
</pre>

The LaTeX syntax highlighter is even easier to implement. All you need to do is loading the Statax.tex in the header of your latex document, before you \begin{document} as shown below:

\input{Statax}

Once the Statax file is loaded in the header, You can call the statax environment to highlight the Stata syntax. For example:

\begin{statax}
	
	// JavaScript Syntax Highlighter for Stata
	
	quietly erase "`This' $Example"
	noisily do `Something'
	forvalues num = 5/13 {
	count if vari`num' > 10 //this is a comment
	scalar 5 = 2 * 10 
	generate x = runiform()
	}
	
	/*
	E. F. Haghish
	Center for Medical Biometry and Medical Informatics
	Unersity of Freiburg, Germany
	*/

\end{statax}

Author

E. F. Haghish
Center for Medical Biometry and Medical Informatics University of Freiburg, Germany
haghish@imbi.uni-freiburg.de
http://www.haghish.com/weaver
@Haghish

Installation

The Statax releases are also hosted on SSC server. So you can download the latest release as follows:

ssc install statax

You can also directly download Statax from GitHub which includes the latest beta version (unreleased). The force option ensures that you reinstall the package, even if the release date is not yet changed, and thus, must be specified.

net install statax, force  from("https://raw.githubusercontent.com/haghish/statax/master/")

The complete guide for installing them is provided in the MarkDoc help file and also, Statax Homepage

0