├── Examples ├── simple.do ├── simple.pdf ├── do │ ├── errors.docx │ ├── errors.odt │ ├── errors.pdf │ ├── errors.do │ ├── errors.tex │ └── errors.html ├── mini │ ├── slide.pdf │ ├── slide.docx │ ├── slide.do │ ├── slide.sthlp │ ├── slide.md │ └── doc.do ├── styles │ └── example.pdf ├── Mathematics │ ├── example.docx │ ├── example.odt │ ├── example.pdf │ ├── example2.pdf │ ├── example.smcl │ ├── example.tex │ ├── math_smcl.do │ └── example.html ├── Workshops │ └── 2018 │ │ ├── dofiles │ │ ├── prepare.do │ │ ├── documentation │ │ │ └── preparation.txt │ │ ├── descriptive.do │ │ ├── math.do │ │ ├── regression.do │ │ └── example.do │ │ └── master.do ├── Statablog │ ├── datamanagement │ │ ├── pdf │ │ │ ├── _NBA.pdf │ │ │ └── _timeseries.pdf │ │ ├── docx │ │ │ ├── _NBA.docx │ │ │ └── _timeseries.docx │ │ ├── Stata help files │ │ │ └── NBA.sthlp │ │ └── nasdaq.stbcal │ ├── README.md │ └── MAIN.do ├── dynamic_text │ ├── test.do │ ├── test2.do │ ├── new.do │ ├── go.do │ ├── test.html │ └── test2.html ├── tbl │ ├── tbl1.do │ ├── tbl0.do │ ├── tbl3.do │ └── tbl2.do ├── example.smcl ├── Examples.do └── Dynamic Slides │ ├── slide.do │ └── example.do ├── Torture_test ├── Markdown │ ├── import.md │ ├── empty.do │ ├── commands.do │ ├── pdf.do │ ├── docx.do │ ├── stata_journal.do │ ├── html.do │ ├── md.do │ ├── mata.do │ ├── weaver_commands.do │ ├── loop.do │ └── markers.do ├── sthlp │ ├── myprogram.ado │ ├── sthlp.do │ ├── bugs.do │ ├── bugs.sthlp │ └── example.ado ├── rundoc │ ├── rundoc_example.odt │ ├── rundoc_example.pdf │ ├── rundoc_example.docx │ ├── rundoc_example.out │ ├── rundoc_example.do │ └── rundoc_example.markdown ├── LaTeX │ ├── latexHeading.tex │ ├── empty.do │ ├── pdf.do │ ├── toc.do │ ├── weaver_command.do │ ├── heading.do │ └── mata.do ├── Arguments │ └── noisily.do ├── Beamer │ ├── beamer_tex.do │ ├── beamer_tex3b.do │ ├── beamer_tex3.do │ ├── beamer_tex2.do │ ├── Beamer2.do │ ├── example.do │ ├── Stata programs.do │ ├── Beamer.do │ └── Beamer3.do ├── Slide │ ├── slidy.do │ └── dzslide.do ├── do │ ├── all_latex.do │ └── example.do ├── DOT │ ├── me.txt │ ├── figure.ado │ ├── me3.txt │ ├── me2.txt │ ├── figure.sthlp │ └── markdown_DOT.do ├── Examples │ ├── short.do │ └── main_features.do └── test │ └── helptest.sthlp ├── Help ├── Help.pdf ├── helpfiles │ ├── img.pdf │ ├── tbl.pdf │ ├── txt.pdf │ ├── markdoc.pdf │ ├── pandoc.pdf │ └── wkhtmltopdf.pdf ├── MarkDoc_Wiki_Manual.pdf └── Help.tex ├── vignette.pdf ├── markdoc_stata.docx ├── putpdf_colors.pdf ├── markdoc_formal.docx ├── markdoc_minimal.docx ├── markdoc_simple.docx ├── Resources └── images │ ├── MD100.png │ ├── MD150.png │ ├── MD2.png │ ├── graph.png │ ├── help.png │ ├── help2.png │ ├── help3.png │ ├── help4.png │ ├── help5.png │ ├── help6.png │ ├── idea.png │ ├── link.png │ ├── list.png │ ├── mini.png │ ├── news.png │ ├── note.png │ ├── pdf.png │ ├── table.png │ ├── test.png │ ├── walk.png │ ├── work.png │ ├── diagram.png │ ├── dynamic.PNG │ ├── example.pdf │ ├── github3.png │ ├── link2.jpeg │ ├── manual.png │ ├── math01.png │ ├── math02.png │ ├── mini4.2.PNG │ ├── process.png │ ├── rundoc.png │ ├── Wrangler.png │ ├── attention.png │ ├── dialogbox.png │ ├── homepage.png │ ├── markdoc4.2.PNG │ ├── markdoc_do.png │ ├── markdown.png │ ├── math01_org.png │ ├── math02_org.png │ ├── process2.png │ ├── professor.png │ ├── announcement.png │ ├── dynamictext.pdf │ ├── dynamictext.png │ ├── markdoc_smcl.png │ ├── analyticprocess.PNG │ ├── markdoc5_small.png │ ├── markdoc_source.png │ ├── markdoc_dialog_box.png │ ├── diagram │ └── announcement2.svg ├── mini_mode_tests ├── active_mini_mode │ ├── results │ │ ├── test.sthlp │ │ ├── go.docx │ │ ├── go.pdf │ │ ├── hello.docx │ │ ├── hello.pdf │ │ ├── test.docx │ │ ├── test.pdf │ │ ├── hello.sthlp │ │ ├── hello.md │ │ ├── test.md │ │ ├── go.sthlp │ │ └── go.md │ ├── graph.png │ ├── example.png │ ├── hello.do │ ├── test.do │ ├── test2.do │ ├── new.do │ ├── go.do │ ├── tbl.do │ ├── md.md │ ├── syntax1A.md │ ├── full1.do │ └── summary.do └── MAIN.do ├── dependency.do ├── _config.yml ├── stata.toc ├── vignette.do ├── book examples └── README.md ├── markdoc.pkg ├── .gitignore ├── pandoc.sthlp ├── mdminor.sthlp ├── sthlp.sthlp ├── markdoc_title.dlg ├── wkhtmltopdf.sthlp ├── mini.sthlp ├── pandoc.ado ├── markdocversion.ado ├── mini.ado ├── wkhtmltopdf.ado ├── mdconvert.sthlp ├── make.do └── putpdf_colors.do /Examples/simple.do: -------------------------------------------------------------------------------- 1 | di "hi" 2 | 3 | -------------------------------------------------------------------------------- /Torture_test/Markdown/import.md: -------------------------------------------------------------------------------- 1 | Import This File 2 | ================ -------------------------------------------------------------------------------- /Help/Help.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/Help.pdf -------------------------------------------------------------------------------- /vignette.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/vignette.pdf -------------------------------------------------------------------------------- /Torture_test/sthlp/myprogram.ado: -------------------------------------------------------------------------------- 1 | program myprogram 2 | display "`0'" 3 | end 4 | -------------------------------------------------------------------------------- /markdoc_stata.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/markdoc_stata.docx -------------------------------------------------------------------------------- /putpdf_colors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/putpdf_colors.pdf -------------------------------------------------------------------------------- /Examples/simple.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/simple.pdf -------------------------------------------------------------------------------- /markdoc_formal.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/markdoc_formal.docx -------------------------------------------------------------------------------- /markdoc_minimal.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/markdoc_minimal.docx -------------------------------------------------------------------------------- /markdoc_simple.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/markdoc_simple.docx -------------------------------------------------------------------------------- /Examples/do/errors.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/do/errors.docx -------------------------------------------------------------------------------- /Examples/do/errors.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/do/errors.odt -------------------------------------------------------------------------------- /Examples/do/errors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/do/errors.pdf -------------------------------------------------------------------------------- /Examples/mini/slide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/mini/slide.pdf -------------------------------------------------------------------------------- /Help/helpfiles/img.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/helpfiles/img.pdf -------------------------------------------------------------------------------- /Help/helpfiles/tbl.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/helpfiles/tbl.pdf -------------------------------------------------------------------------------- /Help/helpfiles/txt.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/helpfiles/txt.pdf -------------------------------------------------------------------------------- /Examples/mini/slide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/mini/slide.docx -------------------------------------------------------------------------------- /Help/helpfiles/markdoc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/helpfiles/markdoc.pdf -------------------------------------------------------------------------------- /Help/helpfiles/pandoc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/helpfiles/pandoc.pdf -------------------------------------------------------------------------------- /Resources/images/MD100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/MD100.png -------------------------------------------------------------------------------- /Resources/images/MD150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/MD150.png -------------------------------------------------------------------------------- /Resources/images/MD2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/MD2.png -------------------------------------------------------------------------------- /Resources/images/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/graph.png -------------------------------------------------------------------------------- /Resources/images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/help.png -------------------------------------------------------------------------------- /Resources/images/help2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/help2.png -------------------------------------------------------------------------------- /Resources/images/help3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/help3.png -------------------------------------------------------------------------------- /Resources/images/help4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/help4.png -------------------------------------------------------------------------------- /Resources/images/help5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/help5.png -------------------------------------------------------------------------------- /Resources/images/help6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/help6.png -------------------------------------------------------------------------------- /Resources/images/idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/idea.png -------------------------------------------------------------------------------- /Resources/images/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/link.png -------------------------------------------------------------------------------- /Resources/images/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/list.png -------------------------------------------------------------------------------- /Resources/images/mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/mini.png -------------------------------------------------------------------------------- /Resources/images/news.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/news.png -------------------------------------------------------------------------------- /Resources/images/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/note.png -------------------------------------------------------------------------------- /Resources/images/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/pdf.png -------------------------------------------------------------------------------- /Resources/images/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/table.png -------------------------------------------------------------------------------- /Resources/images/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/test.png -------------------------------------------------------------------------------- /Resources/images/walk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/walk.png -------------------------------------------------------------------------------- /Resources/images/work.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/work.png -------------------------------------------------------------------------------- /Examples/styles/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/styles/example.pdf -------------------------------------------------------------------------------- /Help/MarkDoc_Wiki_Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/MarkDoc_Wiki_Manual.pdf -------------------------------------------------------------------------------- /Resources/images/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/diagram.png -------------------------------------------------------------------------------- /Resources/images/dynamic.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/dynamic.PNG -------------------------------------------------------------------------------- /Resources/images/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/example.pdf -------------------------------------------------------------------------------- /Resources/images/github3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/github3.png -------------------------------------------------------------------------------- /Resources/images/link2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/link2.jpeg -------------------------------------------------------------------------------- /Resources/images/manual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/manual.png -------------------------------------------------------------------------------- /Resources/images/math01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/math01.png -------------------------------------------------------------------------------- /Resources/images/math02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/math02.png -------------------------------------------------------------------------------- /Resources/images/mini4.2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/mini4.2.PNG -------------------------------------------------------------------------------- /Resources/images/process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/process.png -------------------------------------------------------------------------------- /Resources/images/rundoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/rundoc.png -------------------------------------------------------------------------------- /Help/helpfiles/wkhtmltopdf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Help/helpfiles/wkhtmltopdf.pdf -------------------------------------------------------------------------------- /Resources/images/Wrangler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/Wrangler.png -------------------------------------------------------------------------------- /Resources/images/attention.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/attention.png -------------------------------------------------------------------------------- /Resources/images/dialogbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/dialogbox.png -------------------------------------------------------------------------------- /Resources/images/homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/homepage.png -------------------------------------------------------------------------------- /Resources/images/markdoc4.2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdoc4.2.PNG -------------------------------------------------------------------------------- /Resources/images/markdoc_do.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdoc_do.png -------------------------------------------------------------------------------- /Resources/images/markdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdown.png -------------------------------------------------------------------------------- /Resources/images/math01_org.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/math01_org.png -------------------------------------------------------------------------------- /Resources/images/math02_org.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/math02_org.png -------------------------------------------------------------------------------- /Resources/images/process2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/process2.png -------------------------------------------------------------------------------- /Resources/images/professor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/professor.png -------------------------------------------------------------------------------- /Examples/Mathematics/example.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Mathematics/example.docx -------------------------------------------------------------------------------- /Examples/Mathematics/example.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Mathematics/example.odt -------------------------------------------------------------------------------- /Examples/Mathematics/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Mathematics/example.pdf -------------------------------------------------------------------------------- /Examples/Mathematics/example2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Mathematics/example2.pdf -------------------------------------------------------------------------------- /Resources/images/announcement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/announcement.png -------------------------------------------------------------------------------- /Resources/images/dynamictext.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/dynamictext.pdf -------------------------------------------------------------------------------- /Resources/images/dynamictext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/dynamictext.png -------------------------------------------------------------------------------- /Resources/images/markdoc_smcl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdoc_smcl.png -------------------------------------------------------------------------------- /Examples/Workshops/2018/dofiles/prepare.do: -------------------------------------------------------------------------------- 1 | 2 | //IMPORT ./documentation/preparation.txt 3 | 4 | clear 5 | sysuse auto 6 | -------------------------------------------------------------------------------- /Resources/images/analyticprocess.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/analyticprocess.PNG -------------------------------------------------------------------------------- /Resources/images/markdoc5_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdoc5_small.png -------------------------------------------------------------------------------- /Resources/images/markdoc_source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdoc_source.png -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/test.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | {title:The is heading } 4 | 5 | 6 | -------------------------------------------------------------------------------- /Torture_test/rundoc/rundoc_example.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Torture_test/rundoc/rundoc_example.odt -------------------------------------------------------------------------------- /Torture_test/rundoc/rundoc_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Torture_test/rundoc/rundoc_example.pdf -------------------------------------------------------------------------------- /dependency.do: -------------------------------------------------------------------------------- 1 | github install haghish/weaver 2 | github install haghish/md2smcl 3 | github install haghish/datadoc 4 | 5 | -------------------------------------------------------------------------------- /Resources/images/markdoc_dialog_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Resources/images/markdoc_dialog_box.png -------------------------------------------------------------------------------- /Torture_test/rundoc/rundoc_example.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Torture_test/rundoc/rundoc_example.docx -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/graph.png -------------------------------------------------------------------------------- /Examples/Statablog/datamanagement/pdf/_NBA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Statablog/datamanagement/pdf/_NBA.pdf -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/example.png -------------------------------------------------------------------------------- /Examples/Statablog/datamanagement/docx/_NBA.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Statablog/datamanagement/docx/_NBA.docx -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/go.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/results/go.docx -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/go.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/results/go.pdf -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/hello.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/results/hello.docx -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/hello.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/results/hello.pdf -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/test.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/results/test.docx -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/mini_mode_tests/active_mini_mode/results/test.pdf -------------------------------------------------------------------------------- /Examples/Statablog/datamanagement/pdf/_timeseries.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Statablog/datamanagement/pdf/_timeseries.pdf -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/hello.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | {title:Hello World!} 4 | 5 | {p 4 4 2} 6 | Just display "Hello World" for now! 7 | 8 | -------------------------------------------------------------------------------- /Examples/Statablog/datamanagement/docx/_timeseries.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Statablog/datamanagement/docx/_timeseries.docx -------------------------------------------------------------------------------- /Examples/Statablog/datamanagement/Stata help files/NBA.sthlp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haghish/markdoc/HEAD/Examples/Statablog/datamanagement/Stata help files/NBA.sthlp -------------------------------------------------------------------------------- /Examples/Workshops/2018/dofiles/documentation/preparation.txt: -------------------------------------------------------------------------------- 1 | Data preparation 2 | ----------------- 3 | 4 | 1. clear the data from Stata 5 | 2. laod the auto dataset 6 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/latexHeading.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{article} 2 | \usepackage{amsmath} 3 | \usepackage[english]{babel} 4 | \usepackage{blindtext} 5 | \begin{document} -------------------------------------------------------------------------------- /Examples/dynamic_text/test.do: -------------------------------------------------------------------------------- 1 | 2 | local a = 1 3 | 4 | display "Hello World" 5 | 6 | /*** 7 | The is heading 8 | ====================== 9 | 10 | ***/ 11 | 12 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/hello.do: -------------------------------------------------------------------------------- 1 | /*** 2 | Hello World! 3 | ============ 4 | 5 | Just display "Hello World" for now! 6 | ***/ 7 | 8 | display "Hello World" 9 | 10 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/test.do: -------------------------------------------------------------------------------- 1 | 2 | local a = 1 3 | 4 | display "Hello World" 5 | 6 | /*** 7 | The is heading 8 | ====================== 9 | 10 | ***/ 11 | 12 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/hello.md: -------------------------------------------------------------------------------- 1 | Hello World! 2 | ============ 3 | 4 | Just display "Hello World" for now! 5 | 6 | 7 | . display "Hello World" 8 | Hello World 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/test.md: -------------------------------------------------------------------------------- 1 | . local a = 1 2 | 3 | . display "Hello World" 4 | Hello World 5 | 6 | 7 | The is heading 1 8 | ====================== 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Examples/Workshops/2018/dofiles/descriptive.do: -------------------------------------------------------------------------------- 1 | 2 | /*** 3 | 4 | Summarize the data 5 | ------------------- 6 | 7 | ***/ 8 | 9 | sysuse auto, clear 10 | summarize 11 | 12 | histogram price 13 | img, title("Histogram of the `price` variable") w(200) h(130) 14 | 15 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | title: Markdoc 2 | description: A literate programming package for Stata which develops dynamic documents, slides, and help files in various formats 3 | google_analytics: 4 | show_downloads: true 5 | theme: jekyll-theme-cayman 6 | 7 | gems: 8 | - jekyll-mentions 9 | -------------------------------------------------------------------------------- /Examples/tbl/tbl1.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using 0, replace 3 | /*** 4 | 5 | | Animals | Sports | Fruits | 6 | |---------|------------|--------| 7 | | Cat | Soccer | Apple | 8 | | Dog | Basketball | Orange | 9 | 10 | ***/ 11 | 12 | qui log c 13 | markdoc 0, expor() replace 14 | -------------------------------------------------------------------------------- /stata.toc: -------------------------------------------------------------------------------- 1 | v 5.0.0 2 | d Materials by E. F. Haghish 3 | d University of Goettingen 4 | d haghish@med.uni-goettingen.de 5 | d https://github.com/haghish/github 6 | 7 | d 'markdoc': generate dynamic document, slides, stata help files, and package vignette in various formats 8 | 9 | p markdoc 10 | -------------------------------------------------------------------------------- /Torture_test/Markdown/empty.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // empty template 3 | // ============================================================================= 4 | qui log using example, replace smcl 5 | qui log c 6 | markdoc example, replace exp() 7 | -------------------------------------------------------------------------------- /Torture_test/rundoc/rundoc_example.out: -------------------------------------------------------------------------------- 1 | \BOOKMARK [1][-]{section.1}{rundoc command}{}% 1 2 | \BOOKMARK [2][-]{subsection.1.1}{Features}{section.1}% 2 3 | \BOOKMARK [3][-]{subsubsection.1.1.1}{executing Stata commands}{subsection.1.1}% 3 4 | \BOOKMARK [3][-]{subsubsection.1.1.2}{Writing mathematical notations}{subsection.1.1}% 4 5 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/go.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | perhaps something? 3 | 4 | {title:How about ?} 5 | 6 | {p 4 4 2} 7 | {bf:Price} equals: 8 | 9 | {p 4 4 2} 10 | And here is Scalar 11 | 12 | {p 4 4 2} 13 | or even or ? 14 | 15 | {title:How about ?} 16 | 17 | 18 | -------------------------------------------------------------------------------- /Examples/Statablog/datamanagement/nasdaq.stbcal: -------------------------------------------------------------------------------- 1 | version 14.1 2 | purpose "Converting daily financial data into business calendar dates" 3 | dateformat dmy 4 | range 05feb1971 23mar2015 5 | centerdate 05feb1971 6 | omit dayofweek (Sa Su) 7 | 8 | omit dowinmonth +4 Th of Nov 9 | omit date 25dec* 10 | omit date 25dec* and (-1) if dow(Sa) 11 | omit date 25dec* and (+1) if dow(Su) 12 | -------------------------------------------------------------------------------- /vignette.do: -------------------------------------------------------------------------------- 1 | /*** 2 | \newpage 3 | \part{\texttt{markdoc} package commands} 4 | \newpage 5 | ***/ 6 | 7 | //IMPORT markdoc.md 8 | //IMPORT mini.md 9 | //IMPORT pandoc.md 10 | //IMPORT wkhtmltopdf.md 11 | 12 | /*** 13 | \newpage 14 | \part{Additional commands} 15 | \newpage 16 | ***/ 17 | 18 | //IMPORT ../weaver/txt.md 19 | //IMPORT ../weaver/img.md 20 | //IMPORT ../weaver/tbl.md 21 | -------------------------------------------------------------------------------- /Examples/dynamic_text/test2.do: -------------------------------------------------------------------------------- 1 | 2 | 3 | sysuse auto, clear 4 | summarize foreign 5 | scalar c = "Dynamic" 6 | local min = `r(min)' 7 | scalar max = r(max) 8 | 9 | /*** 10 | ### text 11 | 12 | The documentation can include numeric and string macros and scalars. For example, 13 | the values of the `foreign` variable range between to . 14 | ***/ 15 | 16 | 17 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/test2.do: -------------------------------------------------------------------------------- 1 | 2 | 3 | sysuse auto, clear 4 | summarize foreign 5 | scalar c = "Dynamic" 6 | local min = `r(min)' 7 | scalar max = r(max) 8 | 9 | /*** 10 | # text 11 | 12 | The documentation can include numeric and string macros and scalars. For example, 13 | the values of the `foreign` variable range between to . 14 | ***/ 15 | 16 | 17 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/empty.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // empty template 3 | // ============================================================================= 4 | qui log using example, replace smcl 5 | qui log c 6 | markdoc example, replace markup(latex) exp(tex) //texmaster 7 | 8 | qui log using example2, replace smcl 9 | qui log c 10 | markdoc example2, replace markup(latex) exp(tex) texmaster 11 | -------------------------------------------------------------------------------- /Examples/tbl/tbl0.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using 0, replace 3 | /*** 4 | \begin{table}[] 5 | \centering 6 | \caption{My caption} 7 | \label{my-label} 8 | \begin{tabular}{|l|l|l|} 9 | \hline 10 | \textbf{Animals} & \textbf{Sports} & \textbf{Fruits} \\ \hline 11 | Cat & Soccer & Apple \\ \hline 12 | Dog & Basketball & Orange \\ \hline 13 | \end{tabular} 14 | \end{table} 15 | ***/ 16 | 17 | qui log c 18 | markdoc 0, expor(pdf) markup(latex) replace texmaster 19 | -------------------------------------------------------------------------------- /Torture_test/sthlp/sthlp.do: -------------------------------------------------------------------------------- 1 | 2 | // ----------------------------------------------------------------------------- 3 | // Test Header 4 | // ============================================================================= 5 | cap erase myprogram.ado 6 | copy ./Torture_test/sthlp/myprogram.do myprogram.ado, replace 7 | markdoc myprogram.ado, replace export(sthlp) date 8 | 9 | /*template(empty) title("myprogram") /// 10 | summary("a module for literate programming") date author("me") aff("you") add("SHSD") 11 | 12 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/pdf.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Creating Table of Content 3 | // ============================================================================= 4 | cap erase example.pdf 5 | 6 | qui log using example, replace smcl 7 | txt \section{This is a text heading} 8 | 9 | /*** 10 | \subsection{How about some more text?} 11 | this is some text paragraph. 12 | ***/ 13 | 14 | 15 | qui log c 16 | markdoc example, replace markup(latex) exp(pdf) toc texmaster 17 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/toc.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // Creating Table of Content 3 | // ============================================================================= 4 | cap erase example.pdf 5 | 6 | qui log using example, replace smcl 7 | txt \section{This is a text heading} 8 | 9 | /*** 10 | \subsection{How about some more text?} 11 | this is some text paragraph. 12 | ***/ 13 | 14 | 15 | qui log c 16 | markdoc example, replace markup(latex) exp(tex) toc texmaster 17 | -------------------------------------------------------------------------------- /Examples/dynamic_text/new.do: -------------------------------------------------------------------------------- 1 | 2 | //OFF 3 | sysuse auto, clear 4 | summarize foreign 5 | scalar c = "Dynamic" 6 | local min = `r(min)' 7 | scalar max = r(max) 8 | matrix Mat = (`r(min)', `r(max)') 9 | //ON 10 | 11 | /*** 12 | ### text 13 | 14 | The 24^th^ observation in the data is `` with a `price` of 15 | . The values of the `foreign` variable range between to 16 | . The same values can also be extracted from matrices, for example, 17 | and . 18 | ***/ 19 | 20 | 21 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/new.do: -------------------------------------------------------------------------------- 1 | 2 | //OFF 3 | sysuse auto, clear 4 | summarize foreign 5 | scalar c = "Dynamic" 6 | local min = `r(min)' 7 | scalar max = r(max) 8 | matrix Mat = (`r(min)', `r(max)') 9 | //ON 10 | 11 | /*** 12 | ### `text` 13 | 14 | 15 | 16 | The 24^th^ observation in the data is `` with a `price` of 17 | . The values of the `foreign` variable range between to 18 | . The same values can also be extracted from matrices, for example, 19 | and . 20 | ***/ 21 | 22 | 23 | -------------------------------------------------------------------------------- /Examples/dynamic_text/go.do: -------------------------------------------------------------------------------- 1 | display "Hi" 2 | 3 | di "what!!" 4 | 5 | di "funny" 6 | 7 | di "oh ojk" 8 | 9 | 10 | /*** 11 | perhaps something? 12 | ***/ 13 | 14 | 15 | 16 | scalar a = 10.847958758976 17 | 18 | matrix A = (1,2\ 3, 4) 19 | scalar b = A[2,1] 20 | local a = 999 21 | sysuse auto, clear 22 | 23 | /*** 24 | How about ? 25 | ----------------- 26 | 27 | __Price__ equals: 28 | 29 | And here is Scalar 30 | 31 | or even or ? 32 | ***/ 33 | 34 | 35 | /*** 36 | How about ? 37 | ----------------- 38 | 39 | ***/ 40 | -------------------------------------------------------------------------------- /Examples/Statablog/README.md: -------------------------------------------------------------------------------- 1 | Replicating Stata Blog Examples 2 | =============================== 3 | 4 | This repository replicates some of the tutorials published by 5 | [__Stata Blog__](https://blog.stata.com/). The main purpose is to provide a 6 | __real-world examples__ for using __`markdoc mini`__ for producing: 7 | 8 | - Dynamic analysis documents in __pdf__, __docx__, __md__, and __html__ format 9 | - Dynamic presentation slides 10 | - Stata help files 11 | 12 | Using the same do-file. The output documents are stored in subdirectories 13 | based on their file formats. 14 | 15 | 16 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/go.do: -------------------------------------------------------------------------------- 1 | display "Hi" 2 | 3 | di "what!!" 4 | 5 | di "funny" 6 | 7 | di "oh ojk" 8 | 9 | 10 | /*** 11 | perhaps something? 12 | ***/ 13 | 14 | 15 | 16 | scalar a = 10.847958758976 17 | 18 | matrix A = (1,2\ 3, 4) 19 | scalar b = A[2,1] 20 | local a = 999 21 | sysuse auto, clear 22 | 23 | /*** 24 | How about ? 25 | ----------------- 26 | 27 | __Price__ equals: 28 | 29 | And here is Scalar 30 | 31 | or even or ? 32 | ***/ 33 | 34 | 35 | /*** 36 | How about ? 37 | ----------------- 38 | 39 | ***/ 40 | -------------------------------------------------------------------------------- /book examples/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Reaproducible Research with Stata 6 | 7 | 8 | 9 | **Book Examples** ... 10 | 11 | 12 | Author 13 | ------ 14 | **E. F. Haghish, Ph.D.** 15 | Department of Medical Psychology and Medical Sociology, 16 | University of Göttingen, Germany 17 | 18 | _http://www.haghish.com/contact.php_ 19 | _[@Haghish](https://twitter.com/Haghish)_ 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Torture_test/Arguments/noisily.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // HTML Document Exportation 3 | // ============================================================================= 4 | qui log using example, replace smcl 5 | 6 | /*** 7 | This is heading 1 8 | ================= 9 | 10 |

This is also HTML written with HTML tag

11 | ***/ 12 | 13 | txt "## Testing HTML" _n /// 14 | "This is how it works!" 15 | 16 | sysuse auto, clear 17 | regress price mpg 18 | 19 | 20 | qui log c 21 | markdoc example, replace exp(html) num style() toc statax /// 22 | tit("This is the title") noisily 23 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/weaver_command.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // template with a TXT & Textmaster command 3 | // ============================================================================= 4 | qui log using example, replace smcl 5 | txt \section{This is a text heading} 6 | if 100 > 12 { 7 | local m `n' 8 | } 9 | qui log c 10 | markdoc example, replace markup(latex) exp(tex) //nonumber texmaster 11 | 12 | 13 | qui log using example2, replace smcl 14 | sysuse auto, clear 15 | txt \section{This is a text heading} 16 | qui log c 17 | markdoc example2, replace markup(latex) exp(tex) texmaster 18 | 19 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/tbl.do: -------------------------------------------------------------------------------- 1 | qui log using tbl, replace 2 | 3 | sysuse auto, clear 4 | 5 | //OFF 6 | foreach var of varlist weight price mpg { 7 | summarize `var' 8 | local `var'_mean : display %9.2f r(mean) 9 | local `var'_sd : display %9.2f r(sd) 10 | } 11 | //ON 12 | 13 | tbl ("Variable Name", "Mean", "SD" \ /// 14 | "__weight__", `weight_mean', `weight_sd' \ /// 15 | "__price__", `price_mean', `price_sd' \ /// 16 | "__mpg__", `mpg_mean', `mpg_sd') /// 17 | , title("Table 1. Summary of __weight__, __price__, and __mpg__ variables") 18 | 19 | qui log c 20 | markdoc tbl, mini export(docx) replace 21 | -------------------------------------------------------------------------------- /Torture_test/Markdown/commands.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | 4 | // ----------------------------------------------------------------------------- 5 | // Stata commands & comments 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | sysuse auto, clear 9 | // this is a comment 10 | *also this is a comment 11 | regress price mpg 12 | forval num = 1/1 { 13 | // this is a comment 14 | *also this is a comment 15 | 16 | /* 17 | this is a comment 18 | */ 19 | 20 | /**** 21 | Crazy comments? 22 | */ 23 | 24 | } 25 | 26 | qui log c 27 | markdoc example, replace exp() 28 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/heading.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // begin heading with TXT 3 | // ============================================================================= 4 | qui log using example, replace smcl 5 | txt "\documentclass{article}" _n /// 6 | "\usepackage{graphics}" _n /// 7 | "\begin{document}" _n 8 | txt "\section{This is a text heading}" _n 9 | 10 | /*** 11 | \subsection{How about some more text?} 12 | this is some text paragraph. 13 | 14 | \includegraphics{graph.png} 15 | ***/ 16 | 17 | 18 | 19 | txt "\end{document}" _n 20 | 21 | qui log c 22 | markdoc example, replace markup(latex) exp(tex) 23 | -------------------------------------------------------------------------------- /Torture_test/Markdown/pdf.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.html 3 | 4 | // ----------------------------------------------------------------------------- 5 | // PDF Document Exportation 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | 9 | /*** 10 | This is heading 1 11 | ================= 12 | 13 | ![This Is a Figure!](./graph.png) 14 | 15 | ***/ 16 | 17 | txt "## Testing __`txt`__ command" _n /// 18 | "This is how it works!" 19 | 20 | sysuse auto, clear 21 | regress price mpg 22 | 23 | 24 | qui log c 25 | 26 | markdoc example, replace exp(pdf) nonumber style() toc statax tit("This is the title") 27 | -------------------------------------------------------------------------------- /Torture_test/Beamer/beamer_tex.do: -------------------------------------------------------------------------------- 1 | 2 | //If you produce the slide from the do-file, instead of smcl, remove the log from the 3 | //top line, because the document must begine with the latex heading. 4 | qui log using example, replace 5 | 6 | /*** 7 | \documentclass{beamer} 8 | \title{Generating PDF slides with LaTeX Markup with MarkDoc package} 9 | \author{E. F. Haghish} 10 | \date{August 15, 2016} 11 | \begin{document} 12 | \maketitle 13 | \begin{frame} 14 | \frametitle{First Slide} 15 | Contents of the first slide 16 | \end{frame} 17 | \begin{frame} 18 | \frametitle{Second Slide} 19 | Contents of the second slide 20 | \end{frame} 21 | \end{document} 22 | ***/ 23 | 24 | 25 | 26 | qui log c 27 | *markdoc example, exp(pdf) markup(latex) replace 28 | -------------------------------------------------------------------------------- /Torture_test/Beamer/beamer_tex3b.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using example, replace 3 | 4 | /*** 5 | \documentclass{beamer} 6 | \title{Generating PDF slides with LaTeX Markup with MarkDoc package} 7 | \author{E. F. Haghish} 8 | \date{August 15, 2016} 9 | \begin{document} 10 | \maketitle 11 | ***/ 12 | 13 | 14 | /*** 15 | \begin{frame} 16 | \frametitle{First Slide} 17 | Contents of the first slide 18 | \end{frame} 19 | ***/ 20 | 21 | display "results from Stata commands" 22 | sysuse auto, clear 23 | summarize 24 | 25 | 26 | /*** 27 | \begin{frame} 28 | \frametitle{Second Slide} 29 | Contents of the second slide 30 | \end{frame} 31 | \end{document} 32 | ***/ 33 | 34 | 35 | 36 | 37 | 38 | qui log c 39 | markdoc example, exp(pdf) markup(latex) replace 40 | -------------------------------------------------------------------------------- /Torture_test/Markdown/docx.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | capture erase example.docx 4 | 5 | // ----------------------------------------------------------------------------- 6 | // Docx Document Exportation 7 | // ============================================================================= 8 | qui log using example, replace smcl 9 | 10 | txt "## Testing Mata" _n /// 11 | "This is how it works!" 12 | 13 | /*** 14 | How about some more text? 2 15 | ========================== 16 | 17 | some more? 18 | ---------- 19 | 20 | ### How about Heading 3? 21 | ***/ 22 | 23 | sysuse auto, clear 24 | regress price mpg 25 | qui log c 26 | cap erase example.docx 27 | markdoc example, replace exp(docx) toc nonumber style(stata) 28 | -------------------------------------------------------------------------------- /Torture_test/Slide/slidy.do: -------------------------------------------------------------------------------- 1 | cap erase example.html 2 | 3 | cap qui log c 4 | qui log using example, smcl replace 5 | /*** 6 | 7 | 8 | # HTML Slides 9 | 10 | - portable 11 | - light 12 | - fit many devices 13 | 14 | ***/ 15 | 16 | sysuse auto 17 | summarize price 18 | regress price mpg 19 | 20 | forvalues n = 1/5 { 21 | local m 12.3 22 | global sm 23 23 | } 24 | 25 | /*** 26 | # In the evening 27 | 28 | - Eat spaghetti 29 | - Drink wine 30 | 31 | # Conclusion 32 | 33 | - And the answer is... 34 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 35 | ***/ 36 | qui log c 37 | 38 | *cap prog drop markdoc 39 | 40 | markdoc example.smcl, exp(slidy) replace title("hi") 41 | 42 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/results/go.md: -------------------------------------------------------------------------------- 1 | . display "Hi" 2 | Hi 3 | 4 | . di "what!!" 5 | what!! 6 | 7 | . di "funny" 8 | funny 9 | 10 | . di "oh ojk" 11 | oh ojk 12 | 13 | 14 | perhaps something? 15 | 16 | 17 | . scalar a = 10.847958758976 18 | 19 | . matrix A = (1,2\ 3, 4) 20 | 21 | . scalar b = A[2,1] 22 | 23 | . local a = 999 24 | 25 | . sysuse auto, clear 26 | (1978 Automobile Data) 27 | 28 | 29 | How about 10.847959? 30 | ----------------- 31 | 32 | __Price__ equals: 4082 33 | 34 | And here is Scalar 3 35 | 36 | or even 1 or 4? 37 | 38 | 39 | How about 999? 40 | ----------------- 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Examples/tbl/tbl3.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using 0, replace 3 | 4 | 5 | /*** 6 | 7 | | $\beta$ | __Sports__ | __Fruits__ | 8 | |-------------|------------|------------| 9 | | num1 | soccer | banana | 10 | | num2 | basketball | apple | 11 | 12 | ***/ 13 | 14 | tbl ({l}"$$\\beta$$", {c}"Centered", {r}"Right" \ c(os), c(machine_type), c(username)) 15 | 16 | /*** 17 | --- 18 | 19 | Using inline mathematical notations 20 | ----------------------------------- 21 | ***/ 22 | 23 | 24 | tbl ("$\\beta$", "$\\epsilon$" \ 3.5, 1.3 \ 2.3 , 1.23) 25 | 26 | 27 | tbl ("$\\beta$", "$\\epsilon$" \ "$\\sum$", "$\\prod$") 28 | 29 | 30 | tbl ("$\\beta$", "$95\\%$ Confidence Interval" \ "values...", "values...") 31 | 32 | 33 | qui log c 34 | markdoc 0, expor(html) replace 35 | -------------------------------------------------------------------------------- /Torture_test/Beamer/beamer_tex3.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using example, replace 3 | 4 | /*** 5 | \documentclass{beamer} 6 | \title{Generating PDF slides with LaTeX Markup with MarkDoc package} 7 | \author{E. F. Haghish} 8 | \date{August 15, 2016} 9 | \def\verbatim@font{\ttfamily\tiny} 10 | \makeatother 11 | \begin{document} 12 | \maketitle 13 | ***/ 14 | 15 | 16 | /*** 17 | \begin{frame} 18 | \frametitle{First Slide} 19 | Contents of the first slide 20 | \end{frame} 21 | ***/ 22 | 23 | display "results from Stata commands" 24 | sysuse auto, clear 25 | summarize 26 | 27 | 28 | /*** 29 | \begin{frame} 30 | \frametitle{Second Slide} 31 | Contents of the second slide 32 | \end{frame} 33 | \end{document} 34 | ***/ 35 | 36 | 37 | 38 | 39 | 40 | qui log c 41 | markdoc example, exp(pdf) markup(latex) replace 42 | -------------------------------------------------------------------------------- /Torture_test/Markdown/stata_journal.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.pdf 3 | 4 | // ----------------------------------------------------------------------------- 5 | // Stata Journal Exportation using Markdown 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | 9 | /*** 10 | This is heading 1 11 | 12 | ***/ 13 | 14 | txt "## Testing __`txt`__ command" _n /// 15 | "This is how it works!" 16 | 17 | sysuse auto, clear 18 | regress price mpg 19 | 20 | 21 | qui log c 22 | markdoc example, replace exp(tex) nonumber texmaster style(stata) toc statax /// 23 | tit("This is the title") author("haghish") date /// 24 | summary("THIS IS S H DASID JI FJ FKJD FDJS FDF OEI DLFK D÷L FSOF OEF POFI DLFK") 25 | -------------------------------------------------------------------------------- /Torture_test/Markdown/html.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | capture erase example.docx 4 | 5 | // ----------------------------------------------------------------------------- 6 | // HTML Document Exportation 7 | // ============================================================================= 8 | qui log using example, replace smcl 9 | 10 | /*** 11 | This is heading 1 12 | ================= 13 | 14 |

This is also HTML written with HTML tag

15 | 16 | ![This Is a Figure!](./graph.png) 17 | ***/ 18 | 19 | txt "## Testing __`txt`__ command" _n /// 20 | "This is how it works!" 21 | 22 | 23 | 24 | sysuse auto, clear 25 | regress price mpg 26 | 27 | 28 | qui log c 29 | markdoc example, replace exp(html) nonumber style() toc statax tit("This is the title") 30 | -------------------------------------------------------------------------------- /markdoc.pkg: -------------------------------------------------------------------------------- 1 | v 5.0.0 2 | d 'MARKDOC': a general-purpose literate programming package 3 | d 4 | d generate dynamic document, slides, stata help files, and package vignette in various formats 5 | d 6 | d Distribution-Date: 20190610 7 | d License: MIT 8 | d 9 | F markdoc.ado 10 | F markdoc.dlg 11 | F markdoc.sthlp 12 | F markdoc_formal.docx 13 | F markdoc_minimal.docx 14 | F markdoc_simple.docx 15 | F markdoc_stata.docx 16 | F markdoc_title.dlg 17 | F markdoccheck.ado 18 | F markdocpandoc.ado 19 | F markdocstyle.ado 20 | F markdocversion.ado 21 | F markdocwkhtmltopdf.ado 22 | F markup.ado 23 | F mdconvert.ado 24 | F mdconvert.sthlp 25 | F mdminor.ado 26 | F mdminor.sthlp 27 | F mini.ado 28 | F mini.dlg 29 | F mini.sthlp 30 | F pandoc.ado 31 | F pandoc.sthlp 32 | F rundoc.ado 33 | F sthlp.ado 34 | F sthlp.sthlp 35 | F wkhtmltopdf.ado 36 | F wkhtmltopdf.sthlp 37 | -------------------------------------------------------------------------------- /Torture_test/do/all_latex.do: -------------------------------------------------------------------------------- 1 | //cd "/Users/haghish/Desktop/new" 2 | 3 | /*** 4 | \documentclass[11pt]{amsart} 5 | \usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots. 6 | \geometry{letterpaper} % ... or a4paper or a5paper or ... 7 | \usepackage{graphicx} 8 | \usepackage{amssymb} 9 | \usepackage{epstopdf} 10 | \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png} 11 | 12 | \title{Chapter 3} 13 | \author{E. F. Haghish} 14 | \date{} % Activate to display a given date or no date 15 | 16 | \begin{document} 17 | \maketitle 18 | 19 | \section{} 20 | \subsection{} 21 | 22 | 23 | 24 | \end{document} 25 | ***/ 26 | 27 | 28 | markdoc all_latex.do, export(pdf) markup(latex) replace linesize(120) /// 29 | printer("/usr/texbin/pdflatex") 30 | -------------------------------------------------------------------------------- /Torture_test/Markdown/md.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | 4 | // ----------------------------------------------------------------------------- 5 | // Markdown notation 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | /*** 9 | This is a regular heading 10 | ========================= 11 | 12 | This is a subheading 13 | -------------------- 14 | 15 | ### Paragraph 3? 16 | 17 | #### Paragraph 4? 18 | 19 | ##### Paragraph 5? 20 | 21 | ###### Paragraph 6? 22 | 23 | Text paragraph perhaps? 24 | 25 | ***/ 26 | 27 | forval num = 1/1 { 28 | /*** 29 | Text can be included in the loop, but is only printed once 30 | ========================================================= 31 | 32 | So DON'T DO IT! 33 | ***/ 34 | } 35 | 36 | qui log c 37 | markdoc example, replace exp() 38 | -------------------------------------------------------------------------------- /Torture_test/Markdown/mata.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | capture erase example.docx 4 | 5 | // ----------------------------------------------------------------------------- 6 | // Mata 7 | // ============================================================================= 8 | 9 | qui log using example, replace smcl 10 | 11 | txt "## Testing Mata" 12 | 13 | clear mata 14 | mata 15 | /*** 16 | How about some more text? 2 17 | --------------------------- 18 | ***/ 19 | 20 | // COMMENT 21 | 22 | function zeros(c) 23 | { 24 | a = J(c, 1, 0) 25 | return(a) 26 | 27 | } 28 | 29 | function zeros2(c) 30 | { 31 | a = J(c, 1, 0) 32 | return(a) 33 | } 34 | 35 | printf("HELLO WORLD!\n") 36 | 37 | /*** 38 | How about some more text? 3 39 | --------------------------- 40 | ***/ 41 | 42 | /**/ printf("Hide Command!\n") 43 | 44 | /***/ printf("Hide Output!\n") 45 | 46 | end 47 | 48 | qui log c 49 | markdoc example, replace exp() nonumber 50 | -------------------------------------------------------------------------------- /Torture_test/LaTeX/mata.do: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // With MATA 3 | // ============================================================================= 4 | qui log using example, replace smcl 5 | /*** 6 | Hi there 7 | ***/ 8 | 9 | txt "\section{This is a text heading}" 10 | 11 | sysuse auto, clear 12 | summarize price mpg weight 13 | if 100 > 12 { 14 | local m `n' 15 | } 16 | /*** 17 | \subsection{How about some more text?} 18 | this is some text paragraph. 19 | ***/ 20 | clear mata 21 | mata 22 | /*** 23 | \section{How about Mata?} 24 | This should also work in mata 25 | ***/ 26 | 27 | function zeros(c) 28 | { 29 | a = J(c, 1, 0) 30 | return(a) 31 | 32 | } 33 | 34 | function zeros2(c) 35 | { 36 | a = J(c, 1, 0) 37 | return(a) 38 | } 39 | 40 | /*** 41 | \section{How about Mata?} 42 | This should also work in mata 43 | ***/ 44 | 45 | printf("HELLO WORLD!\n") 46 | 47 | end 48 | 49 | qui log c 50 | markdoc example, replace markup(latex) export(tex) texmaster 51 | 52 | 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | private/MD.png 3 | 4 | private/MD1.psd 5 | 6 | private/MD2.psd 7 | 8 | private/MD3.psd 9 | 10 | Resources/markdoc_do.gv 11 | 12 | Resources/markdoc_smcl.gv 13 | 14 | Resources/markdoc_source.gv 15 | 16 | private/Billrising_help_template.sthlp 17 | 18 | private/ 19 | 20 | private/dlg/child.dlg 21 | 22 | private/dlg/d1.ado 23 | 24 | private/dlg/d1.dlg 25 | 26 | private/dlg/describe2.dlg 27 | 28 | private/dlg/GetLevels.ado 29 | 30 | private/dlg/ig.dlg 31 | 32 | private/dlg/markdoc0.dlg 33 | 34 | private/dlg/markdoc2.dlg 35 | 36 | private/dlg/markdoc3.dlg 37 | 38 | private/dlg/markdoc4.dlg 39 | 40 | private/dlg/nw.dlg 41 | 42 | private/dlg/wb.dlg 43 | 44 | private/markdoc2.dlg 45 | 46 | private/multi_window_dialogbox/markdoc_title.dlg 47 | 48 | private/multi_window_dialogbox/markdoc.dlg 49 | 50 | private/opencsv.do 51 | 52 | private/yaml.dlg 53 | 54 | private/yaml.ado 55 | 56 | private/rundoc_old.ado 57 | 58 | bug/bug.do 59 | 60 | private/rundoc_old2.ado 61 | 62 | 0.do 63 | 64 | 0.html 65 | test/ 66 | mini_mode_tests/active_mini_mode/results/ -------------------------------------------------------------------------------- /Torture_test/Markdown/weaver_commands.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | 4 | // ----------------------------------------------------------------------------- 5 | // Weaver Commands 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | txt "this command can be literally anywhere" _n /// 9 | "======================================" 10 | txt "this command can be literally anywhere" _n /// 11 | "====================================== 12 | txt "this command can be literally anywhere" _n /// 13 | "======================================" 14 | 15 | sysuse auto, clear 16 | hist price 17 | graph export graph.png, as(png) width(300) replace 18 | 19 | img using graph.png, title("This is the title") 20 | img , title("AUTOMATICALL LOADED") 21 | 22 | tble (Title 1, variables, something \ 1 , 2 , 3) 23 | tble (Title 1, variables, something \ 1 , 2 , 3) 24 | tble (Title 1, variables, something \ 1 , 2 , 3) 25 | 26 | qui log c 27 | markdoc example, replace exp() 28 | -------------------------------------------------------------------------------- /Examples/example.smcl: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {com}{sf}{ul off}{txt} 3 | {com}. 4 | . /*** 5 | > MarkDoc: A literate programming package for Stata 6 | > ================================================= 7 | > 8 | > ***/ 9 | . 10 | . 11 | . local a 1 12 | {txt} 13 | {com}. scalar b = 2 14 | {txt} 15 | {com}. local c "HI" 16 | {txt} 17 | {com}. scalar d = "World" 18 | {txt} 19 | {com}. sysuse auto, clear 20 | {txt}(1978 Automobile Data) 21 | 22 | {com}. summarize price 23 | 24 | {txt} Variable {c |} Obs Mean Std. Dev. Min Max 25 | {hline 13}{c +}{hline 57} 26 | {space 7}price {c |}{res} 74 6165.257 2949.496 3291 15906 27 | {txt} 28 | {com}. di "and this?" 29 | {res}and this? 30 | {txt} 31 | {com}. 32 | . /*** 33 | > Header one 34 | > ========== 35 | > 36 | > Header 2 37 | > -------- 38 | > 39 | > ### Header 3 and also 40 | > 41 | > #### Header 4 here 42 | > 43 | > to read the documentation, visit 44 | > [The GitHub Repository](http://github.com/haghish/markdoc) 45 | > 46 | > ***/ 47 | . 48 | . qui log c 49 | {smcl} 50 | {com}{sf}{ul off} -------------------------------------------------------------------------------- /Resources/images/diagram: -------------------------------------------------------------------------------- 1 | digraph G { 2 | rankdir=UD; 3 | fontname="sans-serif"; 4 | splines="line"; 5 | penwidth="0.1"; 6 | edge [comment="Wildcard edge", 7 | fontname="sans-serif", 8 | fontsize=10, 9 | colorscheme="blues3", 10 | color=2, 11 | fontcolor=3]; 12 | node [fontname="serif", 13 | fontsize=13, 14 | fillcolor="1", 15 | colorscheme="blues4", 16 | color="2", 17 | fontcolor="4", 18 | style="filled"]; 19 | "SMCL" [colorscheme="greys4"]; 20 | "do-file" [colorscheme="greys4"]; 21 | "markdoc" [fontcolor="1", 22 | fontname="monospace", 23 | fontsize="18", 24 | fillcolor="3", 25 | colorscheme="greys4"]; 26 | "SMCL" -> "markdoc" [colorscheme="greys3"]; 27 | "do-file" -> "markdoc" [colorscheme="greys3"]; 28 | "markdoc" -> "docx" [colorscheme="greys3"]; 29 | "docx" [fontname="monospace", 30 | fontsize="10", 31 | colorscheme="greys4"]; 32 | } 33 | -------------------------------------------------------------------------------- /Torture_test/sthlp/bugs.do: -------------------------------------------------------------------------------- 1 | /*** 2 | 3 | Adding a list 4 | ============= 5 | 6 | * this is a text line 7 | * this is also 8 | * how about this? 9 | 10 | 11 | Dot in the end 12 | ============== 13 | 14 | It seems that if a line end with a "." dot, 15 | and a new line is 16 | started adter, 17 | the __sthlp__ engine will add 2 space characters. 18 | Like this. 19 | Is that solved? 20 | 21 | 22 | This is not true if the text is written immediately. after the dot 23 | 24 | Also, removing. 25 | space after the dot does not help! 26 | 27 | __AFTER EVALUATING THE {help smcl} file__ it seems {help markdoc} is working 28 | very fine and there is no bug. This is how Stata renders SMCL document... 29 | but still, there is no reason why there should be 2 spaces. 30 | 31 | This problem, 32 | only happens after dots. 33 | 34 | 35 | Ending the line with accent 36 | =========================== 37 | 38 | The grave accents are used to `make` font monospace. Can we 39 | 40 | 41 | Unsolved 42 | =========================== 43 | 44 | 45 | 46 | ***/ 47 | 48 | markdoc "./sthlp/bugs.do", export(sthlp) replace template(empty) 49 | -------------------------------------------------------------------------------- /Torture_test/sthlp/bugs.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | 4 | {title:Adding a list} 5 | 6 | {p 4 4 2} 7 | * this is a text line {break} 8 | * this is also {break} 9 | * how about this? {break} 10 | 11 | 12 | 13 | {title:Dot in the end} 14 | 15 | {p 4 4 2} 16 | It seems that if a line end with a "." dot, 17 | and a new line is 18 | started adter, 19 | the {bf:sthlp} engine will add 2 space characters. 20 | Like this. 21 | Is that solved? 22 | 23 | 24 | {p 4 4 2} 25 | This is not true if the text is written immediately. after the dot 26 | 27 | {p 4 4 2} 28 | Also, removing. 29 | space after the dot does not help! 30 | 31 | {p 4 4 2} 32 | {bf:AFTER EVALUATING THE {help smcl} file} it seems {help markdoc} is working 33 | very fine and there is no bug. This is how Stata renders SMCL document... 34 | but still, there is no reason why there should be 2 spaces. 35 | 36 | {p 4 4 2} 37 | This problem, 38 | only happens after dots. 39 | 40 | 41 | 42 | {title:Ending the line with accent} 43 | 44 | {p 4 4 2} 45 | The grave accents are used to {c 96}make{c 96} font monospace. Can we 46 | 47 | 48 | 49 | {title:Unsolved} 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Torture_test/Markdown/loop.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | 4 | // ----------------------------------------------------------------------------- 5 | // COMPLEX LOOP 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | 9 | /**/ sysuse auto, clear 10 | 11 | /***/ sysuse auto, clear //2 12 | //OFF 13 | //ON 14 | 15 | if 100 > 12 { 16 | local m `n' 17 | *this is a comment 18 | display "how about this?" 19 | } 20 | 21 | forval num = 1/5 { 22 | display "yeap!" _n 23 | /**** 24 | Crazy comments? 25 | */ 26 | display "yeap!" _n 27 | qui log off 28 | *this is a comment 29 | //this is a comment 30 | qui log on 31 | /*** 32 | Text can be included in the loop, but is only printed once 33 | ========================================================= 34 | ***/ 35 | 36 | txt "#### but dynamic text can appear in a loop many times!" _n 37 | } 38 | //OFF 39 | 40 | /*** 41 | Does it word? 42 | ============= 43 | 44 | this is some text paragraph. 45 | ***/ 46 | display "hi" 47 | //ON 48 | qui log c 49 | markdoc example, replace exp(docx) nonumber 50 | -------------------------------------------------------------------------------- /Torture_test/Beamer/beamer_tex2.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using example, replace 3 | 4 | /*** 5 | \documentclass{beamer} 6 | \usepackage{default} 7 | \title{Generating PDF slides with LaTeX Markup with MarkDoc package} 8 | \author{E. F. Haghish} 9 | \date{August 15, 2016} 10 | \begin{document} 11 | \maketitle 12 | ***/ 13 | 14 | 15 | /*** 16 | \begin{frame} 17 | \frametitle{First Slide} 18 | Contents of the first slide 19 | \end{frame} 20 | ***/ 21 | 22 | /*** 23 | \begin{frame} 24 | \frametitle{Famous Composers} 25 | \begin{center} 26 | \begin{tabular}{|l|c|}\hline 27 | J.\ S.\ Bach & 1685--1750 \\ 28 | W.\ A.\ Mozart & 1756--1791 \\ 29 | L.\ Beethoven & 1770--1827 \\ 30 | F.\ Chopin & 1810--1849 \\ 31 | R.\ Schumann & 1810--1856 \\ 32 | B.\ Bart\'{o}k & 1881--1945 \\ \hline 33 | \end{tabular} 34 | \end{center} 35 | \end{frame} 36 | ***/ 37 | 38 | 39 | *********************** IMPORT THE SAME TABLE FROM A FILE 40 | 41 | //IMPORT ./Beamer/table.tex 42 | 43 | 44 | /*** 45 | \begin{frame} 46 | \frametitle{Second Slide} 47 | Contents of the second slide 48 | \end{frame} 49 | \end{document} 50 | ***/ 51 | 52 | 53 | 54 | 55 | 56 | qui log c 57 | markdoc example, exp(slide) markup(latex) replace 58 | -------------------------------------------------------------------------------- /Examples/Statablog/MAIN.do: -------------------------------------------------------------------------------- 1 | // the MAIN.do executes examples from Stata Blog 2 | // visit https://blog.stata.com/ for more informatin 3 | 4 | cd datamanagement 5 | 6 | // Web scraping NBA data into Stata 7 | clear 8 | do "./NBA.do" 9 | markdoc "_NBA.smcl" , mini export(md) replace statax // Markdown 10 | markdoc "_NBA.smcl" , mini export(html) replace statax // html 11 | markdoc "_NBA.smcl" , mini export(docx) replace statax // Word 12 | markdoc "_NBA.smcl" , mini export(pdf) replace statax // pdf 13 | markdoc "_NBA.smcl" , mini export(slide) replace statax // Slides 14 | markdoc "NBA.do" , mini export(sthlp) replace // help file 15 | 16 | 17 | // Handling gaps in time series using business calendars 18 | clear 19 | do "./timeseries.do" 20 | markdoc "_timeseries.smcl" , mini export(md) replace statax // Markdown 21 | markdoc "_timeseries.smcl" , mini export(html) replace statax // html 22 | markdoc "_timeseries.smcl" , mini export(docx) replace statax // Word 23 | markdoc "_timeseries.smcl" , mini export(pdf) replace statax // pdf 24 | markdoc "_timeseries.smcl" , mini export(slide) replace statax // Slides 25 | markdoc "timeseries.do" , mini export(sthlp) replace // help file 26 | -------------------------------------------------------------------------------- /Examples/Workshops/2018/master.do: -------------------------------------------------------------------------------- 1 | cd "/Users/haghish/Documents/Packages/markdoc/Examples/Workshops/2018" 2 | 3 | /*** 4 | Workshop Examples 5 | =============================== 6 | 7 | This document includes some of the examples of the workshop. I have organized 8 | them in separate do files and the dynamic document will include all of the 9 | examples. 10 | 11 | Help 12 | ---- 13 | 14 | If you need help about working with __MarkDoc__ package, probably the 15 | best place to begin is the 16 | [MarkDoc GitHub Wiki](https://github.com/haghish/MarkDoc/wiki), which is the 17 | package manual. If you have questions, post them on and I 18 | get back to you shortly. 19 | 20 | 21 | > NOTE that all of the examples below are being executed in active mode. 22 | 23 | ***/ 24 | 25 | // navigate to the directory where the do-files are located 26 | cd dofiles 27 | 28 | 29 | // the main example of the package 30 | /**/ markdoc "./example.do", export(html) replace 31 | 32 | // mathematics notation 33 | /**/ markdoc "./math.do", export(html) replace 34 | 35 | // load the data set 36 | /**/ markdoc "./prepare.do", export(html) replace 37 | 38 | // descriptive stats 39 | /**/ markdoc "./descriptive.do", export(html) replace 40 | 41 | // Regression 42 | /**/ markdoc "./regression.do", export(html) replace 43 | 44 | 45 | -------------------------------------------------------------------------------- /Examples/tbl/tbl2.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using 0, replace 3 | 4 | /*** 5 | Creating dynamic tables using the `txt` command 6 | =============================================== 7 | 8 | When you use the `tbl` command for creating a dynamic table, you __MUST__ add an 9 | empty line below the table. Otherwise, the next chunk of text will be appended to 10 | the table, causing the table to loos its structure. 11 | 12 | ### Example: 13 | 14 | In the example below, note that there is an empty line between the last line of the 15 | table and the ending sign: 16 | 17 | Markdown | Less | Pretty 18 | --- | --- | --- 19 | *Still* | `renders` | **nicely** 20 | 1 | 2 | 3 21 | 22 | ***/ 23 | 24 | 25 | //OFF 26 | local l1 Cat 27 | local l2 Dog 28 | local l3 Soccer 29 | local l4 Basketball 30 | local l5 Apple 31 | local l6 Orange 32 | //ON 33 | 34 | txt /// 35 | "| __Animals__ | __Sports__ | __Fruits__ |" _n /// 36 | "|-------------|------------|------------|" _n /// 37 | "| `l1' | `l3' | `l5' |" _n /// 38 | "| `l2' | `l4' | `l6' |" _n 39 | 40 | 41 | 42 | txt /// 43 | "Animals | Sports | Fruits " _n /// 44 | "---- | ---- | ---- " _n /// 45 | "`l1' | `l3' | `l5' " _n /// 46 | "`l2' | `l4' | `l6' " _n 47 | 48 | 49 | 50 | qui log c 51 | markdoc 0, expor(pdf) replace 52 | -------------------------------------------------------------------------------- /Examples/Mathematics/example.smcl: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {com}{sf}{ul off}{txt} 3 | {com}. 4 | . /*** 5 | > Use a single "\$" sign for writing inline mathematical notations. For example, 6 | > $f(x)=\sum_{c -(}n=0{c )-}^\infty\frac{c -(}f^{c -(}(n){c )-}(a){c )-}{c -(}n!{c )-}(x-a)^n$ would be rendered inline 7 | > with the text paragraph. Use double dollar signs "$$" for placing the notations 8 | > on a separate lines: 9 | > 10 | > $$Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$$ 11 | > 12 | > 13 | > 1. Since the notations appear in comments, they will not be interpreted by 14 | > Stata as global macros. 15 | > 16 | > 2. Place a backslash before the "\$" if you are using them in the document, but 17 | > not for rendering mathematical notations. The backslash will not appear in the 18 | > dynamic document. 19 | > 20 | > 3. You can also write dynamic mathematical notations using the __`txt`__ command. 21 | > ***/ 22 | . 23 | . local a = 10 24 | {txt} 25 | {com}. txt "$$ \beta_1 = `a' $$" 26 | 27 | 28 | {txt}> $$ \beta_1 = 10 $$ 29 | {com}. 30 | . /*** 31 | > Note that when you write inline mathematical notations, there should be __NO SPACE__ 32 | > between the dollar sign and the notation. However, if you are placing your 33 | > notations on a separate line, there should be no problem. 34 | > ***/ 35 | . 36 | . qui log c 37 | {smcl} 38 | {com}{sf}{ul off} -------------------------------------------------------------------------------- /Torture_test/Slide/dzslide.do: -------------------------------------------------------------------------------- 1 | 2 | cap erase example.html 3 | 4 | cap qui log c 5 | qui log using example, smcl replace 6 | /*** 7 | 8 | 9 | # HTML Slides 10 | 11 | - portable 12 | - light 13 | - fit many devices 14 | 15 | ***/ 16 | 17 | sysuse auto 18 | summarize price 19 | regress price mpg 20 | 21 | forvalues n = 1/5 { 22 | local m 12.3 23 | global sm 23 24 | } 25 | 26 | /*** 27 | # In the evening 28 | 29 | - Eat spaghetti 30 | - Drink wine 31 | 32 | # Conclusion 33 | 34 | - And the answer is... 35 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 36 | ***/ 37 | qui log c 38 | 39 | *cap prog drop markdoc 40 | 41 | cap qui log c 42 | qui log using example, smcl replace 43 | /*** 44 | 45 | 46 | # HTML Slides 47 | 48 | - portable 49 | - light 50 | - fit many devices 51 | 52 | ***/ 53 | 54 | sysuse auto 55 | summarize price 56 | regress price mpg 57 | 58 | forvalues n = 1/5 { 59 | local m 12.3 60 | global sm 23 61 | } 62 | 63 | /*** 64 | # In the evening 65 | 66 | - Eat spaghetti 67 | - Drink wine 68 | 69 | # Conclusion 70 | 71 | - And the answer is... 72 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 73 | ***/ 74 | qui log c 75 | 76 | *cap prog drop markdoc 77 | 78 | 79 | markdoc example.smcl, exp(dzslide) replace 80 | 81 | 82 | -------------------------------------------------------------------------------- /Help/Help.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,12pt]{book} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage{graphicx} 4 | \usepackage{pdfpages} 5 | 6 | \renewcommand\thesection{\arabic{section}} 7 | 8 | 9 | \begin{document} 10 | 11 | \author{E. F. Haghish} 12 | \title{MarkDoc (\texttt{4.0}) Stata Help Files} 13 | \date{October 2018} 14 | 15 | \frontmatter 16 | \maketitle 17 | \tableofcontents 18 | 19 | \mainmatter 20 | 21 | %\includegraphics[width=107mm, scale=0.5]{images/qplot} 22 | \section{\texttt{markdoc}} \label{markdoc} 23 | \includepdf[pages={1-}]{helpfiles/markdoc} 24 | 25 | \section{Additional programs} \label{additional programs} 26 | \subsection{\texttt{txt}} \label{txt} 27 | \includepdf[pages={1-}]{helpfiles/txt} 28 | \subsection{\texttt{img}} \label{img} 29 | \includepdf[pages={1-}]{helpfiles/img} 30 | \subsection{\texttt{tbl}} \label{tbl} 31 | \includepdf[pages={1-}]{helpfiles/tbl} 32 | \section{Calling third-party software within Stata} \label{Calling third-party software within Stata} 33 | \subsection{\texttt{pandoc}} \label{pandoc} 34 | \includepdf[pages={1-}]{helpfiles/pandoc} 35 | \subsection{\texttt{wkhtmltopdf}} \label{wkhtmltopdf} 36 | \includepdf[pages={1-}]{helpfiles/wkhtmltopdf} 37 | 38 | 39 | 40 | 41 | %\include{./TeX_files/chapter01} 42 | %\include{./TeX_files/chapter02} 43 | 44 | \backmatter 45 | % bibliography, glossary and index would go here. 46 | 47 | \end{document} -------------------------------------------------------------------------------- /Torture_test/rundoc/rundoc_example.do: -------------------------------------------------------------------------------- 1 | /*** 2 | `rundoc` command 3 | ================ 4 | 5 | The [`markdoc`](https://github.com/haghish/MarkDoc) command takes a `SMCL` log file 6 | to create a dynamic document or presentation slides. This procedure requires 7 | the user to create a log file and convert it to a dynamic document. 8 | 9 | The __`rundoc`__ command, is simply a wrapper for MarkDoc to simplifies 10 | typesettinf dynamic documents directly from a Stata do-file, without requiring 11 | the do-file to include a log file. 12 | 13 | The syntax for writing comments remains identical to 14 | [`markdoc`](https://github.com/haghish/MarkDoc) command. This command should make 15 | executing dynamic documents much simpler! 16 | 17 | Features 18 | -------- 19 | 20 | ### executing Stata commands 21 | 22 | The __`rundoc`__ command preserves all of the features of `markdoc`, because it 23 | is simply a wrapper program. Therefore, it preserves all of the features of `markdoc` such 24 | as executing Stata commands and syntax highlighting of the Stata commands using 25 | [`statax`](https://github.com/haghish/statax) package: 26 | ***/ 27 | 28 | display "Hello MarkDoc" 29 | sysuse auto, clear 30 | summarize 31 | 32 | /*** 33 | ### Writing mathematical notations 34 | 35 | Mathematical notations are supported in PDF, HTML, Docx, ODT (OpenOffice), and LaTeX: 36 | 37 | $$ Y = \beta_{0} + \beta_{1}x_{1} + \epsilon $$ 38 | ***/ 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /pandoc.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {it:v. 1.1} 3 | 4 | 5 | {title:pandoc} 6 | 7 | {p 4 4 2} 8 | {bf:pandoc} executing {browse "http://pandoc.org/":Pandoc} from Stata 9 | 10 | 11 | {title:Syntax} 12 | 13 | {p 8 8 2} {bf:pandoc} {it:anything} 14 | 15 | 16 | {title:Description} 17 | 18 | {p 4 4 2} 19 | {browse "http://pandoc.org/":Pandoc} is a document convertor freeware. The {bf:markdoc} 20 | package uses this application to produce dynamic documents, slides, 21 | and package documentation. This program is a supplementary command that allows 22 | using this application for other purposes, outside {bf:markdoc}. 23 | 24 | 25 | {title:Examples} 26 | 27 | {p 4 4 2} 28 | executing Pandoc command 29 | 30 | . pandoc _filename_ -o _filename_ 31 | 32 | {p 4 4 2} 33 | adding more Pandoc arguments 34 | 35 | . pandoc -s -S _filename_ -o _filename_ 36 | 37 | 38 | {title:Author} 39 | 40 | {p 4 4 2} 41 | {browse "https://github.com/haghish":E. F. Haghish} {break} 42 | Center for Medical Biometry and Medical Informatics {break} 43 | University of Freiburg, Germany {break} 44 | {it:haghish@imbi.uni-freiburg.de} {break} 45 | {browse "http://www.haghish.com/stat":http://www.haghish.com/stat} 46 | 47 | 48 | {title:License} 49 | 50 | {p 4 4 2} 51 | MIT License 52 | 53 | {space 4}{hline} 54 | 55 | {p 4 4 2} 56 | This help file was dynamically produced by 57 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} 58 | 59 | 60 | -------------------------------------------------------------------------------- /Examples/Workshops/2018/dofiles/math.do: -------------------------------------------------------------------------------- 1 | /*** 2 | Writing mathematical notations 3 | ============================== 4 | 5 | The text paragraph can include mathematical notations. For example, this 6 | formula $Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$ will be displayed within 7 | the text paragraph, whereas this next formula will be placed on a separate 8 | line: $$Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$$ 9 | 10 | ***/ 11 | 12 | /*** 13 | Use a single "\$" sign for writing inline mathematical notations. For example, 14 | $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ would be rendered inline 15 | with the text paragraph. Use double dollar signs "$$" for placing the notations 16 | on a separate lines: 17 | 18 | $$Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$$ 19 | 20 | 21 | 1. Since the notations appear in comments, they will not be interpreted by 22 | Stata as global macros. 23 | 24 | 2. Place a backslash before the "\$" if you are using them in the document, but 25 | not for rendering mathematical notations. The backslash will not appear in the 26 | dynamic document. 27 | 28 | 3. You can also write dynamic mathematical notations using the __`txt`__ command. 29 | ***/ 30 | 31 | local a = 10 32 | txt "$$ \beta_1 = `a' $$" 33 | 34 | /*** 35 | Note that when you write inline mathematical notations, there should be __NO SPACE__ 36 | between the dollar sign and the notation. However, if you are placing your 37 | notations on a separate line, there should be no problem. 38 | ***/ 39 | 40 | 41 | -------------------------------------------------------------------------------- /Examples/do/errors.do: -------------------------------------------------------------------------------- 1 | 2 | /*** 3 | Making the source code really reproducible 4 | ========================================== 5 | 6 | To make the do-file really reproducible, we have to make sure it does not 7 | access the data that is already loaded in Stata. Think about it, if you execute 8 | a do-file on a data that is already loaded and you have been working on it, can 9 | you ensure that re-executing the do-file creates the same results again? 10 | you might have done some changes outside of the do-file on the data 11 | - such as droping a record - which makes the results ireproducible. 12 | 13 | The solution would be to __run the do-file in a cleared workspace__ to ensure 14 | the do-file does not access the data that is already loaded. __MarkDoc__ can 15 | take a do-file and execute the code in a cleared workspace and produce the dynamic 16 | document. This is a very different engine compared to rendering a smcl-log 17 | to a dynamic document. 18 | 19 | If the do-file return an error, __MarkDoc__ still create the dynamic document 20 | until the point the error occured. To run this do-file, first load the __auto__ 21 | dataset in Stata. Then call __`markdoc`__ to produce the dynamic document. You 22 | should get an error the `no variables defined`, which means your do-file does 23 | not load the data, although the data are loaded in your Stata. 24 | 25 | 26 | ***/ 27 | 28 | display "the next command will be an error" 29 | 30 | regress price mpg 31 | 32 | display "Thi will not be printed..." 33 | -------------------------------------------------------------------------------- /mdminor.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {it:v. 1.3} 3 | 4 | 5 | {title:mdminor} 6 | 7 | {p 4 4 2} 8 | {bf:mdminor} interprets Markdown syntax and converts it in 9 | Microrosoft Word{c 39}s {bf:docx} format or {bf:pdf} format 10 | 11 | 12 | {title:Syntax} 13 | 14 | {p 8 8 2} {bf:mdminor} {it:text} [, {it:options}] 15 | 16 | 17 | {p 4 4 2}{bf:Options} 18 | 19 | {col 5}{it:option}{col 21}{it:Description} 20 | {space 4}{hline} 21 | {col 5}export({it:str}){col 21}specifies the file format and can be {bf:docx} (default) or {bf:pdf} 22 | {col 5}name({it:str}){col 21}specifies the file name 23 | {col 5}continue{col 21}avoids creating a new file and works on the loaded file in the memory 24 | {col 5}replace{col 21}replaces the existing file 25 | {space 4}{hline} 26 | 27 | {title:Examples} 28 | 29 | {p 4 4 2} 30 | create a microsoft word file 31 | 32 | . mdminor "**hello** *world*!", export(docx) name(mydoc) replace 33 | 34 | {p 4 4 2} 35 | create a pdf file 36 | 37 | . mdminor "**hello** *world*!", export(pdf) name(mydoc) replace 38 | 39 | 40 | {title:Author} 41 | 42 | {p 4 4 2} 43 | E. F. Haghish {break} 44 | University of Göttingen {break} 45 | {it:haghish@med.uni-goesttingen.de} {break} 46 | {browse "https://github.com/haghish":https://github.com/haghish} 47 | 48 | 49 | {title:License} 50 | 51 | {p 4 4 2} 52 | MIT License 53 | 54 | {space 4}{hline} 55 | 56 | {p 4 4 2} 57 | This help file was dynamically produced by 58 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} 59 | 60 | 61 | -------------------------------------------------------------------------------- /Torture_test/Markdown/markers.do: -------------------------------------------------------------------------------- 1 | capture erase example.smcl 2 | capture erase example.md 3 | 4 | // ----------------------------------------------------------------------------- 5 | // Special Markups 6 | // ============================================================================= 7 | qui log using example, replace smcl 8 | /**/ sysuse auto, clear 9 | /**/ sysuse auto, clear 10 | /**/ sysuse auto, clear 11 | /**/ sysuse auto, clear 12 | 13 | /***/ sysuse auto, clear 14 | /***/ sysuse auto, clear 15 | /***/ sysuse auto, clear 16 | 17 | /*** 18 | Using "ON" and "OFF" to hide loop code 19 | ====================== 20 | 21 | Make sure to add INDENTS before the markers to make sure MarkDoc is robust to indents 22 | ***/ 23 | 24 | //OFF 25 | forval num = 1/1 { 26 | // this is a comment 27 | *also this is a comment 28 | display "try" 29 | } 30 | //ON 31 | 32 | /*** 33 | MarkDoc allows you to __IMPORT__ external files (Markdown, HTML, LaTeX) 34 | In the dynamic document. Here I test for that! MarkDoc should be resistent to 35 | INDENT. 36 | ***/ 37 | 38 | //IMPORT ./Markdown/import.md 39 | 40 | forval num = 1/1 { 41 | // this is a comment 42 | *also this is a comment 43 | display "try" 44 | } 45 | 46 | /*** 47 | Loops cannot be hidden 48 | ====================== 49 | ***/ 50 | // ??? THIS DOES NOT WORK ;) 51 | /**/ forval num = 1/1 { 52 | // this is a comment 53 | *also this is a comment 54 | display "try" 55 | } 56 | 57 | qui log c 58 | markdoc example, replace exp() 59 | -------------------------------------------------------------------------------- /sthlp.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {it:v. 2.0.1} 3 | 4 | 5 | {title:sthlp} 6 | 7 | {p 4 4 2} 8 | converts Markdown to STHLP format to create Stata help files 9 | 10 | 11 | {title:Syntax} 12 | 13 | {p 8 8 2} {bf:sthlp} {it:filename} [, {it:replace} {it:debug} ] 14 | 15 | {p 4 4 2}{bf:Options} 16 | 17 | {col 5}Option{col 19}Description 18 | {space 4}{hline 66} 19 | {col 5}{it:replace}{col 19}replaces the existing file 20 | {col 5}{it:debug}{col 19}runs {bf:sthlp} in debug mode 21 | {col 5}{it:helplayout}{col 19}appends the help file template to a script file 22 | {col 5}{it:datalayout}{col 19}appends or creates the data documentation template 23 | {space 4}{hline 66} 24 | 25 | {title:Example} 26 | 27 | {p 4 4 2} 28 | extract the Markdown notation from a do-file and build a help file 29 | 30 | . sthlp filename.ado , replace 31 | 32 | {p 4 4 2} 33 | append the help layout to an ado-file 34 | 35 | . sthlp filename.ado, helplayout 36 | 37 | {p 4 4 2} 38 | generate a data documentation template for {bf:auto.dta} 39 | 40 | . sysuse auto, clear 41 | . sthlp filename.do , replace datalayout 42 | 43 | 44 | {title:Author} 45 | 46 | {p 4 4 2} 47 | E. F. Haghish {break} 48 | {it:haghish@med.uni-goesttingen.de} {break} 49 | {browse "https://github.com/haghish/echo":https://github.com/haghish/echo} {break} 50 | 51 | 52 | {title:License} 53 | 54 | {p 4 4 2} 55 | MIT License 56 | 57 | {space 4}{hline} 58 | 59 | {p 4 4 2} 60 | This help file was dynamically produced by 61 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Examples/mini/slide.do: -------------------------------------------------------------------------------- 1 | /*** 2 | 3 | 4 | Title 5 | ===== 6 | 7 | subtitle 8 | -------- 9 | 10 | --- 11 | 12 | # Tables 13 | 14 | Your documents, slides, and help files can include tables! 15 | 16 | | Tables | style of table | Cool | 17 | | :-------------- |:-------------------- | :------ | 18 | | col 3 is | right-aligned | $1600 | 19 | | col 2 is | centered | $12 | 20 | 21 | 22 | 23 | You can also create your tables online. The website mentioned below produces 24 | the format that is "ideal" for MarkDoc 25 | 26 | | __Website__ | __URL__ | 27 | |--------------------|-------------------------------------------------| 28 | | _Tables Generator_ | https://www.tablesgenerator.com/markdown_tables | 29 | 30 | --- 31 | 32 | # Agenda 33 | 34 | 1. Introduction 35 | 2. Deep-dive 36 | 3. ... 37 | 38 | or unordered list: 39 | 40 | - Introduction 41 | - Deep-dive 42 | - ... 43 | 44 | 45 | --- 46 | 47 | 48 | 49 | ***/ 50 | 51 | sysuse auto, clear 52 | summarize price mpg 53 | 54 | /*** 55 | 56 | This will start an __asis__ mode, which remember, it does not recognize "tabs". 57 | So until Stata fixes this problem, style your code with spaces rather than tabs. 58 | 59 | ~~~ 60 | 61 | if main.r2.iseq(1) { 62 | call main.master.enable 63 | } 64 | else { 65 | call main.master.disable 66 | } 67 | ~~~ 68 | 69 | 70 | --- 71 | 72 | # Introduction 73 | ***/ 74 | 75 | reg price mpg 76 | 77 | /*** 78 | 79 | --- 80 | 81 | ### Listing observations 82 | 83 | ***/ 84 | 85 | list in 1/5 86 | -------------------------------------------------------------------------------- /Examples/mini/slide.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | 4 | 5 | {title:Title} 6 | 7 | 8 | {title:subtitle} 9 | 10 | {title:} 11 | 12 | {title:Tables} 13 | 14 | {p 4 4 2} 15 | Your documents, slides, and help files can include tables! 16 | 17 | {col 5}Tables {col 21}style of table {col 27}Cool 18 | {space 4}{hline 48} 19 | {col 5}col 3 is {col 21}right-aligned {col 27}$1600 20 | {col 5}col 2 is {col 21}centered {col 27}$12 21 | {space 4}{hline 48} 22 | 23 | 24 | {p 4 4 2} 25 | You can also create your tables online. The website mentioned below produces 26 | the format that is "ideal" for MarkDoc 27 | 28 | {col 5}{bf:Website} {col 25}{bf:URL} 29 | {space 4}{hline 69} 30 | {col 5}{it:Tables Generator} {col 25}https://www.tablesgenerator.com/markdown_tables 31 | {space 4}{hline 69} 32 | {title:} 33 | 34 | {title:Agenda} 35 | 36 | {break} 1. Introduction 37 | {break} 2. Deep-dive 38 | {break} 3. ... 39 | 40 | {p 4 4 2} 41 | or unordered list: 42 | 43 | {break} - Introduction 44 | {break} - Deep-dive 45 | {break} - ... 46 | 47 | 48 | {title:} 49 | 50 | 51 | 52 | 53 | {p 4 4 2} 54 | This will start an {bf:asis} mode, which remember, it does not recognize "tabs". 55 | So until Stata fixes this problem, style your code with spaces rather than tabs. 56 | 57 | {asis} 58 | 59 | if main.r2.iseq(1) { 60 | call main.master.enable 61 | } 62 | else { 63 | call main.master.disable 64 | } 65 | {smcl} 66 | 67 | 68 | {title:} 69 | 70 | {title:Introduction} 71 | 72 | {title:} 73 | 74 | {p 4 4 2}{bf:Listing observations} 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Torture_test/Beamer/Beamer2.do: -------------------------------------------------------------------------------- 1 | //cap prog drop markdoc 2 | cap erase example.pdf 3 | 4 | 5 | qui log using example, replace 6 | 7 | /*** 8 | 9 | 10 | --- 11 | title: "Habits" 12 | output: 13 | beamer_presentation: 14 | 15 | 16 | includes: 17 | in_header: body.tex 18 | --- 19 | 20 | 21 | Slide 1 22 | ======= 23 | 24 | - Writing with __markdown__ syntax allows you to add text and graphs 25 | to _smcl_ logfile and export it to a editable document format. I will demonstrate 26 | the process by using the __Auto.dta__ dataset. 27 | 28 | - I will open the dataset, list a few observations, and export a graph. 29 | Then I will export the logfile to Microsoft Office docx format. 30 | 31 | Adding commands and output 32 | ========================== 33 | 34 | ***/ 35 | 36 | 37 | 38 | 39 | sysuse auto, clear 40 | histogram price 41 | graph export graph.png, width(400) replace 42 | summarize price 43 | 44 | txt "# Regression" 45 | regress price mpg 46 | 47 | 48 | 49 | txt "#missings" 50 | misstable summarize 51 | 52 | 53 | txt "#sum" 54 | misstable summarize 55 | 56 | /*** 57 | Adding image in a slide 58 | ======================= 59 | 60 | ![Histogram of the price variable](./graph.png) 61 | 62 | ***/ 63 | 64 | qui log c 65 | 66 | markdoc example, replace export(slide) /*printer("/usr/texbin/pdflatex")*/ nonumber /*template("body.tex")*/ 67 | 68 | exit 69 | markdoc example, replace export() 70 | 71 | -------------------------------------------------------------------------------- /Examples/Mathematics/example.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass{article} 3 | \usepackage{geometry} 4 | \usepackage{booktabs} %for tables 5 | %\geometry{letterpaper} 6 | \usepackage{graphicx} 7 | \usepackage{amssymb} 8 | \usepackage{hyperref} %use hyperlink 9 | \usepackage{epstopdf} 10 | \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png} 11 | \makeatletter 12 | \def\verbatim@font{\ttfamily\scriptsize} 13 | \makeatother 14 | \begin{document} 15 | \title{Testing Mathematical Notations in MarkDoc} 16 | \author{E. F. Haghish } 17 | \maketitle 18 | 19 | 20 | Use a single ``\$'' sign for writing inline mathematical notations. For 21 | example, \(f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n\) would be 22 | rendered inline with the text paragraph. Use double dollar signs 23 | ``\$\$'' for placing the notations on a separate lines: 24 | 25 | \[Y_i = \beta_0 + \beta_1 X_i + \epsilon_i\] 26 | 27 | \begin{enumerate} 28 | \def\labelenumi{\arabic{enumi}.} 29 | \item 30 | Since the notations appear in comments, they will not be interpreted 31 | by Stata as global macros. 32 | \item 33 | Place a backslash before the ``\$'' if you are using them in the 34 | document, but not for rendering mathematical notations. The backslash 35 | will not appear in the dynamic document. 36 | \item 37 | You can also write dynamic mathematical notations using the 38 | \textbf{\texttt{txt}} command. 39 | 40 | \begin{verbatim} 41 | . local a = 10 42 | \end{verbatim} 43 | \end{enumerate} 44 | 45 | \[ \beta_1 = 10 \] 46 | 47 | Note that when you write inline mathematical notations, there should be 48 | \textbf{NO SPACE} between the dollar sign and the notation. However, if 49 | you are placing your notations on a separate line, there should be no 50 | problem. 51 | 52 | \end{document} 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /markdoc_title.dlg: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // TITLE PAGE TAB 3 | // ============================================================================= 4 | VERSION 12 5 | POSITION . . 400 200 6 | 7 | DIALOG markdoc_title, label("MarkDoc") tabtitle("Dynamic Document") 8 | BEGIN 9 | // title of the document 10 | TEXT tx_title 10 10 . ., label("Title") 11 | EDIT title 80 @ 310 19 //EDIT ed_title +30 @ 340 . 12 | 13 | // Author of the document 14 | TEXT tx_author 10 +20 . ., label("Author") 15 | EDIT author 80 @ 310 19 16 | 17 | // Affiliation 18 | TEXT tx_affiliation 10 +20 . ., label("Affiliation") 19 | EDIT affiliation 80 @ 310 19 20 | 21 | // Address 22 | TEXT tx_address 10 +20 . ., label("Address") 23 | EDIT address 80 @ 310 19 24 | 25 | // Summary 26 | TEXT tx_summary 10 +20 . ., label("Summary") 27 | EDIT summary 80 @ 310 100 28 | END 29 | 30 | OK ok1, label("OK") 31 | CANCEL can1, label("Cancel") 32 | SUBMIT sub1, label("Submit") 33 | //HELP hlp1, view("help markdoc") 34 | RESET res1 35 | COPY copy1 36 | 37 | 38 | PROGRAM command 39 | BEGIN 40 | 41 | 42 | call create ARRAY arr_event_return 43 | call create STRING str_event_return 44 | 45 | call str_event_return.setvalue /// 46 | class event.fi_eventfile.value 47 | call str_event_return.append "*" 48 | call str_event_return.append /// 49 | class event.cb_eventid.value 50 | call str_event_return.append "*" 51 | call str_event_return.append /// 52 | class event.cb_eventdate.value 53 | call str_event_return.append "*" 54 | call str_event_return.append /// 55 | class event.cb_eventfirmid.value 56 | call str_event_return.append "*" 57 | call str_event_return.append /// 58 | class event.cb_eventcontrol.value 59 | 60 | put str_event_return 61 | 62 | END 63 | -------------------------------------------------------------------------------- /wkhtmltopdf.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {it:v. 1.1} 3 | 4 | 5 | {title:wkhtmltopdf} 6 | 7 | {p 4 4 2} 8 | {bf:wkhtmltopdf} renders {bf:html} documents to {bf:pdf} within Stata 9 | 10 | 11 | {title:Syntax} 12 | 13 | {p 8 8 2} {bf:wkhtmltopdf} {browse "http://wkhtmltopdf.org/usage/wkhtmltopdf.txt":[{it:options}}] 14 | {it:filename.html} {it:filename.pdf} 15 | 16 | {p 4 4 2} 17 | See the {browse "http://wkhtmltopdf.org/usage/wkhtmltopdf.txt":{it:options}}, which 18 | is a link to the {bf:wkhtmltopdf} manual, explaining the arguments you can 19 | add to adjust the pdf output. 20 | 21 | 22 | {title:Description} 23 | 24 | {p 4 4 2} 25 | if the {bf:mini} engine is not used, 26 | {bf:markdoc} requires the {browse "http://wkhtmltopdf.org/downloads.html":wkhtmltopdf} 27 | software to convert {bf:html} to {bf:pdf} without requiring installing LaTeX. 28 | Moreove, {bf:markdoc} provides automatic installation of wkhtmltopdf, if desired. 29 | 30 | {p 4 4 2} 31 | However, {bf:markdoc} is not the only software that deals with documents in Stata 32 | and many users show interest to create dynamic documents in their own way. 33 | to help them create {bf:pdf} documents, this command was created to convert their 34 | {bf:html} documents to {bf:pdf}. 35 | 36 | 37 | {title:Example} 38 | 39 | {p 4 4 2} 40 | convert html file to pdf 41 | 42 | . wkhtmltopdf myfile.html myfile.pdf 43 | 44 | 45 | {title:Author} 46 | 47 | {p 4 4 2} 48 | E. F. Haghish {break} 49 | University of Göttingen {break} 50 | {it:haghish@med.uni-goesttingen.de} {break} 51 | {browse "https://github.com/haghish":https://github.com/haghish} 52 | 53 | 54 | {title:License} 55 | 56 | {p 4 4 2} 57 | MIT License 58 | 59 | {space 4}{hline} 60 | 61 | {p 4 4 2} 62 | This help file was dynamically produced by 63 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} 64 | 65 | 66 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/md.md: -------------------------------------------------------------------------------- 1 | *italic 1*|*italic 2*|*italic 3* 2 | :--------|:--------:|:--------: 3 | **boldtext1**|100|1000 4 | **boldtext2**|22|222 5 | **boldtext3**|3948|3948 6 | 7 | 8 | 9 | 10 | Left|Centered|Right 11 | :--------|:--------:|--------: 12 | Windows|PC (64-bit x86-64)|haghish.fardzadeh 13 | 14 | 15 | 16 | #### Adding mathematical symbols in the dynamic table 17 | 18 | We have to use the LaTeX mathematical syntax, but they will be automatically 19 | converted in all documents generated by MarkDoc 20 | 21 | 22 | 23 | 24 | $\beta$ |$95\%$ Confidence Interval 25 | :--------|:--------: 26 | values...|values... 27 | 28 | 29 | 30 | 31 | $\beta$ |$\epsilon$ 32 | :--------|:--------: 33 | $\sum$ |$\prod$ 34 | 35 | 36 | 37 | Creating a summary table 38 | ------------------------ 39 | 40 | I will use the macros returned from `summarize` command to build a nice table 41 | in my document: 42 | 43 | 44 | . summarize price 45 | 46 | Variable | Obs Mean Std. Dev. Min Max 47 | -------------+--------------------------------------------------------- 48 | price | 74 6165.257 2949.496 3291 15906 49 | 50 | . return list 51 | 52 | scalars: 53 | r(N) = 74 54 | r(sum_w) = 74 55 | r(mean) = 6165.256756756757 56 | r(Var) = 8699525.974268788 57 | r(sd) = 2949.495884768919 58 | r(min) = 3291 59 | r(max) = 15906 60 | r(sum) = 456229 61 | 62 | 63 | 64 | Variable|Observations|Mean|SD 65 | :--------|:--------:|:--------:|:--------: 66 | __price__|74|6165.26|2949.50 67 | -------------------------------------------------------------------------------- /Examples/Workshops/2018/dofiles/regression.do: -------------------------------------------------------------------------------- 1 | 2 | clear 3 | sysuse auto 4 | 5 | /*** 6 | Dealining with the returned values 7 | ----------------------------------- 8 | 9 | Use the `return list` command to list the returned values. Most of the 10 | estimations are stored in a matrix. Therefore, we copy the matrix 11 | and use it to extract the values dynamically. 12 | ***/ 13 | 14 | regress price mpg foreign 15 | 16 | /*** 17 | return the rclass objects 18 | ***/ 19 | 20 | return list 21 | mat A = r(table) 22 | mat list A 23 | 24 | /*** 25 | Stata returns the estimations in the __eclass__ 26 | ***/ 27 | ereturn list 28 | mat B = e(b) 29 | mat list B 30 | 31 | /*** 32 | Creating the dynamic table 33 | ========================== 34 | 35 | In the workshop the following question came up. How can we use the returned values 36 | from Stata and create a dynamic table. 37 | 38 | We are trying to create a __dynamic table__ that includes the variables and 39 | $\beta_0$. We need to get the stored values from returned matrices in Stata in the 40 | following procedure: 41 | 42 | 1. save the Stata matrix with a new name 43 | 2. extract the scalars of interest 44 | 3. get the name of the columns of the matrix 45 | 1. parse the names of each column 46 | 2. change the /_const name to $\beta_0$ 47 | 4. use the __`tbl`__ command to generate the dynamic table. 48 | 49 | ***/ 50 | 51 | 52 | scalar scal1 = A[1,1] 53 | scalar scal2 = A[1,2] 54 | scalar scal3 = A[1,3] 55 | 56 | local colnms: coln A 57 | di "`colnms'" 58 | 59 | tokenize "`colnms'" 60 | display "`1' `2' `3'" 61 | 62 | local n = 1 63 | while "`1'" != "" { 64 | if "`1'" == "_cons" { 65 | local m`n' "$\\beta_0$" 66 | } 67 | else { 68 | local m`n' `1' 69 | } 70 | local n = `n' + 1 71 | macro shift 72 | } 73 | 74 | display "`m1' `m2' `m3'" 75 | 76 | 77 | 78 | tbl ("`m1'", "`m2'", "`m3'" \ scal1 , scal2, scal3 ) 79 | -------------------------------------------------------------------------------- /mini.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {it:version 4.8} 3 | 4 | 5 | {title:mini} 6 | 7 | {p 4 4 2} 8 | {bf:mini} is a simplified command to call the {it:mini} engine from the {bf:markdoc} 9 | package 10 | 11 | 12 | {title:Syntax} 13 | 14 | {p 8 8 2} {bf:mini} {it:filename} [, {it:options} ] 15 | 16 | {p 4 4 2} 17 | where {it:options} are identical to the {browse "help markdoc":markdoc} options 18 | 19 | 20 | {title:Description} 21 | 22 | {p 4 4 2} 23 | {bf:mini} is a simplified command to call the light-weight {it:mini} engine forom 24 | the {bf:markdoc} command. it can be called to convert a Markdown file to any 25 | file format supported by the mini engine (html, docx, pdf, sthlp, slide). the 26 | command also can execute a do-file to produce a dynamic document. {break} 27 | 28 | 29 | {title:Examples} 30 | 31 | {p 4 4 2} 32 | convert a Markdown file to a word, pdf, html, sthlp, and slides files 33 | 34 | . mini "filename.md" , export(docx) 35 | . mini "filename.md" , export(pdf) 36 | . mini "filename.md" , export(html) 37 | . mini "filename.md" , export(sthlp) 38 | . mini "filename.md" , export(slide) 39 | 40 | {p 4 4 2} 41 | execute a do-file and produce a word, pdf, and html files... 42 | 43 | . mini "filename.do" , export(docx) 44 | . mini "filename.do" , export(pdf) 45 | . mini "filename.do" , export(html) 46 | 47 | 48 | {title:Author} 49 | 50 | {p 4 4 2} 51 | E. F. Haghish {break} 52 | University of Göttingen {break} 53 | {it:haghish@med.uni-goesttingen.de} {break} 54 | {browse "https://github.com/haghish":https://github.com/haghish} 55 | 56 | 57 | {title:License} 58 | 59 | {p 4 4 2} 60 | MIT License 61 | 62 | {space 4}{hline} 63 | 64 | {p 4 4 2} 65 | This help file was dynamically produced by 66 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} 67 | 68 | 69 | -------------------------------------------------------------------------------- /Examples/Mathematics/math_smcl.do: -------------------------------------------------------------------------------- 1 | qui log using example, replace 2 | 3 | /*** 4 | Writing mathematical notations 5 | ============================== 6 | 7 | The text paragraph can include mathematical notations. For example, this 8 | formula $Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$ will be displayed within 9 | the text paragraph, whereas this next formula will be placed on a separate 10 | line: $$Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$$ 11 | 12 | ***/ 13 | 14 | /*** 15 | Use a single "\$" sign for writing inline mathematical notations. For example, 16 | $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ would be rendered inline 17 | with the text paragraph. Use double dollar signs "$$" for placing the notations 18 | on a separate lines: 19 | 20 | $$Y_i = \beta_0 + \beta_1 X_i + \epsilon_i$$ 21 | 22 | 23 | 1. Since the notations appear in comments, they will not be interpreted by 24 | Stata as global macros. 25 | 26 | 2. Place a backslash before the "\$" if you are using them in the document, but 27 | not for rendering mathematical notations. The backslash will not appear in the 28 | dynamic document. 29 | 30 | 3. You can also write dynamic mathematical notations using the __`txt`__ command. 31 | ***/ 32 | 33 | local a = 10 34 | txt "$$ \beta_1 = `a' $$" 35 | 36 | /*** 37 | Note that when you write inline mathematical notations, there should be __NO SPACE__ 38 | between the dollar sign and the notation. However, if you are placing your 39 | notations on a separate line, there should be no problem. 40 | ***/ 41 | 42 | qui log c 43 | 44 | local title `"title("Testing Mathematical Notations in MarkDoc")"' 45 | local author `"author("E. F. Haghish")"' 46 | 47 | markdoc example, export(html) replace `title' `author' date 48 | markdoc example, export(docx) replace `title' `author' date 49 | markdoc example, export(odt) replace `title' `author' date 50 | markdoc example, export(tex) replace texmaster `title' `author' date 51 | -------------------------------------------------------------------------------- /pandoc.ado: -------------------------------------------------------------------------------- 1 | // documentation is written for markdoc package (github.com/haghish/markdoc) 2 | // . markdoc wpandoc.ado, mini export(sthlp) replace 3 | 4 | /*** 5 | _v. 1.1_ 6 | 7 | pandoc 8 | ====== 9 | 10 | __pandoc__ executing [Pandoc](http://pandoc.org/) from Stata 11 | 12 | Syntax 13 | ------ 14 | 15 | > __pandoc__ _anything_ 16 | 17 | Description 18 | ----------- 19 | 20 | [Pandoc](http://pandoc.org/) is a document convertor freeware. The __markdoc__ 21 | package uses this application to produce dynamic documents, slides, 22 | and package documentation. This program is a supplementary command that allows 23 | using this application for other purposes, outside __markdoc__. 24 | 25 | Examples 26 | -------- 27 | 28 | executing Pandoc command 29 | 30 | . pandoc _filename_ -o _filename_ 31 | 32 | adding more Pandoc arguments 33 | 34 | . pandoc -s -S _filename_ -o _filename_ 35 | 36 | Author 37 | ------ 38 | 39 | [E. F. Haghish ](https://github.com/haghish) 40 | Center for Medical Biometry and Medical Informatics 41 | University of Freiburg, Germany 42 | _haghish@imbi.uni-freiburg.de_ 43 | [http://www.haghish.com/stat](http://www.haghish.com/stat) 44 | 45 | License 46 | ------- 47 | 48 | MIT License 49 | 50 | - - - 51 | 52 | This help file was dynamically produced by 53 | [MarkDoc Literate Programming package](http://www.haghish.com/markdoc/) 54 | ***/ 55 | 56 | 57 | program define pandoc 58 | syntax anything //[, pandoc(str) install ] 59 | 60 | capture weaversetup //it might not be yet created 61 | 62 | *if !missing("`pandoc'") { 63 | * confirm file "`pandoc'" 64 | * global pandoc "`pandoc'" 65 | *} 66 | 67 | if missing("`pandoc'") & !missing("$pathPandoc") { 68 | global pandoc "$pathPandoc" 69 | } 70 | 71 | markdoccheck //, `install' pandoc("`pandoc'") 72 | 73 | confirm file "$pandoc" 74 | di as txt "$pandoc `anything'" 75 | 76 | ! "$pandoc" `anything' 77 | 78 | end 79 | 80 | -------------------------------------------------------------------------------- /markdocversion.ado: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Developed by E. F. Haghish (2014) 4 | Center for Medical Biometry and Medical Informatics 5 | University of Freiburg, Germany 6 | 7 | haghish@imbi.uni-freiburg.de 8 | 9 | * MarkDoc comes with no warranty * 10 | 11 | 12 | 13 | MarkDoc Package 14 | =============== 15 | 16 | This ado file is a part of MarkDoc package and is called within 17 | markdoc.ado. It will connecto to http://haghish.com/ to obtain the latest 18 | version of the MarkDoc package and notify the user, if the package is not 19 | updated. 20 | */ 21 | 22 | 23 | program define markdocversion 24 | version 11 25 | 26 | // make sure that Stata does not repeat this every time 27 | //if "$thenewestmarkdocversion" == "" { 28 | cap qui do "http://www.haghish.com/packages/update.do" 29 | //} 30 | 31 | global markdocversion 3.79 32 | 33 | if "$thenewestmarkdocversion" > "$markdocversion" { 34 | di _n(2) 35 | di as txt _n(2) "{hline}" 36 | 37 | di " _ _ _ _ __ " _n /// 38 | " | | | |_ __ __| | __ _| |_ ___ _ \ \ " _n /// 39 | " | | | | '_ \ / _` |/ _` | __/ _ \ (_) | |" _n /// 40 | " | |_| | |_) | (_| | (_| | || __/ _ | |" _n /// 41 | " \___/| .__/ \__,_|\__,_|\__\___| (_) | |" _n /// 42 | " |_| /_/ " _n /// 43 | 44 | di as text "{p}MarkDoc has a new update available! Click on " /// 45 | `"{ul:{bf:{stata "adoupdate markdoc, update":Update MarkDoc Now}}} "' /// 46 | "or alternatively type {ul: {bf: adoupdate markdoc, update}} to " /// 47 | "update the package." 48 | 49 | di as text "{p}For more information regarding the new features " /// 50 | "of MarkDoc, visit " /// 51 | `"{browse "http://www.haghish.com/statistics/stata-blog/reproducible-research/markdoc.php":{it:http://www.haghish.com/markdoc}}{smcl}"' 52 | } 53 | 54 | end 55 | -------------------------------------------------------------------------------- /Examples/do/errors.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass{article} 3 | 4 | \usepackage{geometry} 5 | \usepackage{booktabs} %for tables 6 | %\geometry{letterpaper} 7 | \usepackage{graphicx} 8 | \usepackage{amssymb} 9 | \usepackage{hyperref} %use hyperlink 10 | \usepackage{epstopdf} 11 | \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png} 12 | \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\makeatletter 13 | \def\verbatim@font{\ttfamily\scriptsize} 14 | \makeatother 15 | \begin{document} 16 | 17 | 18 | \section{Making the source code really 19 | reproducible}\label{making-the-source-code-really-reproducible} 20 | 21 | To make the do-file really reproducible, we have to make sure it does 22 | not access the data that is already loaded in Stata. Think about it, if 23 | you execute a do-file on a data that is already loaded and you have been 24 | working on it, can you ensure that re-executing the do-file creates the 25 | same results again? you might have done some changes outside of the 26 | do-file on the data - such as droping a record - which makes the results 27 | ireproducible. 28 | 29 | The solution would be to \textbf{run the do-file in a cleared workspace} 30 | to ensure the do-file does not access the data that is already loaded. 31 | \textbf{MarkDoc} can take a do-file and execute the code in a cleared 32 | workspace and produce the dynamic document. This is a very different 33 | engine compared to rendering a smcl-log to a dynamic document. 34 | 35 | If the do-file return an error, \textbf{MarkDoc} still create the 36 | dynamic document until the point the error occured. To run this do-file, 37 | first load the \textbf{auto} dataset in Stata. Then call 38 | \textbf{\texttt{markdoc}} to produce the dynamic document. You should 39 | get an error the \texttt{no\ variables\ defined}, which means your 40 | do-file does not load the data, although the data are loaded in your 41 | Stata. 42 | 43 | \end{document} 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /mini.ado: -------------------------------------------------------------------------------- 1 | // documentation is written for markdoc package (github.com/haghish/markdoc) 2 | // . markdoc mini.ado, mini export(sthlp) replace 3 | 4 | /*** 5 | _version 4.8_ 6 | 7 | mini 8 | ===== 9 | 10 | __mini__ is a simplified command to call the _mini_ engine from the __markdoc__ 11 | package 12 | 13 | Syntax 14 | ------ 15 | 16 | > __mini__ _filename_ [, _options_ ] 17 | 18 | where _options_ are identical to the [markdoc](help markdoc) options 19 | 20 | Description 21 | ----------- 22 | 23 | __mini__ is a simplified command to call the light-weight _mini_ engine forom 24 | the __markdoc__ command. it can be called to convert a Markdown file to any 25 | file format supported by the mini engine (html, docx, pdf, sthlp, slide). the 26 | command also can execute a do-file to produce a dynamic document. 27 | 28 | Examples 29 | -------- 30 | 31 | convert a Markdown file to a word, pdf, html, sthlp, and slides files 32 | 33 | . mini "filename.md" , export(docx) 34 | . mini "filename.md" , export(pdf) 35 | . mini "filename.md" , export(html) 36 | . mini "filename.md" , export(sthlp) 37 | . mini "filename.md" , export(slide) 38 | 39 | execute a do-file and produce a word, pdf, and html files... 40 | 41 | . mini "filename.do" , export(docx) 42 | . mini "filename.do" , export(pdf) 43 | . mini "filename.do" , export(html) 44 | 45 | Author 46 | ------ 47 | 48 | E. F. Haghish 49 | University of Göttingen 50 | _haghish@med.uni-goesttingen.de_ 51 | [https://github.com/haghish](https://github.com/haghish) 52 | 53 | License 54 | ------- 55 | 56 | MIT License 57 | 58 | - - - 59 | 60 | This help file was dynamically produced by 61 | [MarkDoc Literate Programming package](http://www.haghish.com/markdoc/) 62 | ***/ 63 | 64 | 65 | 66 | *cap prog drop mini 67 | prog mini 68 | version 15 69 | tokenize `"`macval(0)'"', parse(",") 70 | if "`2'" == "," { 71 | markdoc `0' mini 72 | } 73 | else { 74 | markdoc `0', mini 75 | } 76 | end 77 | 78 | -------------------------------------------------------------------------------- /Torture_test/DOT/me.txt: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | {title:Dynamic Graph} 4 | 5 | 1 6 | 2 7 | 3 8 | 9 | +---------T-------- 10 | | 11 | [---------|-------] [--------] [--------------------] 12 | | markdown|source |------>| mdddia |------T--->| processed markdown | 13 | :---------B-------; :--------; | !--------------------! 14 | :--->| image files | 15 | -- -- :--------------------; 16 | 17 | 18 | [-----------------] [--------] [--------------------] 19 | | markdown|source |------>| mdddia |------T----| processed markdown | 20 | :-----------------; :---T----; | !--------------------! 21 | | :--->| image files | 22 | [---------B--------] :--------------------; 23 | | diagram creation | 24 | !------------------! 25 | | ditaa/dot/rdfdot | 26 | :------------------; 27 | 28 | - - -Tab 29 | 30 | - - - 31 | 32 | - - - 33 | 34 | Source | SS df MS Number of obs = 74 35 | -------------|---------------------------------- F(1, 72) = 20.26 36 | Model | 139449474 1 139449474 Prob > F = 0.0000 37 | Residual | 495615923 72 6883554.48 R-squared = 0.2196 38 | -------------|---------------------------------- Adj R-squared = 0.2087 39 | Total | 635065396 73 8699525.97 Root MSE = 2623.7 40 | 41 | -------------T---------------------------------------------------------------- 42 | price | Coef. Std. Err. t P>|t| [95% Conf. Interval] 43 | -------------|---------------------------------------------------------------- 44 | mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 45 | cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03 46 | -------------B---------------------------------------------------------------- 47 | 48 | 49 | 50 | *cap prog drop markdoc 51 | 52 | 53 | -------------------------------------------------------------------------------- /Torture_test/DOT/figure.ado: -------------------------------------------------------------------------------- 1 | 2 | /*** 3 | Dynamic Graph 4 | ============= 5 | 6 | 1 7 | 2 8 | 3 9 | 10 | +---------+-------- 11 | | 12 | +---------+-------+ +--------+ +--------------------+ 13 | | markdown|source |------>| mdddia |------+--->| processed markdown | 14 | +---------+-------+ +--------+ | +--------------------+ 15 | +--->| image files | 16 | -- -- +--------------------+ 17 | 18 | 19 | +-----------------+ +--------+ +--------------------+ 20 | | markdown|source |------>| mdddia |------+----| processed markdown | 21 | +-----------------+ +--------+ | +--------------------+ 22 | | +--->| image files | 23 | +------------------+ +--------------------+ 24 | | diagram creation | 25 | +------------------+ 26 | | ditaa/dot/rdfdot | 27 | +------------------+ 28 | 29 | - - -Tab 30 | 31 | - - - 32 | 33 | - - - 34 | 35 | Source | SS df MS Number of obs = 74 36 | -------------+---------------------------------- F(1, 72) = 20.26 37 | Model | 139449474 1 139449474 Prob > F = 0.0000 38 | Residual | 495615923 72 6883554.48 R-squared = 0.2196 39 | -------------+---------------------------------- Adj R-squared = 0.2087 40 | Total | 635065396 73 8699525.97 Root MSE = 2623.7 41 | 42 | ------------------------------------------------------------------------------ 43 | price | Coef. Std. Err. t P>|t| [95% Conf. Interval] 44 | -------------+---------------------------------------------------------------- 45 | mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 46 | cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03 47 | ------------------------------------------------------------------------------ 48 | 49 | 50 | ***/ 51 | 52 | *cap prog drop markdoc 53 | 54 | -------------------------------------------------------------------------------- /mini_mode_tests/MAIN.do: -------------------------------------------------------------------------------- 1 | /*** 2 | MarkDoc can be executed in 2 seperate modes, which are: 3 | 4 | 1. Active mode, examining a do-file in a fresh environment 5 | 2. Passive mode, converting a smcl log-file to a document 6 | 7 | Accordingly, I will create 2 sets of examples to examine 8 | each engine 9 | 10 | ***/ 11 | 12 | 13 | /*** 14 | Active Mode 15 | ----------- 16 | 17 | Navigate to the active_mini_mode example and execute the 18 | following commands 19 | ***/ 20 | 21 | // Hello World example 22 | markdoc "hello.do" , export("md") mini replace 23 | markdoc "hello.do" , export("html") mini replace 24 | markdoc "hello.do" , export("docx") mini replace 25 | markdoc "hello.do" , export("pdf") mini replace 26 | markdoc "hello.do" , export("sthlp") mini replace 27 | 28 | markdoc "test.do" , export("md") mini replace 29 | markdoc "test.do" , export("html") mini replace 30 | markdoc "test.do" , export("docx") mini replace 31 | markdoc "test.do" , export("pdf") mini replace 32 | markdoc "test.do" , export("sthlp") mini replace 33 | 34 | 35 | //go.do 36 | markdoc "go.do" , export("md") mini replace 37 | markdoc "go.do" , export("html") mini replace 38 | markdoc "go.do" , export("docx") mini replace 39 | markdoc "go.do" , export("pdf") mini replace 40 | markdoc "go.do" , export("sthlp") mini replace //only extracts the documentation 41 | 42 | markdoc "new.do" , export("md") mini replace 43 | markdoc "new.do" , export("html") mini replace 44 | markdoc "new.do" , export("docx") mini replace 45 | markdoc "new.do" , export("pdf") mini replace 46 | markdoc "new.do" , export("sthlp") mini replace //only extracts the documentation 47 | 48 | markdoc "test2.do" , export("md") mini replace 49 | markdoc "test2.do" , export("html") mini replace 50 | markdoc "test2.do" , export("docx") mini replace 51 | markdoc "test2.do" , export("pdf") mini replace 52 | markdoc "test2.do" , export("sthlp") mini replace 53 | 54 | // tests with `txt`, `img`, and `tbl` commands: 55 | markdoc "full1.do" , export("md") mini replace 56 | markdoc "full1.do" , export("html") mini replace 57 | markdoc "full1.do" , export("docx") mini replace 58 | markdoc "full1.do" , export("pdf") mini replace 59 | markdoc "full1.do" , export("sthlp") mini replace 60 | -------------------------------------------------------------------------------- /Torture_test/DOT/me3.txt: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | {title:Dynamic Graph} 4 | 5 | 1 6 | 2 7 | 3 8 | 9 | +{hline 9}{c TT}{hline 8} 10 | {c |} 11 | {c TLC}{hline 9}{c +}{hline 7}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 12 | {c |} markdown{c |}source {c LT}{hline 6}>{c |} mdddia {c LT}{hline 5}{hline 1}{c TT}{hline 3}>{c |} processed markdown {c |} 13 | {c BLC}{hline 9}{c BT}{hline 7}{c BRC} {c BLC}{hline 8}{c BRC} {c |} {c LT}{hline 20}{c RT} 14 | {c BLC}{hline 3}>{c |} image files {c |} 15 | {c BLC}{hline 20}{c BRC} 16 | 17 | 18 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 19 | {c |} markdown{c |}source {c LT}{hline 6}>{c |} mdddia {c LT}{hline 5}{hline 1}{c TT}{hline 4}{c RT} processed markdown {c |} 20 | {c BLC}{hline 17}{c BRC} {c BLC}{hline 3}{c TT}{hline 4}{c BRC} {c |} {c LT}{hline 20}{c RT} 21 | {c |} {c BLC}{hline 3}>{c |} image files {c |} 22 | {c TLC}{hline 9}{c BT}{hline 8}{c TRC} {c BLC}{hline 20}{c BRC} 23 | {c |} diagram creation {c |} 24 | {c LT}{hline 18}{c RT} 25 | {c |} ditaa/dot/rdfdot {c |} 26 | {c BLC}{hline 18}{c BRC} 27 | 28 | Source {c |} SS df MS Number of obs = 74 29 | {hline 13}{c +}{hline 34} F(1, 72) = 20.26 30 | Model {c |} 139449474 1 139449474 Prob > F = 0.0000 31 | Residual {c |} 495615923 72 6883554.48 R{hline 1}squared = 0.2196 32 | {hline 13}{c +}{hline 34} Adj R{hline 1}squared = 0.2087 33 | Total {c |} 635065396 73 8699525.97 Root MSE = 2623.7 34 | 35 | {hline 13}{c TT}{hline 64} 36 | price {c |} Coef. Std. Err. t P>{c |}t{c |} [95% Conf. Interval] 37 | {hline 13}{c +}{hline 64} 38 | mpg {c |} {hline 1}238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 39 | cons {c |} 11253.06 1170.813 9.61 0.000 8919.088 13587.03 40 | {hline 13}{c BT}{hline 64} 41 | 42 | 43 | 44 | *cap prog drop markdoc 45 | 46 | 47 | -------------------------------------------------------------------------------- /wkhtmltopdf.ado: -------------------------------------------------------------------------------- 1 | // documentation is written for markdoc package (github.com/haghish/markdoc) 2 | // . markdoc wkhtmltopdf.ado, mini export(sthlp) replace 3 | 4 | /*** 5 | _v. 1.1_ 6 | 7 | wkhtmltopdf 8 | =========== 9 | 10 | __wkhtmltopdf__ renders __html__ documents to __pdf__ within Stata 11 | 12 | Syntax 13 | ------ 14 | 15 | > __wkhtmltopdf__ [[_options_](http://wkhtmltopdf.org/usage/wkhtmltopdf.txt)] 16 | _filename.html_ _filename.pdf_ 17 | 18 | See the [_options_](http://wkhtmltopdf.org/usage/wkhtmltopdf.txt), which 19 | is a link to the __wkhtmltopdf__ manual, explaining the arguments you can 20 | add to adjust the pdf output. 21 | 22 | Description 23 | ----------- 24 | 25 | if the __mini__ engine is not used, 26 | __markdoc__ requires the [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html) 27 | software to convert __html__ to __pdf__ without requiring installing LaTeX. 28 | Moreove, __markdoc__ provides automatic installation of wkhtmltopdf, if desired. 29 | 30 | However, __markdoc__ is not the only software that deals with documents in Stata 31 | and many users show interest to create dynamic documents in their own way. 32 | to help them create __pdf__ documents, this command was created to convert their 33 | __html__ documents to __pdf__. 34 | 35 | Example 36 | ------- 37 | 38 | convert html file to pdf 39 | 40 | . wkhtmltopdf myfile.html myfile.pdf 41 | 42 | Author 43 | ------ 44 | 45 | E. F. Haghish 46 | University of Göttingen 47 | _haghish@med.uni-goesttingen.de_ 48 | [https://github.com/haghish](https://github.com/haghish) 49 | 50 | License 51 | ------- 52 | 53 | MIT License 54 | 55 | - - - 56 | 57 | This help file was dynamically produced by 58 | [MarkDoc Literate Programming package](http://www.haghish.com/markdoc/) 59 | ***/ 60 | 61 | *cap prog drop wkhtmltopdf 62 | program wkhtmltopdf 63 | 64 | // Run weaversetup 65 | // ------------------------------------------------------------------------- 66 | capture program drop weaversetup //reload it 67 | capture weaversetup //it might not be yet created 68 | 69 | if !missing("$pathWkhtmltopdf") { 70 | local printer "$pathWkhtmltopdf" 71 | } 72 | else { 73 | markdoccheck , export(pdf) 74 | local printer "$setpath" 75 | } 76 | 77 | *di as err ":::`printer'" 78 | 79 | shell "`printer'" `0' 80 | 81 | end 82 | 83 | 84 | -------------------------------------------------------------------------------- /Torture_test/DOT/me2.txt: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | {title:Dynamic Graph} 4 | 5 | 1 6 | 2 7 | 3 8 | 9 | +{hline 9}{c TT}{hline 8} 10 | {c |} 11 | {c TLC}{hline 9}{c +}{hline 7}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 12 | {c |} markdown{c |}source {c LT}{hline 6}>{c |} mdddia {c LT}{hline 6}{c TT}{hline 3}>{c |} processed markdown {c |} 13 | {c BLC}{hline 9}{c BT}{hline 7}{c BRC} {c BLC}{hline 8}{c BRC} {c |} {c LT}{hline 20}{c RT} 14 | {c BLC}{hline 3}>{c |} image files {c |} 15 | {hline 2} {hline 2} {c BLC}{hline 20}{c BRC} 16 | 17 | 18 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 19 | {c |} markdown{c |}source {c LT}{hline 6}>{c |} mdddia {c LT}{hline 6}{c TT}{hline 4}{c RT} processed markdown {c |} 20 | {c BLC}{hline 17}{c BRC} {c BLC}{hline 3}{c TT}{hline 4}{c BRC} {c |} {c LT}{hline 20}{c RT} 21 | {c |} {c BLC}{hline 3}>{c |} image files {c |} 22 | {c TLC}{hline 9}{c BT}{hline 8}{c TRC} {c BLC}{hline 20}{c BRC} 23 | {c |} diagram creation {c |} 24 | {c LT}{hline 18}{c RT} 25 | {c |} ditaa/dot/rdfdot {c |} 26 | {c BLC}{hline 18}{c BRC} 27 | 28 | {dlgtab:Tab} 29 | 30 | {hline} 31 | 32 | {hline} 33 | 34 | Source {c |} SS df MS Number of obs = 74 35 | {hline 13}{c +}{hline 34} F(1, 72) = 20.26 36 | Model {c |} 139449474 1 139449474 Prob > F = 0.0000 37 | Residual {c |} 495615923 72 6883554.48 R-squared = 0.2196 38 | {hline 13}{c +}{hline 34} Adj R-squared = 0.2087 39 | Total {c |} 635065396 73 8699525.97 Root MSE = 2623.7 40 | 41 | {hline 13}{c TT}{hline 64} 42 | price {c |} Coef. Std. Err. t P>{c |}t{c |} [95% Conf. Interval] 43 | {hline 13}{c +}{hline 64} 44 | mpg {c |} -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 45 | cons {c |} 11253.06 1170.813 9.61 0.000 8919.088 13587.03 46 | {hline 13}{c BT}{hline 64} 47 | 48 | 49 | 50 | *cap prog drop markdoc 51 | 52 | 53 | -------------------------------------------------------------------------------- /Torture_test/DOT/figure.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | 3 | {title:Dynamic Graph} 4 | 5 | 1 6 | 2 7 | 3 8 | 9 | +{hline 9}{c TT}{hline 8} 10 | {c |} 11 | {c TLC}{hline 9}{c +}{hline 7}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 12 | {c |} markdown{c |}source {c LT}{hline 6}>{c |} mdddia {c LT}{hline 6}{c TT}{hline 3}>{c |} processed markdown {c |} 13 | {c BLC}{hline 9}{c BT}{hline 7}{c BRC} {c BLC}{hline 8}{c BRC} {c |} {c LT}{hline 20}{c RT} 14 | {c BLC}{hline 3}>{c |} image files {c |} 15 | {hline 2} {hline 2} {c BLC}{hline 20}{c BRC} 16 | 17 | 18 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 19 | {c |} markdown{c |}source {c LT}{hline 6}>{c |} mdddia {c LT}{hline 6}{c TT}{hline 4}{c RT} processed markdown {c |} 20 | {c BLC}{hline 17}{c BRC} {c BLC}{hline 3}{c TT}{hline 4}{c BRC} {c |} {c LT}{hline 20}{c RT} 21 | {c |} {c BLC}{hline 3}>{c |} image files {c |} 22 | {c TLC}{hline 9}{c BT}{hline 8}{c TRC} {c BLC}{hline 20}{c BRC} 23 | {c |} diagram creation {c |} 24 | {c LT}{hline 18}{c RT} 25 | {c |} ditaa/dot/rdfdot {c |} 26 | {c BLC}{hline 18}{c BRC} 27 | 28 | {dlgtab:Tab} 29 | 30 | {hline} 31 | 32 | {hline} 33 | 34 | Source {c |} SS df MS Number of obs = 74 35 | {hline 13}{c +}{hline 34} F(1, 72) = 20.26 36 | Model {c |} 139449474 1 139449474 Prob > F = 0.0000 37 | Residual {c |} 495615923 72 6883554.48 R-squared = 0.2196 38 | {hline 13}{c +}{hline 34} Adj R-squared = 0.2087 39 | Total {c |} 635065396 73 8699525.97 Root MSE = 2623.7 40 | 41 | {hline 13}{c TT}{hline 64} 42 | price {c |} Coef. Std. Err. t P>{c |}t{c |} [95% Conf. Interval] 43 | {hline 13}{c +}{hline 64} 44 | mpg {c |} -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 45 | cons {c |} 11253.06 1170.813 9.61 0.000 8919.088 13587.03 46 | {hline 13}{c BT}{hline 64} 47 | 48 | 49 | 50 | *cap prog drop markdoc 51 | 52 | 53 | -------------------------------------------------------------------------------- /Examples/Examples.do: -------------------------------------------------------------------------------- 1 | /* 2 | Examples 3 | ======== 4 | 5 | MarkDoc has 3 different engines: 6 | 7 | 1. convert smcl log-file to document or presentation slides 8 | 9 | 2. execute a do-file, examine if it's reproducible, and produces dynamic 10 | document or slides 11 | 12 | 3. reads the documentation written in ado or mata files and export Stata help 13 | files of package vignette 14 | 15 | This document provides examples for all of the engines 16 | 17 | 18 | E. F. Haghish 19 | Department of Mathematics and Computer Science 20 | University of Southern Denmark 21 | Odense, Denmark 22 | 23 | Aug 2016 24 | */ 25 | 26 | cd "/Users/haghish/Documents/Packages/markdoc/Examples" 27 | 28 | 29 | 30 | // ============================================================================= 31 | // 32 | // PART 1 : TESTING SMCL ENGINE 33 | // 34 | // The smcl engine converts smcl log files to variety of formats 35 | // ============================================================================= 36 | 37 | // Mathematical notations 38 | do ./Mathematics/math_smcl.do 39 | 40 | 41 | 42 | 43 | 44 | // ============================================================================= 45 | // 46 | // PART 2 : TESTING DO ENGINE 47 | // 48 | // The do engine executes do-files in a cleared workspace 49 | // ============================================================================= 50 | 51 | // first load data in Stata, because MarkDoc will ignore your current workspace! 52 | sysuse auto, clear 53 | markdoc "./do/errors.do", export(html) replace statax 54 | markdoc "./do/errors.do", export(pdf) replace statax 55 | markdoc "./do/errors.do", export(docx) replace 56 | markdoc "./do/errors.do", export(odt) replace 57 | markdoc "./do/errors.do", export(latex) replace texmaster 58 | 59 | 60 | 61 | // Erase the products 62 | // ============================================================================= 63 | cap erase graph.png 64 | cap erase example.docx 65 | cap erase example.html 66 | cap erase example.odt 67 | 68 | cap erase example.pdf 69 | cap erase example.smcl 70 | cap erase example.tex 71 | cap erase example.aux 72 | cap erase example.log 73 | cap erase example.out 74 | cap erase example.synctex.gz 75 | 76 | cap erase example2.pdf 77 | cap erase example2.smcl 78 | cap erase example2.tex 79 | cap erase example2.aux 80 | cap erase example2.log 81 | cap erase example2.out 82 | cap erase example2.synctex.gz 83 | cap erase myprogram.ado 84 | 85 | -------------------------------------------------------------------------------- /Examples/dynamic_text/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 96 | 97 | 98 |
      ======================
 99 | 
100 |       ***/
101 |       (note: file /var/folders/b8/v19wyt1d3xngpr03_nc7fbtw0000gn/T//S_08163.000007 not found)
102 | 103 | 104 | -------------------------------------------------------------------------------- /mdconvert.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {it:v. 1.3} 3 | 4 | 5 | {title:mdconvert} 6 | 7 | {p 4 4 2} 8 | {bf:mdconvert} converts {browse "https://daringfireball.net/projects/markdown/":Markdown} to 9 | Microsoft Word {bf:docx} or {bf:pdf} within Stata 10 | 11 | 12 | {title:Syntax} 13 | 14 | {p 8 8 2} {bf:mdconvert} using {it:filename} [, {it:options}] 15 | 16 | {p 4 4 2}{bf:Options} 17 | 18 | {col 5}{it:option}{col 27}{it:Description} 19 | {space 4}{hline 75} 20 | {col 5}{ul:rep}lace{col 27}names of the exported file 21 | {col 5}name{col 27}bold face text 22 | {col 5}{ul:e}xport(name){col 27}document format which can be {bf:docx} or {bf:pdf} 23 | {col 5}{ul:t}itle(str){col 27}title of the document 24 | {col 5}{ul:au}thor(str){col 27}author of the document 25 | {col 5}{ul:aff}iliation(str){col 27}author affiliation 26 | {col 5}{ul:add}ress(str){col 27}author address or email 27 | {col 5}{ul:sum}mary(str){col 27}abstract or summary of the document 28 | {space 4}{hline 75} 29 | 30 | {title:Description} 31 | 32 | {p 4 4 2} 33 | {bf:mdconvert} is an alternative to {browse "https://pandoc.org/":Pandoc} for converting 34 | Markdown documents to {bf:docx} and {bf:pdf} within Stata 15. This package was 35 | developed to support {browse "https://github.com/haghish/markdoc":markdoc} package and 36 | allow generating dynamic documents independent of Pandoc or 37 | {browse "https://wkhtmltopdf.org/":wkhtmltopdf} for generating Microsoft Word and 38 | PDF documents respectively. 39 | 40 | 41 | {title:Limitations} 42 | 43 | {p 4 4 2} 44 | Generating docx and pdf files in Stata 15 is done using the {bf:putdocx} and 45 | {bf:putpdf} commands. Compared to Pandoc, these commands are still very limited 46 | and do not fully cover the Markdown syntax. For example, they do not allow: 47 | 48 | {break} 1. horizontal line 49 | {break} 2. Hyperlink 50 | {break} 3. Nested lists 51 | {break} 4. Mathematical notations 52 | 53 | 54 | {title:Examples} 55 | 56 | {p 4 4 2} 57 | convert Markdown file to docx 58 | 59 | . mdconvert using "markdown.md", name(mydoc) export(docx) replace 60 | 61 | {p 4 4 2} 62 | convert Markdown file to pdf 63 | 64 | . mdconvert using "markdown.md", name(mydoc) export(pdf) replace 65 | 66 | 67 | {title:Author} 68 | 69 | {p 4 4 2} 70 | E. F. Haghish {break} 71 | University of Göttingen {break} 72 | {it:haghish@med.uni-goesttingen.de} {break} 73 | {browse "https://github.com/haghish":https://github.com/haghish} 74 | 75 | 76 | {title:License} 77 | 78 | {p 4 4 2} 79 | MIT License 80 | 81 | {space 4}{hline} 82 | 83 | {p 4 4 2} 84 | This help file was dynamically produced by 85 | {browse "http://www.haghish.com/markdoc/":MarkDoc Literate Programming package} 86 | 87 | 88 | -------------------------------------------------------------------------------- /Torture_test/Beamer/example.do: -------------------------------------------------------------------------------- 1 | 2 | qui log using example, replace 3 | 4 | /*** 5 | 6 | --- 7 | title: "Dynamic Slides in MarkDoc Package" 8 | author: E. F. Haghish 9 | date: February 2016 10 | 11 | 12 | output: 13 | beamer_presentation: 14 | theme: "Boadilla" 15 | colortheme: "lily" 16 | fonttheme: "structurebold" 17 | --- 18 | 19 | Creating dynamic slides in Stata 20 | ================================ 21 | 22 | - Dynamic slides are slides created for statistical representation and thus, 23 | includes code and output from Stata. 24 | 25 | - The __`markdoc`__ command allows you to 26 | easily create a _smcl log file_ and use it for creating dynamic analysis 27 | reports or even PDF slides. In this tutorial I will demonstrate how to quickly 28 | create the slides from Stata. Here are a few capabilities of the package. 29 | 30 | 31 | About MarkDoc 32 | ============= 33 | 34 | MarkDoc is a general purpose literate programming package that can export 35 | dynamic reports in several formats within Stata. However, this tutorial only 36 | demonstrates the dynamic slide feature. 37 | 38 | - Adding images and figures 39 | - Interpreting mathematics 40 | - creating PDF slides 41 | 42 | 43 | How Does it Word? 44 | ================= 45 | 46 | - Install MarkDoc (ssc install markdoc) 47 | - Install a full LaTeX distribution 48 | - provide the path to **pdfLaTeX** in the `printer()` option (see below) 49 | - Learn from this example! 50 | 51 | 52 | 53 | 54 | How about mathematics? 55 | ====================== 56 | 57 | The dynamic slides are compiled with LaTeX and naturally, 58 | LaTeX mathematical notations are supported. Here is an example: 59 | 60 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 61 | 62 | 63 | 64 | 65 | How about Stata Output? 66 | ====================== 67 | 68 | You can execute any command and present the outputs as well! 69 | ***/ 70 | 71 | sysuse auto, clear 72 | tab price if price < 4000 73 | 74 | //OFF 75 | histogram price 76 | graph export graph.png, replace 77 | //ON 78 | 79 | 80 | /*** 81 | Adding a graph 82 | ========================== 83 | 84 | ![Histogram of the *Price* variable](graph.png) 85 | 86 | 87 | 88 | How to create more slides? 89 | ========================== 90 | 91 | - Every heading creates a new slide. 92 | - You can also use __#__ at the beginning of the line for creating a new slide. 93 | - or make a line with equal signs under a text line (see the code) 94 | 95 | ***/ 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | qui log c 104 | 105 | markdoc example, export(slide) replace // printer("PATH/TO/pdflatex") 106 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/syntax1A.md: -------------------------------------------------------------------------------- 1 | . do test1.do 2 | 3 | 4 | Title 1 5 | ======= 6 | 7 | **Hello** *World*! 8 | 9 | **hello** world! **what *the hell* is going on**! this is cool! 10 | ***we can also try a combination*** of these two! (_difficult_) **tests**. 11 | (*are*) also **WELCOMED**! 12 | 13 | And we can simple add multiple paragraphs? That is actually cool! 14 | In Markdown you can do a line break 15 | by adding 2 spaces at the end of the line 16 | without creating a new paragraph! 17 | 18 | Header 1 19 | ======== 20 | 21 | Let's Try a code 22 | ---------------- 23 | 24 | ### Code chunk! 25 | 26 | This is a code! **DO NOT INTERPRET** 27 | This is another code line 28 | 29 | Yet another one 30 | 31 | this is a paragraph again. We do not expect anything fuzzy here! 32 | 33 | Adding a figure with caption 34 | ---------------------------- 35 | 36 | ![Figure 1. This is a caption of the image](./graph.png) 37 | 38 | Adding a table with **tbl** command 39 | ----------------------------------- 40 | 41 | - - - 42 | 43 | - - - 44 | 45 | 46 | "Column1"|"Column2"|"Column3" 47 | :--------|:--------:|:--------: 48 | 4|5|6 49 | 7|8|9 50 | "OKOK"|"WHAT"|"NO WAY" 51 | "Let's try adding a long text here"|"and a semi long text here"|"NO WAY" 52 | 53 | 54 | 55 | ## Adding Indention 56 | 57 | You can also indent your text as well as do nested indention. Use the ">" sign 58 | at the beginning of the line to indent it. 59 | 60 | > this is a Markdown indention 61 | 62 | > > this is indention level 2 63 | 64 | > > > this is indention level 3 65 | 66 | Adding a list 67 | ------------- 68 | 69 | Stata's **markdown** command supports Markdown lists and nesting lists. 70 | However, **putdocx** and **putpdf** do not support lists yet. There has been 71 | a workaround to support Markdown lists in **md2doc**. But nested lists are 72 | not yet implemented because they look rather ugly without a decent support 73 | of lists in the document... 74 | 75 | 1. This is a list 76 | 2. This is list 2 77 | 3. This is list 3 78 | 79 | - This is unordered list 80 | - This is also unordered list 81 | 82 | * These are paragraph breaks 83 | * And so is this one 84 | 85 | Code block 86 | ---------- 87 | 88 | ~~~ 89 | This is a code block 90 | anything 91 | written here 92 | will be preserved 93 | ~~~ 94 | 95 | 96 | 97 | Limitations 98 | ----------- 99 | 100 | Some of the Markdown syntax is **NOT** yet supported by Stata's **putdocx** or 101 | **putpdf** commands. These limitations are listed below: 102 | 103 | 1. horizontal line 104 | 2. Hyperlink 105 | 3. Nested lists 106 | 4. Mathematical notations 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /Torture_test/Examples/short.do: -------------------------------------------------------------------------------- 1 | /* 2 | MarkDoc Torture Test 001 : Main Features Test 3 | --------------------------------------------- 4 | 5 | Author: E. F. Haghish 6 | Institute for Medical Biometry and Statistics (IMBI) 7 | University of Freiburg 8 | http://haghish.com/stat 9 | @haghish 10 | 11 | Requirements: Install MarkDoc, Weaver, and Statax packages 12 | Install Pandoc and Wkhtmltopdf 13 | If you wish to produce PDF Slides, install a complete LaTeX 14 | */ 15 | 16 | capture erase example.docx 17 | 18 | set scheme s1manual 19 | set linesize 80 20 | cap qui log c 21 | 22 | qui log using example, replace smcl 23 | 24 | 25 | /*** 26 | MarkDoc Feature Test 27 | ==================== 28 | 29 | This document attempts to check the main features of MarkDoc, for a broad 30 | assessment of the package before every new release. 31 | ***/ 32 | 33 | sysuse auto, clear 34 | /*** 35 | Text styling check 36 | ------------------ 37 | 38 | _this is Italic_. 39 | __this is bold__. 40 | ___this is Italic and Bold___. 41 | `this text line should be in monospace font`. 42 | 43 | Variable check 44 | -------------- 45 | 46 | Figure 1 shows the distribution of the __Price__ variable, followed by a 47 | regression analysis. 48 | ***/ 49 | 50 | histogram price 51 | img, title("Figure 1. The histogram of the price variable") 52 | regress price mpg 53 | //OFF 54 | mat A = r(table) 55 | scalar p1 = A[4,1] 56 | //ON 57 | txt "As the output demonstrates, the average price of cars is " pmean " and " /// 58 | "the standard deviation is " psd ". The summary of the __price__ and " /// 59 | "__mpg__ variables is given in Table 1. " /// 60 | "Moreover, the regression analysis reveals the coefficient of the __mpg__ " /// 61 | "variable to be " coe1 " with a P-value of " p1 ", which is significant." 62 | 63 | 64 | //OFF 65 | qui summarize price 66 | scalar pnum = r(N) 67 | scalar pmean = r(mean) 68 | scalar psd = r(sd) 69 | qui summarize mpg 70 | //ON 71 | 72 | tbl ("__variable__", "__Observations__", "__Mean__", "__SD__" \ /// 73 | "__Price__", pnum, pmean, psd \ /// 74 | "__Mpg__", r(N), r(mean), r(sd) ), /// 75 | title("_Table 1_. Summary of the price and mpg variables") 76 | 77 | 78 | qui log c 79 | markdoc example, install replace export(docx) /// 80 | title("MarkDoc Main Features Test") author("E. F. Haghish") /// 81 | affiliation("IMBI, University of Freiburg") summary("This document presents " /// 82 | "the main features of [MarkDoc package], a multi-purpose package for creating " /// 83 | "dynamic PDF slides and analysis reports in many formats such as __pdf__, " /// 84 | "__docx__, __html__, __latex__, and __epub__. The package supports many " /// 85 | "features and recognizes three markup languages, which are Markdown, HTML, " /// 86 | "and LaTeX." ) 87 | 88 | -------------------------------------------------------------------------------- /Torture_test/rundoc/rundoc_example.markdown: -------------------------------------------------------------------------------- 1 | `rundoc` command 2 | ================ 3 | 4 | The [`markdoc`](https://github.com/haghish/MarkDoc) command takes a 5 | `SMCL` log file to create a dynamic document or presentation slides. 6 | This procedure requires the user to create a log file and convert it to 7 | a dynamic document. 8 | 9 | The **`rundoc`** command, is simply a wrapper for MarkDoc to simplifies 10 | typesettinf dynamic documents directly from a Stata do-file, without 11 | requiring the do-file to include a log file. 12 | 13 | The syntax for writing comments remains identical to 14 | [`markdoc`](https://github.com/haghish/MarkDoc) command. This command 15 | should make executing dynamic documents much simpler! 16 | 17 | Features 18 | -------- 19 | 20 | ### executing Stata commands 21 | 22 | The **`rundoc`** command preserves all of the features of `markdoc`, 23 | because it is simply a wrapper program. Therefore, it preserves all of 24 | the features of `markdoc` such as executing Stata commands and syntax 25 | highlighting of the Stata commands using 26 | [`statax`](https://github.com/haghish/statax) package: 27 | 28 | . display "Hello MarkDoc" 29 | Hello MarkDoc 30 | 31 | . sysuse auto, clear 32 | (1978 Automobile Data) 33 | 34 | . summarize 35 | 36 | Variable | Obs Mean Std. Dev. Min Max 37 | -------------+--------------------------------------------------------- 38 | make | 0 39 | price | 74 6165.257 2949.496 3291 15906 40 | mpg | 74 21.2973 5.785503 12 41 41 | rep78 | 69 3.405797 .9899323 1 5 42 | headroom | 74 2.993243 .8459948 1.5 5 43 | -------------+--------------------------------------------------------- 44 | trunk | 74 13.75676 4.277404 5 23 45 | weight | 74 3019.459 777.1936 1760 4840 46 | length | 74 187.9324 22.26634 142 233 47 | turn | 74 39.64865 4.399354 31 51 48 | displacement | 74 197.2973 91.83722 79 425 49 | -------------+--------------------------------------------------------- 50 | gear_ratio | 74 3.014865 .4562871 2.19 3.89 51 | foreign | 74 .2972973 .4601885 0 1 52 | 53 | 54 | 55 | ### Writing mathematical notations 56 | 57 | Mathematical notations are supported in PDF, HTML, Docx, ODT 58 | (OpenOffice), and LaTeX: 59 | 60 | $$ Y = \beta_{0} + \beta_{1}x_{1} + \epsilon $$ 61 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/full1.do: -------------------------------------------------------------------------------- 1 | 2 | 3 | /*** 4 | Workshop Example 5 | ================ 6 | 7 | Subheader, Markdown syntax 8 | -------------------------- 9 | 10 | 11 | This is a normal paragraph. We are trying to import 12 | an image to our document. The image is stored in the 13 | working directory. The syntax for importing an image 14 | is as follows 15 | 16 | ![explain this figure](path/to/imagefile) 17 | 18 | ![explain this figure](example.png) 19 | 20 | 21 | There is a better way to include an image in the document. completely automatic! 22 | Let's start by creating a histogram and then using the `img` command: 23 | 24 | ***/ 25 | 26 | sysuse auto, clear 27 | hist price 28 | 29 | /*** 30 | ### Including an image 31 | 32 | Next, I am using the `img` command to automatically include the image in the 33 | document 34 | ***/ 35 | 36 | img, title("Figure 1. say something about this figure") 37 | 38 | 39 | /*** 40 | Writing dynamic text 41 | -------------------- 42 | 43 | We can use the `txt` command to write dynamic text in our documnt. 44 | ***/ 45 | 46 | summarize price 47 | 48 | /*** 49 | I can use the `return list` command to see what macros are returned by the 50 | `summarize` command. These values will be printed: 51 | ***/ 52 | 53 | return list 54 | 55 | 56 | txt "the mean of Price variable is " r(mean) 57 | 58 | txt "the minimum value is " r(min) " and the maximum is " r(max) 59 | 60 | 61 | 62 | /*** 63 | Writing dynamic table 64 | -------------------- 65 | 66 | We can use the `tbl` command to write dynamic tables. The `tbl` command generates 67 | the tables the same way Stata defines a matrix. To learn how Stata generate a 68 | matrix type: 69 | 70 | help matrix 71 | ***/ 72 | 73 | tbl ("*italic 1*", "*italic 2*", "*italic 3*" \ /// 74 | "**boldtext1**", 100, 1000 \ /// 75 | "**boldtext2**", 22, 222 \ /// 76 | "**boldtext3**", 3948, 3948), title("Table 1. Styling a table") 77 | 78 | 79 | tbl ({l}"Left", {c}"Centered", {r}"Right" \ c(os), c(machine_type), c(username)) 80 | 81 | 82 | /*** 83 | #### Adding mathematical symbols in the dynamic table 84 | 85 | We have to use the LaTeX mathematical syntax, but they will be automatically 86 | converted in all documents generated by MarkDoc 87 | ***/ 88 | 89 | tbl ("$\\beta$", "$95\\%$ Confidence Interval" \ "values...", "values...") 90 | 91 | tbl ("$\\beta$", "$\\epsilon$" \ "$\\sum$", "$\\prod$") 92 | 93 | 94 | /*** 95 | Creating a summary table 96 | ------------------------ 97 | 98 | I will use the macros returned from `summarize` command to build a nice table 99 | in my document: 100 | ***/ 101 | 102 | summarize price 103 | return list 104 | tbl ("Variable", "Observations", "Mean", "SD" \ /// 105 | "__price__", r(N), %9.2f r(mean), %9.2f r(sd)) 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /Examples/mini/slide.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Title 4 | ===== 5 | 6 | subtitle 7 | -------- 8 | 9 | --- 10 | 11 | # Tables 12 | 13 | Your documents, slides, and help files can include tables! 14 | 15 | | Tables | style of table | Cool | 16 | | :-------------- |:-------------------- | :------ | 17 | | col 3 is | right-aligned | $1600 | 18 | | col 2 is | centered | $12 | 19 | 20 | 21 | 22 | You can also create your tables online. The website mentioned below produces 23 | the format that is "ideal" for MarkDoc 24 | 25 | | __Website__ | __URL__ | 26 | |--------------------|-------------------------------------------------| 27 | | _Tables Generator_ | https://www.tablesgenerator.com/markdown_tables | 28 | 29 | --- 30 | 31 | # Agenda 32 | 33 | 1. Introduction 34 | 2. Deep-dive 35 | 3. ... 36 | 37 | or unordered list: 38 | 39 | - Introduction 40 | - Deep-dive 41 | - ... 42 | 43 | 44 | --- 45 | 46 | 47 | 48 | 49 | 50 | . sysuse auto, clear 51 | (1978 Automobile Data) 52 | 53 | . summarize price mpg 54 | 55 | Variable | Obs Mean Std. Dev. Min Max 56 | -------------+--------------------------------------------------------- 57 | price | 74 6165.257 2949.496 3291 15906 58 | mpg | 74 21.2973 5.785503 12 41 59 | 60 | 61 | 62 | This will start an __asis__ mode, which remember, it does not recognize "tabs". 63 | So until Stata fixes this problem, style your code with spaces rather than tabs. 64 | 65 | ~~~ 66 | 67 | if main.r2.iseq(1) { 68 | call main.master.enable 69 | } 70 | else { 71 | call main.master.disable 72 | } 73 | ~~~ 74 | 75 | 76 | --- 77 | 78 | # Introduction 79 | 80 | 81 | . reg price mpg 82 | 83 | Source | SS df MS Number of obs = 74 84 | -------------+---------------------------------- F(1, 72) = 20.26 85 | Model | 139449474 1 139449474 Prob > F = 0.0000 86 | Residual | 495615923 72 6883554.48 R-squared = 0.2196 87 | -------------+---------------------------------- Adj R-squared = 0.2087 88 | Total | 635065396 73 8699525.97 Root MSE = 2623.7 89 | 90 | ------------------------------------------------------------------------------ 91 | price | Coef. Std. Err. t P>|t| [95% Conf. Interval] 92 | -------------+---------------------------------------------------------------- 93 | mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 94 | _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03 95 | ------------------------------------------------------------------------------ 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /make.do: -------------------------------------------------------------------------------- 1 | // the 'make.do' file is automatically created by 'github' package. 2 | // execute the code below to generate the package installation files. 3 | // DO NOT FORGET to update the version of the package, if changed! 4 | // for more information visit http://github.com/haghish/github 5 | 6 | make markdoc, replace toc pkg version(5.0.0) /// 7 | license("MIT") /// 8 | author("E. F. Haghish") /// 9 | affiliation("University of Goettingen") /// 10 | email("haghish@med.uni-goettingen.de") /// 11 | url("https://github.com/haghish/github") /// 12 | title("a general-purpose literate programming package") /// 13 | description("generate dynamic document, slides, stata help files, " /// 14 | "and package vignette in various formats") /// 15 | install("markdoc_formal.docx;markdoc_minimal.docx;markdoc_simple.docx;" /// 16 | "markdoc_stata.docx;markdoc_title.dlg;markdoc.ado;markdoc.dlg;" /// 17 | "markdoc.sthlp;markdoccheck.ado;markdocpandoc.ado;" /// 18 | "markdocstyle.ado;markdocversion.ado;markdocwkhtmltopdf.ado;" /// 19 | "markup.ado;mdconvert.ado;mdconvert.sthlp;mdminor.ado;" /// 20 | "mdminor.sthlp;mini.ado;mini.dlg;mini.sthlp;pandoc.ado;" /// 21 | "pandoc.sthlp;rundoc.ado;sthlp.ado;sthlp.sthlp;wkhtmltopdf.ado;" /// 22 | "wkhtmltopdf.sthlp") /// 23 | ancillary("") 24 | 25 | 26 | 27 | /* 28 | Generating the package documentation 29 | ==================================== 30 | 31 | The package documentation is written in Markdown language. The MARKDOC package 32 | extract these documentation and create the Stata help files as well as Markdown 33 | documentation for GitHub Wiki. Learn more about MARKDOC here: 34 | https://github.com/haghish/markdoc 35 | 36 | Generating Stata Help Files 37 | --------------------------- 38 | */ 39 | 40 | markdoc "markdoc.ado", mini export(sthlp) replace 41 | markdoc "mini.ado", mini export(sthlp) replace 42 | markdoc "mdconvert.ado", mini export(sthlp) replace 43 | markdoc "mdminor.ado", mini export(sthlp) replace 44 | markdoc "pandoc.ado", mini export(sthlp) replace 45 | markdoc "wkhtmltopdf.ado", mini export(sthlp) replace 46 | 47 | // generate the Markdown documentation for GitHub 48 | markdoc "markdoc.ado", mini export(md) replace 49 | markdoc "mini.ado", mini export(md) replace 50 | markdoc "mdconvert.ado", mini export(md) replace 51 | markdoc "mdminor.ado", mini export(md) replace 52 | markdoc "pandoc.ado", mini export(md) replace 53 | markdoc "wkhtmltopdf.ado", mini export(md) replace 54 | 55 | markdoc "vignette.do", export(tex) toc replace master /// 56 | title("markdoc v. 5.0 package vignette") /// 57 | author("E. F. Haghish") 58 | -------------------------------------------------------------------------------- /Examples/dynamic_text/test2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 96 | 97 | 98 |
      .  sysuse auto, clear
 99 |       (1978 Automobile Data)
100 | 
101 |       . summarize foreign 
102 | 
103 |           Variable |        Obs        Mean    Std. Dev.       Min        Max
104 |       -------------+---------------------------------------------------------
105 |            foreign |         74    .2972973    .4601885          0          1
106 | 
107 |       . scalar c = "Dynamic" 
108 | 
109 |       . local min = `r(min)'
110 | 
111 |       . scalar max = r(max)
112 |

Dynamic text

113 |

The documentation can include numeric and string macros and scalars. For example, the values of the foreign variable range between 0 to 1.

114 | 115 | 116 | -------------------------------------------------------------------------------- /Torture_test/Beamer/Stata programs.do: -------------------------------------------------------------------------------- 1 | cap erase programming_course.pdf 2 | capture log c 3 | qui log using programming_course, replace 4 | 5 | 6 | /*** 7 | --- 8 | title: "Stata, as a programming language" 9 | author: E. F. Haghish 10 | 11 | date: March 2016 12 | 13 | fontsize: 14pt 14 | 15 | output: 16 | beamer_presentation: 17 | theme: "Boadilla" 18 | colortheme: "lily" 19 | fonttheme: "structurebold" 20 | 21 | includes: 22 | in_header: body.tex 23 | --- 24 | 25 | ABout the workshop 26 | ================================ 27 | 28 | - Reviewing different features of Stata programming language 29 | 30 | - Giving examples and homework for each feature 31 | 32 | - The workshop is completely lab-based, teaching solutions to actual problems 33 | 34 | 35 | ABout the workshop 36 | ================================ 37 | 38 | - The workshop includes a number of "problems" categorized as 39 | Beginner, Intermediate, and Advanced level 40 | 41 | - The solutions are already provided, but you should make an attempt for 42 | solving them yourself 43 | 44 | - After each problem, we discuss possible solutions and we spend a few minutes 45 | programming 46 | 47 | - I will cover a wide-range of programs 48 | 49 | 50 | Beginner Level 51 | ================================================================================ 52 | 53 | 54 | 55 | Intermediate Level 56 | ================================================================================ 57 | 58 | 59 | Problem 1 : File 60 | ================ 61 | 62 | "file allows programmers to read and write both text and binary files, so file 63 | could be used to write a program to input data in some complicated situation. 64 | Files are referred to by a file handle. When you open a file, you specify the 65 | file handle that you want to use" 66 | 67 | - read the following file with the program and count the number of lines! 68 | "https://raw.githubusercontent.com/haghish/MarkDoc/master/README.md" 69 | 70 | - Write an ado program that reads a file and counts the number of lines 71 | 72 | 73 | Solution 74 | ================ 75 | ***/ 76 | 77 | capture program drop countline 78 | program countline 79 | syntax using/ 80 | tempname handle 81 | file open `handle' using `"`using'"', read 82 | file read `handle' line 83 | local lnum 0 84 | while r(eof) == 0 { 85 | file read `handle' line 86 | local lnum `++lnum' 87 | } 88 | file close `handle' 89 | display as txt "(the file includes {bf:`lnum'} lines)" 90 | end 91 | 92 | countline using "https://raw.githubusercontent.com/haghish/MarkDoc/master/README.md" 93 | 94 | 95 | 96 | /*** 97 | Advanced Level 98 | ================================================================================ 99 | 100 | Problem 1 : File 101 | ================ 102 | 103 | In the first problem of the intermediate level, we wrote a program that opens 104 | a file and counts the number of lines. Rewrite that program with Mata 105 | 106 | 107 | 108 | ***/ 109 | 110 | 111 | 112 | qui log c 113 | markdoc programming_course, export(slide) replace linesize(120) 114 | 115 | 116 | -------------------------------------------------------------------------------- /putpdf_colors.do: -------------------------------------------------------------------------------- 1 | local namelist aliceblue ghostwhite navajowhite /// 2 | antiquewhite gold navy /// 3 | aqua goldenrod oldlace /// 4 | aquamarine gray olive /// 5 | azure green olivedrab /// 6 | beige greenyellow orange /// 7 | bisque honeydew orangered /// 8 | black hotpink orchid /// 9 | blanchedalmond indianred palegoldenrod /// 10 | blue indigo palegreen /// 11 | blueviolet ivory paleturquoise /// 12 | brown khaki palevioletred /// 13 | burlywood lavender papayawhip /// 14 | cadetblue lavenderblush peachpuff /// 15 | chartreuse lawngreen peru /// 16 | chocolate lemonchiffon pink /// 17 | coral lightblue plum /// 18 | cornflowerblue lightcoral powderblue /// 19 | cornsilk lightcyan purple /// 20 | crimson lightgoldenrodyellow red /// 21 | cyan lightgray rosybrown /// 22 | darkblue lightgreen royalblue /// 23 | darkcyan lightpink saddlebrown /// 24 | darkgoldenrod lightsalmon salmon /// 25 | darkgray lightseagreen sandybrown /// 26 | darkgreen lightskyblue seagreen /// 27 | darkkhaki lightslategray seashell /// 28 | darkmagenta lightsteelblue sienna /// 29 | darkolivegreen lightyellow silver /// 30 | darkorange lime skyblue /// 31 | darkorchid limegreen slateblue /// 32 | darkred linen slategray /// 33 | darksalmon magenta snow /// 34 | darkseagreen maroon springgreen /// 35 | darkslateblue mediumaquamarine steelblue /// 36 | darkslategray mediumblue tan /// 37 | darkturquoise mediumorchid teal /// 38 | darkviolet mediumpurple thistle /// 39 | deeppink mediumseagreen tomato /// 40 | deepskyblue mediumslateblue turquoise /// 41 | dimgray mediumspringgreen violet /// 42 | dodgerblue mediumturquoise wheat /// 43 | firebrick mediumvioletred white /// 44 | floralwhite midnightblue whitesmoke /// 45 | forestgreen mintcream yellow /// 46 | fuchsia mistyrose yellowgreen /// 47 | gainsboro moccasin 48 | 49 | putpdf clear 50 | putpdf begin 51 | putpdf paragraph 52 | 53 | tokenize "`namelist'" 54 | while "`1'" != "" { 55 | putpdf text ("`1'"), font("", 14, `1') linebreak 56 | macro shift 57 | } 58 | 59 | putpdf save putpdf_colors, replace 60 | -------------------------------------------------------------------------------- /Resources/images/announcement2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 15 | 20 | 22 | 24 | 26 | 28 | 29 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Torture_test/Examples/main_features.do: -------------------------------------------------------------------------------- 1 | capture erase example.docx 2 | 3 | /* 4 | MarkDoc Torture Test 001 : Main Features Test 5 | --------------------------------------------- 6 | 7 | Author: E. F. Haghish 8 | Institute for Medical Biometry and Statistics (IMBI) 9 | University of Freiburg 10 | http://haghish.com/stat 11 | @haghish 12 | 13 | Requirements: Install MarkDoc, Weaver, and Statax packages 14 | Install Pandoc and Wkhtmltopdf 15 | If you wish to produce PDF Slides, install a complete LaTeX 16 | */ 17 | 18 | set scheme s1manual 19 | set linesize 80 20 | cap qui log c 21 | 22 | sysuse auto, clear 23 | 24 | qui log using example, replace smcl 25 | 26 | 27 | /*** 28 | MarkDoc Feature Test 29 | ==================== 30 | 31 | Editable mathematical notations 32 | ------------------------------- 33 | 34 | Documenting statistical software or even teaching statistics often requires 35 | some mathematical discussions. The notation can be included in the output 36 | dynamically! 37 | 38 | $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 39 | 40 | 41 | Figure 1 shows the distribution of the __Price__ variable, followed by a 42 | regression analysis. 43 | ***/ 44 | 45 | histogram price 46 | img, title("Figure 1. The histogram of the price variable") 47 | regress price mpg 48 | //OFF 49 | mat A = r(table) 50 | scalar p1 = A[4,1] 51 | //ON 52 | txt "As the output demonstrates, the average price of cars is " pmean " and " /// 53 | "the standard deviation is " psd ". The summary of the __price__ and " /// 54 | "__mpg__ variables is given in Table 1. " /// 55 | "Moreover, the regression analysis reveals the coefficient of the __mpg__ " /// 56 | "variable to be " coe1 " with a P-value of " p1 ", which is significant." 57 | 58 | 59 | //OFF 60 | qui summarize price 61 | scalar pnum = r(N) 62 | scalar pmean = r(mean) 63 | scalar psd = r(sd) 64 | qui summarize mpg 65 | //ON 66 | 67 | tbl ("__variable__", "__Observations__", "__Mean__", "__SD__" \ /// 68 | "__Price__", pnum, pmean, psd \ /// 69 | "__Mpg__", r(N), r(mean), r(sd) ), /// 70 | title("_Table 1_. Summary of the price and mpg variables") 71 | 72 | 73 | qui log c 74 | 75 | markdoc example, install replace export(docx) /// 76 | title("MarkDoc Main Features Test") author("E. F. Haghish") /// 77 | affiliation("IMBI, University of Freiburg") summary("This document presents " /// 78 | "the main features of [MarkDoc package](http://www.haghish.com/markdoc), " /// 79 | "a multi-purpose package for creating dynamic PDF slides and analysis reports " /// 80 | "in many formats such as __pdf__, __docx__, __html__, __latex__, and " /// 81 | "__epub__. The package supports many features and recognizes three markup " /// 82 | "languages, which are Markdown, HTML, and LaTeX." ) 83 | 84 | markdoc example, install replace export(slide) /// 85 | title("MarkDoc Main Features Test") author("E. F. Haghish") /// 86 | affiliation("IMBI, University of Freiburg") summary("This document presents " /// 87 | "the main features of [MarkDoc package](http://www.haghish.com/markdoc), " /// 88 | "a multi-purpose package for creating dynamic PDF slides and analysis reports " /// 89 | "in many formats such as __pdf__, __docx__, __html__, __latex__, and " /// 90 | "__epub__. The package supports many features and recognizes three markup " /// 91 | "languages, which are Markdown, HTML, and LaTeX." ) 92 | -------------------------------------------------------------------------------- /Torture_test/Beamer/Beamer.do: -------------------------------------------------------------------------------- 1 | //capture prog drop markdoc 2 | capture erase example.pdf 3 | 4 | sysuse auto, clear 5 | capture log c 6 | qui log using example, replace 7 | /*** 8 | 9 | --- 10 | title: "Dynamic Slides in MarkDoc Package" 11 | author: E. F. Haghish 12 | date: or anything else 13 | fontsize: 14pt 14 | 15 | output: 16 | beamer_presentation: 17 | theme: "Boadilla" 18 | colortheme: "lily" 19 | fonttheme: "structurebold" 20 | 21 | includes: 22 | in_header: body.tex 23 | --- 24 | 25 | Creating dynamic slides in Stata 26 | ================================ 27 | 28 | - Dynamic slides are slides created for statistical representation and thus, 29 | includes code and output from Stata. 30 | 31 | - The __`markdoc`__ command allows you to 32 | easily create a _smcl log file_ and use it for creating dynamic analysis 33 | reports or even PDF slides. In this tutorial I will demonstrate how to quickly 34 | create the slides from Stata. Here are a few capabilities of the package. 35 | 36 | 37 | About MarkDoc 38 | ============= 39 | 40 | MarkDoc is a general purpose literate programming package that can export 41 | dynamic reports in several formats within Stata. However, this tutorial only 42 | demonstrates the dynamic slide feature. 43 | 44 | - Adding images and figures 45 | - Interpreting mathematics 46 | - creating PDF slides 47 | 48 | 49 | How Does it Word? 50 | ================= 51 | 52 | - Install MarkDoc (ssc install markdoc) 53 | - Install a full LaTeX distribution 54 | - Learn from this example! 55 | 56 | 57 | 58 | 59 | How about mathematics? 60 | ====================== 61 | 62 | The dynamic slides are compiled with \LaTeX{} and naturally, 63 | \LaTeX{} mathematical notations are supported. Here is an example: 64 | 65 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 66 | 67 | 68 | 69 | 70 | How about Stata Output? 71 | ====================== 72 | 73 | You can execute any command and present the outputs as well! 74 | ***/ 75 | 76 | 77 | tab price if price < 4000 78 | 79 | 80 | 81 | /*** 82 | How to create more slides? 83 | ========================== 84 | 85 | Every heading creates a new slide. You can also use __#__ at the beginning of 86 | the line for creating a new slide 87 | 88 | 89 | 90 | 91 | # How about wider Stata outputs 92 | 93 | if you use commands that produce wider tables, reduce the __fontsize__ 94 | at the beginning of the document to keep the output within the document. 95 | 96 | ***/ 97 | 98 | 99 | 100 | qui log c 101 | 102 | //capture prog drop markdoc 103 | markdoc example, export(slide) replace 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | exit 112 | 113 | cap erase example.pdf 114 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:Boadilla -V /// 115 | colortheme:lily -V fontsize=8pt -o example.pdf 116 | 117 | 118 | 119 | exit 120 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:AnnArbor -V fontsize=9pt -o example.pdf 121 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:AnnArbor -o example.pdf 122 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:Warsaw -o example01.pdf 123 | 124 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -o example01.pdf 125 | -------------------------------------------------------------------------------- /Torture_test/Beamer/Beamer3.do: -------------------------------------------------------------------------------- 1 | //capture prog drop markdoc 2 | capture erase example.pdf 3 | 4 | sysuse auto, clear 5 | capture log c 6 | qui log using example, replace 7 | /*** 8 | 9 | --- 10 | title: "Dynamic Slides in MarkDoc Package" 11 | author: E. F. Haghish 12 | date: February 2016 13 | fontsize: 14pt 14 | 15 | output: 16 | beamer_presentation: 17 | theme: "CambridgeUS" 18 | colortheme: "lily" 19 | fonttheme: "structurebold" 20 | 21 | includes: 22 | in_header: body.tex 23 | --- 24 | 25 | Creating dynamic slides in Stata 26 | ================================ 27 | 28 | ### header 3 29 | - Dynamic slides are slides created for statistical representation and thus, 30 | includes code and output from Stata. 31 | 32 | - The __`markdoc`__ command allows you to 33 | easily create a _smcl log file_ and use it for creating dynamic analysis 34 | reports or even PDF slides. In this tutorial I will demonstrate how to quickly 35 | create the slides from Stata. Here are a few capabilities of the package. 36 | 37 | 38 | About MarkDoc 39 | ============= 40 | 41 | #### Header 4 42 | 43 | MarkDoc is a general purpose literate programming package that can export 44 | dynamic reports in several formats within Stata. However, this tutorial only 45 | demonstrates the dynamic slide feature. 46 | 47 | - Adding images and figures 48 | - Interpreting mathematics 49 | - creating PDF slides 50 | 51 | 52 | How Does it Word? 53 | ================= 54 | 55 | - Install MarkDoc (ssc install markdoc) 56 | - Install a full LaTeX distribution 57 | - Learn from this example! 58 | 59 | 60 | 61 | 62 | How about mathematics? 63 | ====================== 64 | 65 | The dynamic slides are compiled with \LaTeX{} and naturally, 66 | \LaTeX{} mathematical notations are supported. Here is an example: 67 | 68 | - $f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ 69 | 70 | 71 | 72 | 73 | How about Stata Output? 74 | ====================== 75 | 76 | You can execute any command and present the outputs as well! 77 | ***/ 78 | 79 | 80 | tab price if price < 4000 81 | 82 | 83 | 84 | /*** 85 | How to create more slides? 86 | ========================== 87 | 88 | Every heading creates a new slide. You can also use __#__ at the beginning of 89 | the line for creating a new slide 90 | 91 | 92 | 93 | 94 | # How about wider Stata outputs 95 | 96 | if you use commands that produce wider tables, reduce the __fontsize__ 97 | at the beginning of the document to keep the output within the document. 98 | 99 | ***/ 100 | 101 | 102 | 103 | qui log c 104 | 105 | //capture prog drop markdoc 106 | markdoc example, export(slide) replace 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | exit 115 | 116 | cap erase example.pdf 117 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:Boadilla -V /// 118 | colortheme:lily -V fontsize=8pt -o example.pdf 119 | 120 | 121 | 122 | exit 123 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -V theme:AnnArbor -V fontsize=9pt -o example.pdf 124 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:AnnArbor -o example.pdf 125 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer example.md -V theme:Warsaw -o example01.pdf 126 | 127 | ! "C:\ado\plus\Weaver\Pandoc\pandoc.exe" -t beamer source.md -o example01.pdf 128 | -------------------------------------------------------------------------------- /Examples/Mathematics/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 88 | 89 | 90 |

Use a single "$" sign for writing inline mathematical notations. For example, \(f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n\) would be rendered inline with the text paragraph. Use double dollar signs "$$" for placing the notations on a separate lines:

91 |

\[Y_i = \beta_0 + \beta_1 X_i + \epsilon_i\]

92 |
    93 |
  1. Since the notations appear in comments, they will not be interpreted by Stata as global macros.

  2. 94 |
  3. Place a backslash before the "$" if you are using them in the document, but not for rendering mathematical notations. The backslash will not appear in the dynamic document.

  4. 95 |
  5. You can also write dynamic mathematical notations using the txt command.

    96 |
      .  local a = 10
  6. 97 |
98 |

\[ \beta_1 = 10 \]

99 |

Note that when you write inline mathematical notations, there should be NO SPACE between the dollar sign and the notation. However, if you are placing your notations on a separate line, there should be no problem.

100 | 101 | 102 | -------------------------------------------------------------------------------- /Examples/mini/doc.do: -------------------------------------------------------------------------------- 1 | // 1. change the working directory to where this file is saved 2 | // Execute this file with markdoc mini to create dynamic document/slides/sthlp 3 | 4 | /*** 5 | Header 6 | ====== 7 | 8 | something will appear 9 | 10 | --- 11 | 12 | Header 2 13 | -------- 14 | 15 | ### Header 3 16 | 17 | #### Header 4 18 | 19 | ##### Header 5 20 | 21 | --- 22 | 23 | Part 2 24 | ======= 25 | 26 | This is a text paragraph. Text can be *italic* or 27 | _italic_. Also, it can be **Bold** or __Bold__. 28 | 29 | > "the text paragraph can be indented for - typically -quoting " 30 | 31 | - This is item 1 32 | - Item 2 33 | - item 3 34 | - This is another item 35 | - quite file I hope 36 | - continue with the list 37 | 38 | --- 39 | 40 | Numbered list 41 | ============== 42 | 43 | 1. numbered item 1 44 | 2. item 2 45 | 3. back to item 46 | 47 | Using the "---" sign will add a line in the document 48 | 49 | --- 50 | 51 | Breaking the line 52 | ----------------- 53 | 54 | Add 2 or more spaces at the end of the line to break it without 55 | starting 56 | a new 57 | paragraph 58 | 59 | 60 | --- 61 | 62 | 63 | Adding links 64 | ------------- 65 | 66 | You can also add the __hypertext__ e.g. 67 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki) 68 | 69 | --- 70 | 71 | ***/ 72 | 73 | sysuse auto, clear //load auto dataset 74 | 75 | summarize 76 | 77 | /*** 78 | --- 79 | ***/ 80 | 81 | histogram price 82 | graph export price_hist.png, replace width(300) 83 | 84 | /*** 85 | Including a figure 86 | ------------------ 87 | 88 | Next, I include the histogram of the Price variable using 89 | the `histogram` command and the `price` variable. 90 | 91 | --- 92 | 93 | ![Figure 1. Histogram of the `price` variable](price_hist.png) 94 | 95 | ***/ 96 | 97 | 98 | // reloading the same image using `img` command: 99 | 100 | *img using "price_hist.png", title("explain your graph") 101 | 102 | 103 | histogram mpg 104 | 105 | img, title("Figure 2. Histogram of the `mpg` variable") 106 | 107 | 108 | /*** 109 | 110 | --- 111 | 112 | Writing dynamic text 113 | -------------------- 114 | 115 | use the `txt` command to interpret values of macros and scalars: 116 | ***/ 117 | 118 | summarize price 119 | return list 120 | 121 | txt "The number of subject is " r(N) " subjects in the darta set. " 122 | 123 | 124 | /*** 125 | 126 | --- 127 | 128 | creating table 129 | --------------- 130 | 131 | This table is also supported in __sthlp__ help files 132 | 133 | | __Optopns__ | __Discription__ | 134 | |-------------|------------------------------------------------------------------| 135 | | markup(str) | specifies the markup language that is used for documentation | 136 | | title(str) | displays the table description | 137 | | width(int) | specifies the width of the table in HTML and LaTeX | 138 | | height(int) | specifies the height of the table in HTML and LaTeX | 139 | | center | aligns the table to the center of the document in HTML and LaTeX | 140 | | left | aligns the table to the left of the document | 141 | 142 | --- 143 | 144 | Mathematical notations 145 | ====================== 146 | 147 | You can use markdoc to: 148 | 149 | 1. write inline notations (i.e. in the text paragraphs) 150 | 2. on a separate line 151 | 152 | For example, $\sum$ will appear inline whereas $$\sum$$ willbe on another line. 153 | 154 | 155 | ***/ 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /mini_mode_tests/active_mini_mode/summary.do: -------------------------------------------------------------------------------- 1 | // this document produces the dynamic document passively, because a log-file is 2 | // used to generate the PDF file, instead of a do-file! 3 | 4 | 5 | 6 | qui log using summary, replace 7 | 8 | /*** 9 | 10 | Notes 11 | -------- 12 | 13 | Here are a few important notes 14 | 15 | 1. As I noted, I have a book about `markdoc` that is nearly finished. I will 16 | send the PDF of the book to Dennis and kindly ask him to put send it to all 17 | of participants of the course. The book is very detailed and has many examples, 18 | and giving it to you is the least I can do to appologize from those few who 19 | had issues with installing the software on their computer and could not fully 20 | benefit from the course. I am certain that the book will provide much more 21 | details as well as examples about MarkDoc and will get everyone going. 22 | 23 | 2. `markdoc` has an option named `noisily`. If you are using the GUI, make sure 24 | the box that says `Execute MarkDoc noisily` is not checked. If you check this 25 | box, your report will be very noisy with information you did not ask for, 26 | because this option is for debugging. I remember some people asked me why they 27 | get extra information while others do not... 28 | 29 | 3. On Mac and Linux, the file path is specified with slash. On Microsoft Windows, 30 | with backslash. Therefore, anyone with Microsoft Windows who could not execute 31 | my example of `markdoc ./filename, ...` hat to actually type 32 | `markdoc .\filename, ...` on Microsoft Windows. This was so obvious, yet at the 33 | time of the presentation it didn't occure to me. 34 | 35 | 36 | Summary of Workshop 37 | =================== 38 | 39 | In the workshop, we covered multiple topics regarding `markdoc` package. Most 40 | notably, we learned about: 41 | 42 | 1. Markdown markup language. We also practiced the syntax at John Gruber's 43 | website which was . 44 | 45 | 2. We talked about writing dynamic text and adding figures in the document 46 | automatically. If you would like to know more about the `txt` and `img` commands, 47 | type: 48 | 49 | help txt 50 | help img 51 | 52 | 3. We also talked about the `tbl` command for building and styling dynamic tables 53 | that can be exported to any document format. To learn more about the `tbl` command 54 | type: 55 | 56 | help tbl 57 | 58 | 4. We also talked about using `markdoc` for generating presentation slides. 59 | 60 | 5. Most of the participants were interested in using `markdoc` for writing dynamic 61 | tables. Therefore, I have prepared additional examples for writing and styling 62 | dynamic tables. These examples will be available on markdoc's manual website soon. 63 | 64 | 65 | Resources 66 | --------- 67 | 68 | 69 | There are several resources that you can practice `markdoc` package. These 70 | resources are: 71 | 72 | - [markdoc's journal article](https://www.stata-journal.com/article.html?article=pr0064) 73 | - [markdoc's GitHub Wiki](https://github.com/haghish/markdoc/wiki) 74 | - [markdoc's vignette](https://github.com/haghish/markdoc/raw/master/Help/Help.pdf) 75 | 76 | --- 77 | 78 | 79 | If you have any question regarding `markdoc`, please kindly post it on 80 | , there is a rather big community of markdoc users 81 | there and I also regularly respond to the questions on this website. 82 | You can also reach me via email 83 | 84 | ***/ 85 | 86 | 87 | qui log c 88 | markdoc summary.smcl, export(pdf) replace style("formal") /// 89 | title("Summary of the workshop") author("E. F. Haghish") /// 90 | affiliation("University of Göttingen") /// 91 | address("haghish@med.uni-goettingen.de") 92 | -------------------------------------------------------------------------------- /Examples/Dynamic Slides/slide.do: -------------------------------------------------------------------------------- 1 | // Execute this file to create dynamic slides. Remember that you will need 2 | // pdfLaTeX to be installed 3 | 4 | 5 | 6 | /*** 7 | Header 8 | ====== 9 | 10 | sthing will appear 11 | 12 | Header 2 13 | -------- 14 | 15 | ### Header 3 16 | 17 | #### Header 4 18 | 19 | ##### Header 5 20 | 21 | Part 2 22 | ======= 23 | 24 | 25 | This is a text paragraph. Text can be *italic* or 26 | _italic_. Also, it can be **Bold** or __Bold__. 27 | 28 | > "the text paragraph can be indented for - typically -quoting " 29 | 30 | - This is item 1 31 | - Item 2 32 | - item 3 33 | * This is another item 34 | - quite file I hope 35 | - sublist item 1 36 | - sublist 2 37 | - subsublist 1 38 | - item 39 | 1. sth 40 | 2. sth 41 | - continue with sublist 42 | - continue with the list 43 | 44 | 45 | Numbered list 46 | ============== 47 | 48 | 1. numbered item 1 49 | 2. item 2 50 | 1. subitem 1 51 | 2. subitem 2 52 | 2. subsub item 53 | 2. sth 54 | 3. back to item 55 | 56 | Using the "---" sign will add a line in the document 57 | 58 | --- 59 | 60 | Breaking the line 61 | ----------------- 62 | 63 | Add 2 or more spaces at the end of the line to break it without 64 | starting 65 | a new 66 | paragraph 67 | 68 | 69 | --- 70 | 71 | 72 | Adding links 73 | ------------- 74 | 75 | This is a link to MarkDoc's GitHub Manual 76 | 77 | 78 | You can also change the __hypertext__ e.g. 79 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki) 80 | 81 | --- 82 | 83 | ***/ 84 | 85 | sysuse auto, clear //load auto dataset 86 | 87 | summarize 88 | 89 | /*** 90 | --- 91 | ***/ 92 | 93 | histogram price 94 | graph export price_hist.png, replace width(300) 95 | 96 | /*** 97 | Including a figure 98 | ------------------ 99 | 100 | Next, I include the histogram of the Price variable using 101 | the `histogram` command and the `price` variable. 102 | 103 | --- 104 | 105 | ![Figure 1. Histogram of the `price` variable](price_hist.png) 106 | 107 | ***/ 108 | 109 | 110 | // reloading the same image using `img` command: 111 | 112 | *img using "price_hist.png", title("explain your graph") 113 | 114 | 115 | histogram mpg 116 | 117 | img, title("Figure 2. Histogram of the `mpg` variable") 118 | 119 | 120 | /*** 121 | 122 | --- 123 | 124 | Writing dynamic text 125 | -------------------- 126 | 127 | use the `txt` command to interpret values of macros and scalars: 128 | ***/ 129 | 130 | summarize price 131 | return list 132 | 133 | txt "The number of subject is " r(N) " subjects in the darta set. " 134 | 135 | 136 | /*** 137 | 138 | --- 139 | 140 | creating table 141 | --------------- 142 | 143 | 144 | | __Optopns__ | __Discription__ | 145 | |-------------|------------------------------------------------------------------| 146 | | markup(str) | specifies the markup language that is used for documentation | 147 | | title(str) | displays the table description | 148 | | width(int) | specifies the width of the table in HTML and LaTeX | 149 | | height(int) | specifies the height of the table in HTML and LaTeX | 150 | | center | aligns the table to the center of the document in HTML and LaTeX | 151 | | left | aligns the table to the left of the document | 152 | 153 | -- 154 | 155 | size material color 156 | ---- ------------ ------------ 157 | 9 leather brown 158 | 10 hemp canvas natural 159 | 11 glass transparent 160 | 161 | 162 | Mathematical notations 163 | ====================== 164 | 165 | You can use markdoc to: 166 | 167 | 1. write inline notations (i.e. in the text paragraphs) 168 | 2. on a separate line 169 | 170 | For example, $\sum$ will appear inline whereas $$\sum$$ willbe on another line. 171 | 172 | 173 | ***/ 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /Examples/Dynamic Slides/example.do: -------------------------------------------------------------------------------- 1 | // Execute this file to create dynamic slides. Remember that you will need 2 | // pdfLaTeX to be installed 3 | 4 | 5 | 6 | /*** 7 | Header 8 | ====== 9 | 10 | sthing will appear 11 | 12 | Header 2 13 | -------- 14 | 15 | ### Header 3 16 | 17 | #### Header 4 18 | 19 | ##### Header 5 20 | 21 | Part 2 22 | ======= 23 | 24 | 25 | This is a text paragraph. Text can be *italic* or 26 | _italic_. Also, it can be **Bold** or __Bold__. 27 | 28 | > "the text paragraph can be indented for - typically -quoting " 29 | 30 | - This is item 1 31 | - Item 2 32 | - item 3 33 | * This is another item 34 | - quite file I hope 35 | - sublist item 1 36 | - sublist 2 37 | - subsublist 1 38 | - item 39 | 1. sth 40 | 2. sth 41 | - continue with sublist 42 | - continue with the list 43 | 44 | 45 | Numbered list 46 | ============== 47 | 48 | 1. numbered item 1 49 | 2. item 2 50 | 1. subitem 1 51 | 2. subitem 2 52 | 2. subsub item 53 | 2. sth 54 | 3. back to item 55 | 56 | Using the "---" sign will add a line in the document 57 | 58 | --- 59 | 60 | Breaking the line 61 | ----------------- 62 | 63 | Add 2 or more spaces at the end of the line to break it without 64 | starting 65 | a new 66 | paragraph 67 | 68 | 69 | --- 70 | 71 | 72 | Adding links 73 | ------------- 74 | 75 | This is a link to MarkDoc's GitHub Manual 76 | 77 | 78 | You can also change the __hypertext__ e.g. 79 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki) 80 | 81 | --- 82 | 83 | ***/ 84 | 85 | sysuse auto, clear //load auto dataset 86 | 87 | summarize 88 | 89 | /*** 90 | --- 91 | ***/ 92 | 93 | histogram price 94 | graph export price_hist.png, replace width(300) 95 | 96 | /*** 97 | Including a figure 98 | ------------------ 99 | 100 | Next, I include the histogram of the Price variable using 101 | the `histogram` command and the `price` variable. 102 | 103 | --- 104 | 105 | ![Figure 1. Histogram of the `price` variable](price_hist.png) 106 | 107 | ***/ 108 | 109 | 110 | // reloading the same image using `img` command: 111 | 112 | *img using "price_hist.png", title("explain your graph") 113 | 114 | 115 | histogram mpg 116 | 117 | img, title("Figure 2. Histogram of the `mpg` variable") 118 | 119 | 120 | /*** 121 | 122 | --- 123 | 124 | Writing dynamic text 125 | -------------------- 126 | 127 | use the `txt` command to interpret values of macros and scalars: 128 | ***/ 129 | 130 | summarize price 131 | return list 132 | 133 | txt "The number of subject is " r(N) " subjects in the darta set. " 134 | 135 | 136 | /*** 137 | 138 | --- 139 | 140 | creating table 141 | --------------- 142 | 143 | 144 | | __Optopns__ | __Discription__ | 145 | |-------------|------------------------------------------------------------------| 146 | | markup(str) | specifies the markup language that is used for documentation | 147 | | title(str) | displays the table description | 148 | | width(int) | specifies the width of the table in HTML and LaTeX | 149 | | height(int) | specifies the height of the table in HTML and LaTeX | 150 | | center | aligns the table to the center of the document in HTML and LaTeX | 151 | | left | aligns the table to the left of the document | 152 | 153 | -- 154 | 155 | size material color 156 | ---- ------------ ------------ 157 | 9 leather brown 158 | 10 hemp canvas natural 159 | 11 glass transparent 160 | 161 | 162 | Mathematical notations 163 | ====================== 164 | 165 | You can use markdoc to: 166 | 167 | 1. write inline notations (i.e. in the text paragraphs) 168 | 2. on a separate line 169 | 170 | For example, $\sum$ will appear inline whereas $$\sum$$ willbe on another line. 171 | 172 | 173 | ***/ 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /Torture_test/test/helptest.sthlp: -------------------------------------------------------------------------------- 1 | {smcl} 2 | {right:version 1.0.0} 3 | {title:Title} 4 | 5 | {phang} 6 | {bf:myprogram }{hline 2} A new module for to print text. This description can include multiple lines, but not several paragraphs. You may write the title section in multiple lines. {help MarkDoc} will connect the lines to create only a single paragraph. If you{c 39}d like to describe the package more, create a description section below this header. 7 | 8 | 9 | {title:Author} 10 | 11 | {p 4 4 2} 12 | E. F. Haghish{break} 13 | University of Freiburg{break} 14 | haghish@imbi.uni-freiburg.de{break} 15 | {browse "http://www.haghish.com/markdoc"}{break} 16 | 17 | 18 | {title:Syntax} 19 | 20 | {p 8 16 2} 21 | {opt myprogram} [{it:anything}] [, {opt b:old} {opt i:talic}] 22 | 23 | {synoptset 20 tabbed}{...} 24 | {synopthdr} 25 | {synoptline} 26 | {synopt :{opt b:old}}prints bold text{p_end} 27 | {synopt :{opt i:talic}}prints italic text{p_end} 28 | {synoptline} 29 | 30 | 31 | 32 | {p} 33 | Typically, the text paragraphs in Stata help files begin with an indention, which makes the help file easier to read (and that{c 39}s important). To do so, place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text paragraph and you{c 39}re good to go. 34 | 35 | {p} 36 | this is a text paragraph that is processing {bf:Markdown}, {it:italic text} or {ul:underscored text}. The only thing left is the link! but how far can this {bf:text styling go}? I mean how far does the rabit whole go? do you have any idea? 37 | 38 | 39 | {hline} 40 | 41 | {p} 42 | this is a text paragraph that is processing {bf:Markdown}, {it:italic text} or {ul:underscored text}. The only thing left is the link! but how far can this {bf:text styling go}? I mean how far does the rabit whole go? do you have any idea? 43 | 44 | 45 | {p 4 4 2} 46 | this is a text paragraph that is processing {bf:Markdown}, {it:italic text} or {ul:underscored text}. The only thing left is the link! but how far can this {bf:text styling go}? I mean how far does the rabit whole go? do you have any idea? 47 | 48 | 49 | 50 | {title:Another heading } 51 | 52 | {p 4 4 2} 53 | Typically, the text paragraphs in Stata help files begin with an indention, 54 | which makes the help file easier to read (and that's important). To do so, 55 | place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text 56 | paragraph and you're good to go. 57 | 58 | 59 | {title:Example} 60 | 61 | print {bf:bold} text 62 | . myprogram "print this text in bold", bold 63 | 64 | print {it:italic} text 65 | . myprogram "print this text in italic", i 66 | 67 | {title:Dynamic Graph} 68 | 69 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c TLC}{hline 20}{c TRC} 70 | {c |} markdown source {c |}{hline 6}>{c |} mdddia {c |}{hline 5}-{c +}{hline 3}>{c |} processed markdown {c |} 71 | {c TLC}{hline 17}{c TRC} {c TLC}{hline 8}{c TRC} {c |} {c TLC}{hline 20}{c TRC} 72 | {c |} {c TLC}{hline 3}>{c |} image files {c |} 73 | {c TLC}{hline 18}{c TRC} {c TLC}{hline 20}{c TRC} 74 | {c |} diagram creation {c |} 75 | {c TLC}{hline 18}{c TRC} 76 | {c |} ditaa/dot/rdfdot {c |} 77 | {c TLC}{hline 18}{c TRC} 78 | 79 | 80 | {title: Source | SS df MS Number of obs = 74} 81 | Model | 139449474 1 139449474 Prob > F = 0.0000 82 | 83 | {title: Residual | 495615923 72 6883554.48 R-squared = 0.2196} 84 | Total | 635065396 73 8699525.97 Root MSE = 2623.7 85 | 86 | price | Coef. Std. Err. t P>|t| [95% Conf. Interval] 87 | mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879 88 | 89 | {title: _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03} 90 | 91 | 92 | 93 | *cap prog drop markdoc 94 | markdoc test/helptest.ado, replace export(sthlp) 95 | -------------------------------------------------------------------------------- /Examples/do/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 88 | 89 | 90 | 91 |

Making the source code really reproducible

92 |

To make the do-file really reproducible, we have to make sure it does not access the data that is already loaded in Stata. Think about it, if you execute a do-file on a data that is already loaded and you have been working on it, can you ensure that re-executing the do-file creates the same results again? you might have done some changes outside of the do-file on the data - such as droping a record - which makes the results ireproducible.

93 |

The solution would be to run the do-file in a cleared workspace to ensure the do-file does not access the data that is already loaded. MarkDoc can take a do-file and execute the code in a cleared workspace and produce the dynamic document. This is a very different engine compared to rendering a smcl-log to a dynamic document.

94 |

If the do-file return an error, MarkDoc still create the dynamic document until the point the error occured. To run this do-file, first load the auto dataset in Stata. Then call markdoc to produce the dynamic document. You should get an error the no variables defined, which means your do-file does not load the data, although the data are loaded in your Stata.

95 |
  .  display "the next command will be an error"
96 |
      the next command will be an error
 97 |       
98 |
  .  regress price mpg
99 |
      no variables defined
100 |       r(111);
101 |       
102 |       end of do-file
103 |       
104 | 105 | 106 | -------------------------------------------------------------------------------- /Torture_test/DOT/markdown_DOT.do: -------------------------------------------------------------------------------- 1 | 2 | // ----------------------------------------------------------------------------- 3 | // Literate Visualization Notation 4 | // ============================================================================= 5 | qui log using 000, replace smcl 6 | /*** 7 | Dynamic Software Visualization 8 | ========================= 9 | 10 | 11 | Writing software documentation and visualizing seletive information can 12 | boost active learning in students. It can also provide very useful information 13 | about structure of a software and encourages users to read the code and 14 | contribute to an open-source project. __MarkDoc package__ supports the 15 | ___DOT___ (graph description language), and it can produce HTML documents 16 | with graphs, written within the source code or data analysis. 17 | 18 | The graph can be written in different sections. However, MarkDoc has a 19 | separate syntax for beginning a new graph or continuing the previous graphs. 20 | to begin a new graph, use the regular syntax for wiriting documentation plus 21 | a double dollar sign and to continue using the current 22 | graph, use a single dollar sign. Here is an example: 23 | ***/ 24 | 25 | /***$$ 26 | digraph { 27 | Hello -> World; 28 | } 29 | ***/ 30 | 31 | /*** 32 | Continues figures 33 | ----------------- 34 | 35 | It's much easier to write a detailed graph in different section and update 36 | it, when there is a change in that section. Writing a detailed graph at once 37 | and within a single section makes it _less interesting_ and makes it feel like 38 | _extra work_ when the job is already done. However if the graph is developed 39 | gradually, as the program is written, it's more encouraging. For example, the 40 | graph below is written in two separate sections. 41 | ***/ 42 | 43 | /***$$ 44 | graph ER { 45 | node [shape=box]; course; institute; student; 46 | node [shape=ellipse]; {node [label="name"] name0; name1; name2;} 47 | code; grade; number; 48 | node [shape=diamond,style=filled,color=lightgrey]; "C-I"; "S-C"; "S-I"; 49 | 50 | name0 -- course; 51 | code -- course; 52 | course -- "C-I" [label="n",len=1.00]; 53 | "C-I" -- institute [label="1",len=1.00]; 54 | ***/ 55 | 56 | 57 | 58 | /***$ 59 | institute -- name1; 60 | institute -- "S-I" [label="1",len=1.00]; 61 | "S-I" -- student [label="n",len=1.00]; 62 | student -- grade; 63 | student -- name2; 64 | student -- number; 65 | student -- "S-C" [label="m",len=1.00]; 66 | "S-C" -- course [label="n",len=1.00]; 67 | 68 | label = "\n\nEntity Relation Diagram\ndrawn by NEATO"; 69 | fontsize=20; 70 | } 71 | ***/ 72 | 73 | 74 | /*** 75 | Example 1 76 | --------- 77 | ***/ 78 | 79 | /***$$ 80 | digraph { 81 | subgraph cluster_0 { 82 | label="Subgraph A"; 83 | a -> b; 84 | b -> c; 85 | c -> d; 86 | } 87 | 88 | subgraph cluster_1 { 89 | label="Subgraph B"; 90 | a -> f; 91 | f -> c; 92 | } 93 | } 94 | ***/ 95 | 96 | 97 | /*** 98 | Example 2 99 | --------- 100 | ***/ 101 | 102 | /***$$ 103 | digraph { 104 | a -> b[label="0.2",weight="0.2"]; 105 | a -> c[label="0.4",weight="0.4"]; 106 | c -> b[label="0.6",weight="0.6"]; 107 | c -> e[label="0.6",weight="0.6"]; 108 | e -> e[label="0.1",weight="0.1"]; 109 | e -> b[label="0.7",weight="0.7"]; 110 | } 111 | ***/ 112 | 113 | 114 | 115 | 116 | 117 | 118 | /*** 119 | Example 3 120 | --------- 121 | ***/ 122 | /***$$ 123 | digraph G { 124 | 125 | subgraph cluster_0 { 126 | style=filled; 127 | color=lightgrey; 128 | node [style=filled,color=white]; 129 | a0 -> a1 -> a2 -> a3; 130 | label = "process #1"; 131 | } 132 | 133 | subgraph cluster_1 { 134 | node [style=filled]; 135 | b0 -> b1 -> b2 -> b3; 136 | label = "process #2"; 137 | color=blue 138 | } 139 | start -> a0; 140 | start -> b0; 141 | a1 -> b3; 142 | b2 -> a3; 143 | a3 -> a0; 144 | a3 -> end; 145 | b3 -> end; 146 | 147 | start [shape=Mdiamond]; 148 | end [shape=Msquare]; 149 | } 150 | ***/ 151 | 152 | 153 | 154 | qui log c 155 | markdoc 000, replace exp(html) 156 | -------------------------------------------------------------------------------- /Examples/Workshops/2018/dofiles/example.do: -------------------------------------------------------------------------------- 1 | // Comments will not be in the rendered document 2 | 3 | /* 4 | This is a comment 5 | */ 6 | 7 | * Another comment 8 | 9 | // -------------------------------------------- 10 | 11 | //OFF 12 | 13 | displa "this will be hidden" 14 | 15 | //ON 16 | 17 | /**/ display "Hellow World" 18 | 19 | /***/ display "hello world" 20 | 21 | /*** 22 | Header 23 | ====== 24 | 25 | sthing will appear 26 | 27 | Header 2 28 | -------- 29 | 30 | ### Header 3 31 | 32 | #### Header 4 33 | 34 | ##### Header 5 35 | 36 | Part 2 37 | ======= 38 | 39 | 40 | This is a text paragraph. Text can be *italic* or 41 | _italic_. Also, it can be **Bold** or __Bold__. 42 | 43 | > "the text paragraph can be indented for - typically -quoting " 44 | 45 | - This is item 1 46 | - Item 2 47 | - item 3 48 | * This is another item 49 | - quite file I hope 50 | - sublist item 1 51 | - sublist 2 52 | - subsublist 1 53 | - item 54 | 1. sth 55 | 2. sth 56 | - continue with sublist 57 | - continue with the list 58 | 59 | 60 | Numbered list 61 | ============== 62 | 63 | 1. numbered item 1 64 | 2. item 2 65 | 1. subitem 1 66 | 2. subitem 2 67 | 2. subsub item 68 | 2. sth 69 | 3. back to item 70 | 71 | Using the "---" sign will add a line in the document 72 | 73 | --- 74 | 75 | Breaking the line 76 | ----------------- 77 | 78 | Add 2 or more spaces at the end of the line to break it without 79 | starting 80 | a new 81 | paragraph 82 | 83 | 84 | --- 85 | 86 | 87 | Adding links 88 | ------------- 89 | 90 | This is a link to MarkDoc's GitHub Manual 91 | 92 | 93 | You can also change the __hypertext__ e.g. 94 | [MarDoc's Manual](https://github.com/haghish/MarkDoc/wiki) 95 | 96 | --- 97 | 98 | ***/ 99 | 100 | sysuse auto, clear //load auto dataset 101 | 102 | summarize 103 | 104 | /*** 105 | --- 106 | ***/ 107 | 108 | histogram price 109 | graph export ./price_hist.png, replace width(300) 110 | 111 | /*** 112 | Including a figure 113 | ------------------ 114 | 115 | Next, I include the histogram of the Price variable using 116 | the `histogram` command and the `price` variable. 117 | 118 | --- 119 | 120 | ![Figure 1. Histogram of the `price` variable](./price_hist.png) 121 | 122 | ***/ 123 | 124 | 125 | // reloading the same image using `img` command: 126 | img using "./price_hist.png", title("using the img command to include exported figure") 127 | 128 | 129 | histogram mpg 130 | 131 | img, title("Figure 2. Histogram of the `mpg` variable") 132 | 133 | 134 | /*** 135 | 136 | --- 137 | 138 | Writing dynamic text 139 | -------------------- 140 | 141 | use the `txt` command to interpret values of macros and scalars: 142 | ***/ 143 | 144 | summarize price 145 | return list 146 | 147 | txt "The number of subject is " r(N) " subjects in the darta set. " 148 | 149 | 150 | /*** 151 | 152 | --- 153 | 154 | creating table 155 | --------------- 156 | 157 | 158 | | __Optopns__ | __Discription__ | 159 | |-------------|------------------------------------------------------------------| 160 | | markup(str) | specifies the markup language that is used for documentation | 161 | | title(str) | displays the table description | 162 | | width(int) | specifies the width of the table in HTML and LaTeX | 163 | | height(int) | specifies the height of the table in HTML and LaTeX | 164 | | center | aligns the table to the center of the document in HTML and LaTeX | 165 | | left | aligns the table to the left of the document | 166 | 167 | --- 168 | 169 | size material color 170 | ---- ------------ ------------ 171 | 9 leather brown 172 | 10 hemp canvas natural 173 | 11 glass transparent 174 | 175 | 176 | Mathematical notations 177 | ====================== 178 | 179 | You can use markdoc to: 180 | 181 | 1. write inline notations (i.e. in the text paragraphs) 182 | 2. on a separate line 183 | 184 | For example, $\sum$ will appear inline whereas $$\sum$$ will be on another line. 185 | ***/ 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /Torture_test/sthlp/example.ado: -------------------------------------------------------------------------------- 1 | /*** DO NOT EDIT THIS LINE ----------------------------------------------------- 2 | 3 | Version: 1.0.0 4 | 5 | 6 | Intro Description 7 | ================= 8 | 9 | myprogram -- A new module for to print text. This description can include 10 | multiple lines, but not several paragraphs. You may write the title section 11 | in multiple lines. {help MarkDoc} will connect the lines to create only a 12 | single paragraph. If you'd like to describe the package more, create a 13 | description section below this header. 14 | 15 | Author(s) section 16 | ================= 17 | 18 | E. F. Haghish 19 | University of Freiburg 20 | haghish@imbi.uni-freiburg.de 21 | {browse "http://www.haghish.com/markdoc"} 22 | 23 | Syntax 24 | ================= 25 | 26 | {opt myprogram} [{it:anything}] [, {opt b:old} {opt i:talic}] 27 | 28 | {synoptset 20 tabbed}{...} 29 | {synopthdr} 30 | {synoptline} 31 | {synopt :{opt b:old}}prints bold text{p_end} 32 | {synopt :{opt i:talic}}prints italic text{p_end} 33 | {synoptline} 34 | ----------------------------------------------------- DO NOT EDIT THIS LINE ***/ 35 | 36 | * Note: If you like to leave the "Intro Description" or "Author(s) section 37 | * empty, erase the text but KEEP THE HEADINGS 38 | 39 | 40 | cap prog drop myprogram 41 | program myprogram 42 | syntax [anything] [, Bold Italic] 43 | if missing("`bold'") & missing("`italic'") { 44 | display as txt `anything' 45 | } 46 | else if !missing("`bold'") & missing("`italic'") { 47 | local anything : display `anything' 48 | display as txt "{bf:`anything'}" 49 | } 50 | else if missing("`bold'") & !missing("`italic'") { 51 | local anything : display `anything' 52 | display as txt "{it:`anything'}" 53 | } 54 | else { 55 | local anything : display `anything' 56 | display "{bf:{it:`anything'}}" 57 | } 58 | end 59 | 60 | 61 | /*** 62 | 63 | 64 | : Typically, the text paragraphs in Stata help files begin with an indention, 65 | which makes the help file easier to read (and that's important). To do so, 66 | place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text 67 | paragraph and you're good to go. 68 | 69 | : this is a text paragraph that is processing __Markdown__, _italic text_ or 70 | ___underscored text___. The only thing left is the link! but how far can this 71 | __text styling go__? I mean how far does the 72 | rabit whole go? do you have any idea? 73 | 74 | 75 | - - - 76 | 77 | : this is a text paragraph that is processing __Markdown__, _italic text_ or 78 | ___underscored text___. The only thing left is the link! but how far can this 79 | __text styling go__? I mean how far does the 80 | rabit whole go? do you have any idea? 81 | 82 | 83 | > this is a text paragraph that is processing __Markdown__, _italic text_ or 84 | ___underscored text___. The only thing left is the link! but how far can this 85 | __text styling go__? I mean how far does the 86 | rabit whole go? do you have any idea? 87 | 88 | 89 | Another heading 90 | ---------------------- 91 | 92 | {p 4 4 2} 93 | Typically, the text paragraphs in Stata help files begin with an indention, 94 | which makes the help file easier to read (and that's important). To do so, 95 | place a {bf:{c -(}p 4 4 2{c )-}} directive above the line to indent the text 96 | paragraph and you're good to go. 97 | 98 | ***/ 99 | 100 | /*** 101 | Example 102 | ================= 103 | 104 | print {bf:bold} text 105 | . myprogram "print this text in bold", bold 106 | 107 | print {it:italic} text 108 | . myprogram "print this text in italic", i 109 | ***/ 110 | 111 | /*** 112 | Dynamic Graph 113 | ============= 114 | 115 | +-----------------+ +--------+ +--------------------+ 116 | | markdown source |------>| mdddia |---------->| processed markdown | 117 | +-----------------+ +--------+ | +--------------------+ 118 | | +--->| image files | 119 | +------------------+ +--------------------+ 120 | | diagram creation | 121 | +------------------+ 122 | | ditaa/dot/rdfdot | 123 | +------------------+ 124 | 125 | ***/ 126 | 127 | *cap prog drop markdoc 128 | 129 | -------------------------------------------------------------------------------- /Torture_test/do/example.do: -------------------------------------------------------------------------------- 1 | /*** DO NOT EDIT THIS LINE ----------------------------------------------------- 2 | 3 | Version: 0.0.0 4 | 5 | 6 | Intro Description 7 | ================= 8 | 9 | packagename -- A new module for ... 10 | 11 | 12 | Author(s) section 13 | ================= 14 | 15 | Author name ... 16 | Author affiliation ... 17 | to add more authors, leave an empty line between authors' information 18 | 19 | Second author ... 20 | For more information visit {browse "http://www.haghish.com/markdoc":MarkDoc homepage} 21 | 22 | 23 | Syntax 24 | ================= 25 | 26 | {opt exam:ple} {depvar} [{indepvars}] {ifin} using 27 | [{it:{help filename:filename}}] 28 | [{cmd:,} {it:options}] 29 | 30 | {synoptset 20 tabbed}{...} 31 | {synopthdr} 32 | {synoptline} 33 | {synopt :{opt rep:lace}}replace this example{p_end} 34 | {synopt :{opt app:end}}work further on this help file{p_end} 35 | {synopt :{opt addmore}}you can add more description for the options; Moreover, 36 | the text you write can be placed in multiple lines {p_end} 37 | {synopt :{opt learn:smcl}}you won't make a loss learning 38 | {help smcl:SMCL Language} {p_end} 39 | {synoptline} 40 | ----------------------------------------------------- DO NOT EDIT THIS LINE ***/ 41 | 42 | * Note: If you like to leave the "Intro Description" or "Author(s) section 43 | * empty, erase the text but KEEP THE HEADINGS 44 | 45 | 46 | 47 | 48 | 49 | /*** 50 | 51 | \section{Reading statistical packages} 52 | 53 | :Literate programming was adopted by statisticians for documenting the process of data analysis and generating dynamic analysis reports \cite{ Literate_programming_using_noweb, 1994_Literate_programming_simplified, Literate_Statistical_Programming.Concepts_and_Tools} and several literate programming packages have been developed particularly for statistical languages to meet the special features required for analysis reports \cite{weaver, markdoc, xie2013knitr, xieknit, leisch2002sweave, allaire2015rmarkdown, statweave}. 54 | 55 | >While statisticians strongly support literate programming for data analysis, when it comes to programming statistical packages, the best they have come up with is documenting individual functions and objects using literate programming packages such as Roxygen2 \cite{roxygen2:In-source_documentation_for_R} in R or MarkDoc \cite{markdoc} in Stata. However, as the number of script files and the structural complexity of the package (nested files or functions) increase, the object documentation will provide minor information about the overall structure and logic of the package. 56 | 57 | Any R package includes a number of R script files and each may include one or more functions. Furthermore, each of these functions may call other functions written in different script files within the package as well. Thus, an R package with a few files and functions, may have a very complex nested structure. Furthermore, R packages may include script files written in other programming languages, such as C or C++ which further increases the complexity of the package. 58 | 59 | My argument is that open source programming languages such as R that do not require header files, should be carefully documented at both micro-level and macro-level to improve the readability of the package. The micro-level documentation is already advocated by literate programming packages. However, macro-level documentation -- inferring on the overall architecture of the package and function dependency -- is surprisingly ignored. To treat R packages truly as work of literature that should be read by humans and not just the compiler, as Knuth proposed, we should bear in mind that instead of instructing a ``computer what to do'', we shall ``concentrate rather on explaining to human beings what we want a computer to do'' \cite{knuth1984literate, knuth1992book}. 60 | 61 | Yet, there has been no software for macro-level documentation of R packages. In the current article, I introduce CodeMap, an application written for Macintosh operating system, that discovers the file and function dependency tree of an R package, and visualize them in an interactively. 62 | 63 | ***/ 64 | 65 | 66 | markdoc example.do, export(sthlp) markup() replace linesize(120) /// 67 | printer("/usr/texbin/pdflatex") 68 | 69 | /*** 70 | Example 71 | ================= 72 | 73 | explain what it does 74 | . example command 75 | 76 | second explanation 77 | . example command 78 | ***/ 79 | 80 | 81 | 82 | --------------------------------------------------------------------------------