编辑: 252276522 | 2017-10-07 |
com dyndoc ― Convert dynamic Markdown document to an HTML ?le Description Syntax Options Remarks and examples References Also see Description dyndoc converts a dynamic Markdown document―a document containing both formatted text and Stata commands―to an output ?le in HTML format. Stata processes the Markdown text and Stata dynamic tags (see [P] dynamic tags) and creates the output HTML ?le. Markdown is a simple markup language with a formatting syntax based on plain text. It is easily converted to an output format such as HTML. Stata dynamic tags allow Stata commands, output, and graphs to be interleaved with Markdown text. If you want to convert a Markdown document without Stata dynamic tags to an HTML document, see [P] markdown. If you want to convert a plain text ?le containing Stata dynamic tags to a plain text output ?le, see [P] dyntext. Syntax dyndoc src?le arguments , options src?le is a plain text ?le containing Markdown-formatted text and Stata dynamic tags. arguments are stored in the local macros '
1'
, '
2'
, and so on for use in src?le;
see [U] 16.4.1 Argument passing. You may enclose src?le and target?le in double quotes and must do so if they contain blanks or other special characters. options Description saving(target?le) specify the target HTML ?le to be saved replace replace the target HTML ?le if it already exists hardwrap replace hard wraps (actual line breaks) with the HTML tag nomsg suppress message of a link to target?le nostop do not stop when an error occurs Options saving(target?le) speci?es the target ?le to be saved. If saving() is not speci?ed, the target ?lename is constructed using the source ?lename (src?le) with the .html extension. replace speci?es that the target ?le be replaced if it already exists. hardwrap speci?es that hard wraps (actual line breaks) in the Markdown document be replaced with the HTML line break tag .
1 2 dyndoc ― Convert dynamic Markdown document to an HTML ?le nomsg suppresses the message that contains a link to the target ?le. nostop allows the document to continue being processed even if an error occurs. By default, dyndoc stops processing the document if an error occurs. The error can be caused by either a malformed dynamic tag or by executing Stata code within the tag. Remarks and examples stata.com A dynamic document contains both static narrative and dynamic tags. Dynamic tags are instructions for dyndoc to perform certain actions, such as run a block of Stata code, insert the result of a Stata expression in text, export a Stata graph to an image ?le and include a link to the image ?le, etc. Any changes in the data or in Stata will change the output as the document is created. The main advantages of using dynamic documents are ? results in the document come from executing commands instead of being copied from Stata and pasted into the document;
? no need to maintain parallel do-?les;
and ? any changes in data or in Stata are re?ected in the ?nal document when it is created. Example
1 Let us consider an example. Suppose that we have dyndoc ex.txt with the following Markdown- formatted text that includes Stata dynamic tags. begin dyndoc ex.txt Using Stata dynamic tags in a text file with the dyndoc command Let us consider an example where we study the **mpg** and **weight** variables in **auto.dta**. In our examples below, we will first write the commands so that they will be displayed in our target HTML file. Then, we will write the commands so that Stata will process the Stata dynamic tags, displaying the results of the Stata commands in the target HTML file. We first use the **sysuse** command to load the dataset and then describe the data using the **describe** command. ~~~~ sysuse auto, clear describe ~~~~ This produces the following Stata results: ~~~~ sysuse auto, clear describe ~~~~ Now, we want to check if **mpg** is always greater than