version 1.1 September, 2014
help Synlight

Title

synlight -- Is a Stata HTML syntax highlighter. It converts smcl logfile to HTML and highlight Stata syntax. Visit
Synlight Homepage
for a complete guide on using Synlight package.

Author

E. F. Haghish

Center for Medical Biometry and Medical Informatics

University of Freiburg, Germany

haghish@imbi.uni-freiburg.de

http://stata-blog.com/ketchup

Syntax

synlight
smclfile
[, erase replace style(name) title() font(str) cmdfont(str) size() css(str)]

Main
replace replace the htmlfile if already exists

erase erase the smclfile after generating the HTML output

style(name) specifies the style theme which can be stata, daring, midnight, sunset, imbi, blackforest, desert, and cobalt

size(int) specifies the font size

cfont(str) specifies the font of Stata commands

font(str) specifies the font of Stata outputs

title(str) specify the title of the HTML file

css(str) specify the path to external CSS Style SHeet

Description

synlight is a HTML-based Stata syntax highlighter. It takes a Stata
smcl logfile as input, converts it to HTML, and post-processes the HTML
file to highlight Stata syntax. The output can be easily copy-pasted into websites/HTML documents.

Options

Main

replace rewrites a new HTML file if already exists.

erase removes the smclfile after converting it to HTML.

style(name) specifies the theme of the HTML document and also the CSS style sheet for syntax highlighting. The current version of synlight provides 8 syntax styles which are stata, daring, sunset, midnight, imbi, blackforest, desert, and cobalt.

size(int) specifies the font size of the HTML document. The default is 12px.

cfont(str) specifies the font for the Stata command. The default font family for Stata
commands are "Menlo-Regular", "Monaco", "Courier New" respectively. If the user's
OS does not support the first font, the latter font will be selected. All fonts are available
for download on Synlight Homepage.

font(str) specifies the font for the Stata output. The default font "Courier New".

title(str) prints the title of the HTML file on the top of the document.

css(str) links an external CSS style sheet to the document. If an external CSS is used,
synlight will only include CSS files that are essential for maintaining the essential
document which are the fonts, body, and classes of "<code>" and "<div>" tags. Stata codes are classified in <code class="code"> and Stata outputs are included in <div class="output"> tag. If the CSS includes similar information, the default basic CSS style will be ignored. In order to specify the file path to the external css, write the full file path or alternatively, the relative file path to the external file (Click here to see an example).

Remarks

To activate the full power of the synlight package, you should separate the arithmetic operators from one another. For example, in a command such as "local num =1+1", only "local", and the digits will be highlighted and "=" and "+" signs will not highlight.
However, if the command is written as "local num = 1 + 1", all arithmetic operators will be
highlighted. This decision has been made to avoid potential threat of highlighting something in the
Stata command which is not supposed to be highlighted.

When a command is nested with a brace (such as loops, etc), although very unlikely, but do not add any comment after the braces. The braces should be that last character in the line. Also,
avoid adding empty lines while using nested braces. The reason is that synlight attempts to
put all lines related to nested braces into the "<code>" and empty lines confuse the program.

If the logfile is closed using "qui log c" command, synlight automatically removes it from the end of the HTML file. However, any other command for terminating the logfile will be registered in the HTML file. This code was added to avoid unnecessary command at the end of the
HTML document.

The imbi style is named after "The Center for Medical Biometry and Medical Informatics (IMBI)" in University of Freiburg, where learned Stata programming and met amazing colleagues.

Example

Only specify the name of the logfile, without the file suffix.

. synlight smclfile, replace style(imbi) size(14) cfont(Monaco) font("Lucida Console")

Also see

Weaver: Advanced HTML & PDF Dynamic Report producer

Ketchup: Converting SMCL to a modern-looking HTML or PDF using Pandoc

MarkDoc: Converting SMCL to Markdown and other formats using Pandoc