{smcl}
{* *! version 1.0.0 18jan2026}{...}
{vieweralsosee "ishere" "help ishere"}{...}
{vieweralsosee "markdown" "help markdown"}{...}
{viewerjumpto "Syntax" "tohtml##syntax"}{...}
{viewerjumpto "Description" "tohtml##description"}{...}
{viewerjumpto "Options" "tohtml##options"}{...}
{viewerjumpto "Examples" "tohtml##examples"}{...}
{title:Title}
{p2colset 5 16 18 2}{...}
{p2col:{cmd:tohtml} {hline 2}}Convert Stata log files to HTML reports{p_end}
{p2colreset}{...}
{marker syntax}{...}
{title:Syntax}
{pstd}
Basic usage
{p 8 16 2}
{cmd:tohtml} {it:filename}|{it:directory}
[{cmd:,} {it:options}]
{synoptset 25 tabbed}{...}
{synopthdr}
{synoptline}
{syntab:Output options}
{synopt:{opt md(filename)}}output Markdown file; default matches {opt html()} with {bf:.md}{p_end}
{synopt:{opt html(filename)}}HTML file; default is the input stem with {bf:.html}{p_end}
{synopt:{opt replace}}overwrite existing output files{p_end}
{syntab:Style options}
{synopt:{opt css(filename)}}custom CSS file; default is package resource {bf:tohtml.css}{p_end}
{synopt:{opt mathjax}}inject MathJax when equations are detected (independent of CSS){p_end}
{syntab:Table options}
{synopt:{opt tabwidth(size)}}max width of an inlined table box; overflow scrolls (default {bf:100%}){p_end}
{synopt:{opt tabheight(size)}}max height of an inlined table box; overflow scrolls (default {bf:80vh}){p_end}
{syntab:Portable package options}
{synopt:{opt bundle}}collect figures/tables into {bf:figures/} and {bf:tables/} under the HTML folder{p_end}
{synopt:{opt embed}}self-contained HTML: inline {bf:tohtml.css} and Base64 images{p_end}
{synopt:{opt zip(filename|.)}}create a zip archive of the HTML package (implies {cmd:bundle}); use {cmd:.} for default name{p_end}
{syntab:Cleaning modes}
{synopt:{opt clean}}keep only headings, images, and tables{p_end}
{synopt:{opt cleancode}}keep Stata commands from the log (drop output); retain figure/table embeds{p_end}
{syntab:Figure options}
{synopt:{opt width(string)}}set default width for images{p_end}
{synopt:{opt height(string)}}set default height for images{p_end}
{synopt:{opt zoom(string)}}set default zoom level for images{p_end}
{synoptline}
{p2colreset}{...}
{marker description}{...}
{title:Description}
{pstd}
{cmd:tohtml} is specifically designed to work hand-in-hand with {help ishere}, forming a unified workflow
embodied by the phrase: {it:everything is here: from do to html}. This design philosophy emphasizes
a minimalist approach to reproducible research—where "is here" corresponds to the {cmd:ishere} command
(marking where elements belong), and "to html" corresponds to the {cmd:tohtml} command (converting marked
logs into polished reports).
{pstd}
The core principle is simple: everything you need for your analysis lives in one place—your do-file.
You mark locations with {cmd:ishere}, run your analysis, and {cmd:tohtml} transforms the log into a
professional HTML report. No external tools, no manual editing, no copy-pasting—just a streamlined path
from code to publication-ready output.
{pstd}
{cmd:tohtml} converts Stata log files containing {help ishere} markers into formatted HTML reports.
The command can process a single log file or a directory containing multiple table and figure files. The latter gathers all table and figure files in the directory in a HTML.
{pstd}
{cmd:tohtml} provides the following main functions:
{pmore}
1. {bf:Clean log files}: Removes Stata log control characters and extraneous output to produce clean Markdown files.
{pmore}
2. {bf:Process markers}: Recognizes and processes {cmd:ishere} markers in log files, correctly formatting code blocks, headings, figures, and tables.
{pmore}
3. {bf:Generate HTML}: Converts cleaned Markdown to HTML with customizable or preset CSS styles.
{pmore}
4. {bf:Path management}: Supports resource file path replacement for generating portable reports.
{pmore}
5. {bf:Multiple modes}: Supports standard mode, minimal mode (clean), and code-only mode (cleancode).
{marker options}{...}
{title:Options}
{dlgtab:Output options}
{phang}
{opt md(filename)} specifies the output Markdown file. If omitted, the Markdown
path is the same as the HTML file with extension {bf:.md}
(e.g. {cmd:html(report.html)} → {bf:report.md}; omitted {opt html()} from
{bf:analysis.log} → {bf:analysis.md}). If {it:filename} does not
end with {bf:.md}, the extension is added automatically.
The Markdown output path must differ from the input file; otherwise {cmd:tohtml}
errors with {err:input file and Markdown output file must be different}
before any file is deleted. If the input is already a {bf:.md} file, specify
a different {opt md()} (or an {opt html()} whose basename is not the input).
{phang}
{opt html(filename)} converts the Markdown output to HTML after processing.
If omitted, the HTML path is the input stem with extension {bf:.html}
(e.g. {cmd:tohtml "analysis.log"} → {bf:analysis.html}).
If {it:filename} does not end with {bf:.html}, the extension is added automatically.
{phang}
{opt replace} overwrites existing output files. If this option is not specified and files exist,
the command will error.
{dlgtab:Style options}
{phang}
{opt css(filename)} applies a custom stylesheet to the generated HTML file.
When {opt css()} is omitted, the package resource
{bf:tohtml.css} (GitHub-like
layout). Pass a file path only when you want a different stylesheet; the
file must exist. The chosen CSS is copied to a
{bf:css/} subdirectory beside the HTML output. Iframe tables from
{cmd:collect} / {cmd:outreg2e} keep their own three-line styles and
are not restyled by {bf:tohtml.css}.
{phang}
{opt mathjax} enables MathJax for LaTeX formulas in the HTML report. This option
is independent of {opt css()}: you can combine MathJax with {bf:tohtml.css} or any
custom stylesheet. The MathJax CDN script is injected only when equation
delimiters are detected in the cleaned Markdown (e.g. {cmd:$...$}, {cmd:$$...$$},
{cmd:\(...\)}, {cmd:\[...\]}); otherwise nothing is linked. Requires
internet access when viewing formulas.
{dlgtab:Table options}
{phang}
{opt tabwidth(size)} sets the maximum width of each inlined table box
({cmd:.tohtml-embedded-table}). The box grows with the table up to this cap;
if the table is still wider, a horizontal scrollbar appears. The default is
{bf:100%} of the report content width. A value larger than {bf:100%} (e.g.
{cmd:tabwidth(1000%)}) lets the table extend past the text column instead of
scrolling. A bare number is treated as pixels ({cmd:tabwidth(800)} → {bf:800px}).
CSS lengths such as {cmd:100%}, {cmd:90vw}, and {cmd:800px} are accepted.
Use {cmd:none}, {cmd:off}, or {cmd:.} to disable the width cap.
{phang}
{opt tabheight(size)} sets the maximum height of each inlined table box.
If a table is taller than this, a vertical scrollbar appears. The default
is {bf:80vh} (80% of the browser viewport). A bare number is treated as
pixels ({cmd:tabheight(400)} → {bf:400px}). CSS lengths such as {cmd:80vh}
and {cmd:600px} are accepted. Use {cmd:none}, {cmd:off}, or {cmd:.} to let
the table grow with the page.
{phang}
These options apply in every report mode (default, {cmd:clean},
{cmd:cleancode}, and {opt embed}), because HTML tables are always inlined.
They require {opt html()}. They are independent of {opt width()}/{opt height()},
which only affect directory-mode figures.
{dlgtab:Portable package options}
{phang}
{opt bundle} reorganizes linked local resources so the HTML report is self-contained as a folder
tree. After HTML generation, {cmd:tohtml} scans {cmd:
} / {cmd: