Stata Markdown

Posted on  by 



  1. Stata Markdown Version
  2. Stata Markdown Latex
  3. Mark Down Price Formula

Within Stata there is a dynamic markdown package called stmd that relies on Stata's dyndoc command, as well as the user-written package markstat. Each has it's strengths and weaknesses. The system I will describe here is intended primarily for those of us who are already using R Markdown to write documentation in other languages, and would like.

    • Jun 2019
    • 23

    Stata markdown: can dyndoc create md files instead of html?

    I'm working in a project with many collaborators, all of which have Stata version 15. We use the dyndoc command to generate the documentation of our datasets, but need the documentation to be .md instead of .html (default in dyndoc), so it's all easily displayed and linked in Github, which we use to maintain the project.
    Currently, the solution is to call Pandoc after every dyndoc to convert from .html to .md (see mock code). The downside is that it requires that every user installs Pandoc and points it is in Stata, which is not a trivial task for all our collaborators.
    Given that there is a markdown command in Stata 15, I suspect that there must be a better way to do this from within Stata, without having to resort to Pandoc. But looking at the dyndoc and markdown ados in the base folder I could not figure out how... Any suggestions?
    Thanks for any advice!
    • Jun 2014
    • 235
    Yes, you can. dyndoc uses dyntext first to process all dynamic tags, then call markdown to convert the resulted mrakdown document to html. Using dyntext alone will leave you the markdown file.
    For example, the following example.txt is a markdown file with dynamic tags
    Use command
    will produce the following markdown file example.md
    And you can use the command:
    to get the HTML file example.html.
    Last edited by Hua Peng (StataCorp); 13 Jul 2019, 16:36.

    Comment

    • Jun 2019
    • 23
    Perfect, thank you!

    Comment

Updated on 14 July 2014

Quando scrivo qualcosa nel campo markdown del taccuino jupyter, gli errori di battitura non vengono evidenziati e spesso mi sono ritrovato con qualcosa del genere: In quasi tutti gli IDE che ho. My Stata commands. In practice markdown documents are often transformed using eg Pandoc and so The Pandoc User Guide is quite often necessary if.

Stata Markdown - the Flexmark Specification. There are many different flavors of the Markdown specification for writing documents. Keywords: Stata, webdoc, HTML, Markdown, weaving, Stata output, Stata log, reproducible research Contents 1 Introduction 3 2 The webdoc command 4 2.1.

Quick Tips

Several packages such as MarkDoc, Weaver, and ketchup have been written for Stata to make Markdown codes available for Stata. Markdown provides a simple solution for writing and styling text as well as adding graphs and links to a document. In this document I will introduce you to Markdown and provide several example about how to style text and add graphs using markdown

Introduction

Markdown is a plain text syntax used for formating text. It was developed in 2004 by John Gruber to simplify HTML writing. In other words, Markdown is a text-to-HTML convertor that converts specific text symbols to XHTML codes. Markdown uses symbols to simplify these tags and as a results, has gained a lot of popularity for writing in blogs, websites, and online forums. In addition, many software have attempt to make use of Markdown codes for writing and styling text.

Writing in HTML format requires using a lot of tags, for example, to write a heading you should place text between <h1> and </h1> below I write a few more examples to give you an idea about writing with HTML codes. In the examples below, the HTML tags are highlighted in blue color and the black color text is the actual text that appear in the document.

Thus, “Markdown” is two things: (1) a plain text formatting syntax; and (2) a software tool, ... that converts the plain text formatting to HTML. The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. - J. Gruber

But how does Markdown simplify styling text in a plain-text formatted document? Here is an example about writing in HTML format. To give you a taste of writing in HTML format, I will introduce you to introduced the <h1>, <p>, <strong>, and <em> which are used for writing heading 1, paragraph, making the text bold, and italic respectively. Then I will write the same text using markdown codes to make them comparable to one another.

Stata Markdown Version


<h1> This is heading 1 </h1>
<p> This is a text paragraph. The content of the text paragraph can be <strong> Bold<strong> or even <em> Italic. </em></p>
#This is heading 1
This is a text paragraph. The content of the text paragraph can be __Bold__ or even _Italic_.

It is clear that Markdown significantly improve the readability of the document and simplify styling it. If you are interested to learn more about Markdown visit http://daringfireball.net/. You can also practice Markdown syntax in the online Markdown simulator.

Syntax

One reason for popularity of Markdown code is that the syntax codes are only a few which I explain them below. These codes are applicable in Weaver, MarkDoc, and Ketchup packages in Stata.


Phrase Emphasis

**bold** and __bold__/* make the text bold */
***italic & bold*** and ___italic & bold___/* make the text italic & bold */


Stata Markdown Latex

Link

[MyLink](http://haghish.com/stata 'Optional Title')/* create a link named MyLink */

In the example above, the 'MyLink' is the hyperlinked text, i.e. the text that appears in the document. The 'optional title' is the title that pops up if you keep your mouse cursor on it for a couple of seconds. Try it by holding your cursor on MyLink for a few seconds.

Note that there should be no space between the ]( characters.

Mark Down Price Formula


Images

![description](/path/to/graph.jpg 'Optional Title')/* inserts graph.jpg to the document */

Inserting a graph in the document is very similar to creating a link. The difference is that the image begin with !. Similar to the link syntax, there should be no space between the ]( characters. If you don't know the relative source of your graph, you can also use the absolute path to your image. And if you are wondering what do I mean by relative and absolute paths, make sure you read this link carefully!

Also pay attention to the file suffix (in this example, .jpg) that should be specified otherwise, markdown does not recognize the file that you are trying to import. Just to give you an example, I import an image named 'smallheart.jpg' to this page using ![](http://ftp.stata-blog.com/resources/images/content/smallheart.jpg) because my Stata-Blog website is actually reading Markdown codes. In this example, I have used the absolute path of the file which shows where on the server my graph is. If my graph was in the same folder as my HTML file, then writing ![](./smallheart.jpg) would have been enough. Obviously the relative paths are shorter and easier to write. More importantly, the relative paths are dynamic i.e. if you move the HTML and the image to a different folder (but keep them in the same folder) the graph still appears in your document. If you wish to create this graph yourself, right click and download the graph code here.


Headers and subtitles

##Heading 2/* create heading 2 */
####Heading 4/* create heading 4 */
######Heading 6/* create heading 6 */

The Markdown syntax for adding headings is very simple. Adding the # sign at the beginning of the line creates a heading. The number of hashtags refer to the heading rank which cann vary from 1 to 6. However, each hashtag has to appear at the beginning of the line. Therefore, you cannot write heading 1 and heading 2 on the same line.

Markdown


Paragraph

This is a text paragraph! it doesn't have any syntax! Just write!

Writing a text paragraph is the simplest thing using Markdown because it does not have any syntax. More excitingly, you can always press the enter key and move on to the next line without breaking the paragraph. The enter key does not break the line. To break the line, you should end the line with 2 or more spaces.

Horizontal rules

***/* adds a horizontal line */

Adding three or more dashes or asterisks will be converted to a horizontal rule which is defined as <hr /> in HTML.

Stata markdown examples


Exceptions

Adding an indent to a normal Markdown file would be interpreted as a 'code block' in HTML. In Stata, this interpretation has been ignored. Stata packages that can interpret Markdown codes, Ketchup and MarkDoc both ignore this interpretation and remove indents, unless indents are used to style braces, where indents improve readability of the code.

Example

For Stata packages that read Markdown text, the text has to be inserted within comment signs to tell Stata that the text is not meant to be executed. If you want to write only one line of text, the // symbol can be used. For example, you can add a heading 1 text to your document by typing:

However, if you wish to write more thext, the text should be inserted between /* */ signs. Bear in mind that these signs should be placed on separate lines to tell the packages that these are Markdown codes. This is not required by Stata, but the packages. By typing /* and */ on separate lines, Ketchup and MarkDoc make a difference between Markdown codes and comments that are made within Stata codes, using the same symbols. The reason is that these packages automatically remove the /* */ signs, after translating their content to Markdown, which improves the look of the document. However, they preserve and highlight these signs if they appear within the codes and interpret them as comments rather than Markdown codes. Therefore, the correct way of writing is as follows:

/*
#This is heading 1
##This is heading 2
###This is heading 3
This is a text paragraph and its content can be *italic* or **bold**.
as long as you move on to the next lines without adding 2 or more spaces to the
end of each line, Markdown will be interpreted as one paragraph and the lines appear
continuous in your document.
to begin a new paragraph, leave an empty line between your text. Also remember that you can
use underscore to make your text _italic_, __bold__, or even
___italic & bold___.
*/


Example Template

The example template uses the codes of the graph, 'I Love Stata' and uses both MarkDoc and Ketchup packages to read the codes and export them to docx (for microsoft word) and HTML.






Coments are closed