-log2markup-

Description

-log2markup- extract parts of the text version from the Stata -log- command and transform the logfile into a markup based document with the same name, but with extension markup (or otherwise specified in option extension) instead of log.

Users may decide on all sorts of markup languages, eg Markdown, HTML, or LaTex.

The key is that markup of Stata code and Stata output can be set by the options.

-log2markup- produces a markdown document based on the log marking described here:

-log2markup- is based on the text version from the Stata -log- command.

See presentation at 2018 Nordic and Baltic Stata Users Group meeting Oslo

Adding text blocks

Text inside /*** and ***/ in a do file log will be considered as a markup text block.

Commenting code

Comments inside /* and */ are ignored in the document so it is also possible to keep comments for yourself.

Commented code which starts with a * or \\ are ignored as well.

Code lines as well as their outblocks are marked as markdown code blocks.

The appearance of code

Show only code in the markup document

If a code line is prefixed with /**/ only the code part is used in the markdown document.

Show only Stata output in the markup document

If a code line is prefixed with /***/ only the output part is used in the markdown document. However the output is marked as a code block in the markdown document.

Code blocks can be run, but ignored in document

Code blocks and markdown text blocks to be ignored are surrounded with //OFF and //ON so preparing code and its output can be seen in the log but not in the resulting markup document.

Show both command and output in the markup document

The command without any prefix will shown as well as it's output in log. This might be interesting when writing technical or educational Stata notes.

Integrate markup output into the markup document

If a code line is prefixed with /****/ only the code part is used in the markdown document, but now the output is inserted as ordinary markdown lines.

Hence output in eg HTML format can be integreted directly when the markdown document is transformed to HTML. The same goes for LaTex.

Installation

To install use the command: ssc install log2markup

Demonstration

The whole website is generate using -log2markup- and the command do2md.ado. At each page at the website, it is possible to download the generating do-file.

Running the do-file log2markup_example.do gives the markdown file log2markup_example.txt. The markdown file can converted using pandoc (if installed) to e.g. word by the Stata command: shell pandoc -s "output/log2markup_example.txt" -o "output/log2markup_example.docx" & timeout 30

Most will probably prefer a word template/reference doc. My current reference-doc is nhb-reference.docx.

Using pandoc with a reference-doc is done by: shell pandoc --reference-doc="nhb-reference.docx" -s "output/log2markup_example.txt" -o "output/log2markup_example.docx" & timeout 30

If word is installed, the do-file can be seen by the command: shell "output/log2markup_example.docx"

The word file using my reference-doc can be seen here


The do file for this document

Last update: 2022-04-21, Stata version 17