Skip to content

Commit

Permalink
Add dialogs, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Hemken authored and Douglas Hemken committed Jul 24, 2018
1 parent b31e54a commit c0b5a31
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 7 deletions.
27 changes: 27 additions & 0 deletions Examples/example0-bm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1><a href="#an-example-file" id="an-example-file">An Example File</a></h1>
<p>Some preliminary text.</p>
<p>A code block, evaluted:</p>
<pre><code class="language-stata">. sysuse auto
(1978 Automobile Data)

. summarize weight

Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
weight | 74 3019.459 777.1936 1760 4840

</code></pre>
<p>In-line text: the mean weight is 3019.5 pounds.</p>
<p>A list:</p>
<ul>
<li>N = 74</li>
<li>mean = 3019.5</li>
<li>sd = 777.19</li>
</ul>
<p>A graph:</p>
<pre><code class="language-stata">. histogram weight
(bin=8, start=1760, width=385)

</code></pre>
<img src="Graph.svg" >
<p>More text.</p>
6 changes: 3 additions & 3 deletions Examples/example0.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1><a href="#an-example-file" id="an-example-file">An Example File</a></h1>
<p>Some preliminary text.</p>
<p>A code block, evaluted:</p>
<pre><code class="language-s">. sysuse auto
<pre><code class="language-stata">. sysuse auto
(1978 Automobile Data)

. summarize weight
Expand All @@ -19,9 +19,9 @@ <h1><a href="#an-example-file" id="an-example-file">An Example File</a></h1>
<li>sd = 777.19</li>
</ul>
<p>A graph:</p>
<pre><code class="language-s">. histogram weight
<pre><code class="language-stata">. histogram weight
(bin=8, start=1760, width=385)

</code></pre>
<img src="Graph5.svg" >
<img src="Graph11.svg" >
<p>More text.</p>
6 changes: 3 additions & 3 deletions Examples/example0.stmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ An Example File
Some preliminary text.

A code block, evaluted:
```s
```stata
sysuse auto
summarize weight
```

In-line text: the mean weight is `s %9.1f r(mean)` pounds.
In-line text: the mean weight is `stata %9.1f r(mean)` pounds.

A list:

Expand All @@ -18,7 +18,7 @@ A list:
- sd = `s % 9.2f r(sd)`

A graph:
```s
```stata
histogram weight
```

Expand Down
6 changes: 6 additions & 0 deletions Tests/stmd tests.do
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ do "update stmd install.do "

cd z:/public_web/stataworkshops/stmd/Examples/

capture erase graph.svg
cscript
//Basic, with code, inline, graphs
stmd example0.stmd, replace
file_equal example0.html using example0-bm.html, display

capture erase graph1.svg
capture erase graph2.svg
cscript
Expand Down
64 changes: 64 additions & 0 deletions dyndoc.dlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
*! dyndoc dialog version 1.0.0, 24 July 2018, Doug Hemken, [email protected]
*! for dyndoc version 1.0.0, 17 May 2017, Hua Peng, StataCorp

Stata Markdown
--------------

dyndoc filename [ , saving(filename2) replace hardwrap noremove nomsg nostop ]

Note: does not allow option arguments, does not allow pegdown option

To install in User Statistics menu via Stata commands:

. window menu append submenu "stUser" "Documents"
. window menu append item "Documents" "DYN to HTML (dyndoc)" "db dyndoc"

. window menu refresh

To permanently install, place these commands in your -profile.do- file.
*/

VERSION 15

POSITION . . 410 250

DIALOG main, label("dyndoc - Translate Dyndoc format to HTML") tabtitle("Main")
BEGIN
TEXT tx_source 10 10 . ., label("Source document:")
FILE file_source 10 +20 390 ., error("Source document") ///
label("Browse")
TEXT tx_target 10 +25 . ., label("Target document:")
FILE file_target 10 +20 390 ., error("Target document") ///
label("Browse")
CHECKBOX cb_replace 15 +25 . ., label("replace target document")
CHECKBOX cb_hardwrap 15 +25 . ., label("hardwrap - line breaks preserved")
CHECKBOX cb_nostop 15 +25 . ., label("nostop - ignore errors")
END

OK ok1, label("OK")
CANCEL can1, label("Cancel")
SUBMIT sub1, label("Submit")
HELP hlp1, view("help dyndoc")
RESET res1
COPY copy1

PROGRAM command
BEGIN
put "dyndoc "
require main.file_source
put `"""' main.file_source `"""' " "
put ", "
if main.file_target.isneq("") {
put "saving(" `"""' main.file_target `"""' ") "
}
if main.cb_replace {
put "replace"
}
if main.cb_hardwrap {
put "hardwarp"
}
if main.cb_nostop {
put "nostop"
}
END
9 changes: 9 additions & 0 deletions stmd menu setup.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
window menu clear
window menu append submenu "stUser" "Documents"
window menu append item "Documents" "Stata Markdown to HTML (&stmd)" "db stmd"
window menu append item "Documents" "Stata Markdown to DYN (stmd2dyn)" "db stmd2dyn"
window menu append separator "Documents"
window menu append item "Documents" "DYN to HTML (dyndoc)" "db dyndoc"
window menu append item "Documents" "DYN to MD (dyntext)" "db dyntext"
window menu append item "Documents" "MD to HTML (markdown)" "db markdown"
window menu refresh
23 changes: 22 additions & 1 deletion stmd.dlg
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
*! stmd dialog version 1.0.0, 24 July 2018, Doug Hemken, [email protected]
*! for stmd version 1.3, 18 June 2018

Stata Markdown
--------------

stmd filename [ , saving(filename2) replace hardwrap noremove nomsg nostop ]

To install in User Statistics menu via Stata commands:

. window menu append submenu "stUser" "Documents"
. window menu append item "Documents" "Stata Markdown to HTML (&stmd)" "db stmd"

. window menu refresh

To permanently install, place these commands in your -profile.do- file.
*/

VERSION 15

POSITION . . 410 250
Expand Down Expand Up @@ -28,7 +47,9 @@ BEGIN
require main.file_source
put `"""' main.file_source `"""' " "
put ", "
put "saving(" `"""' main.file_target `"""' ") "
if main.file_target.isneq("") {
put "saving(" `"""' main.file_target `"""' ") "
}
if main.cb_replace {
put "replace"
}
Expand Down
62 changes: 62 additions & 0 deletions stmd2dyn.dlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
*! stmd2dyn dialog version 1.0.0, 24 July 2018, Doug Hemken, [email protected]
*! for stmd2dyn version 1.5.9, 3 July 2018

Stata Markdown
--------------

stmd2dyn filename [ , saving(filename2) replace hardwrap noremove nomsg nostop ]

To install in User Statistics menu via Stata commands:

. window menu append submenu "stUser" "Documents"
. window menu append item "Documents" "Stata Markdown to DYN (&stmd2dyn)" "db stmd2dyn"

. window menu refresh

To permanently install, place these commands in your -profile.do- file.
*/

VERSION 15

POSITION . . 410 250

DIALOG main, label("stmd2dyn - Translate Stata Markdown to DYN") tabtitle("Main")
BEGIN
TEXT tx_source 10 10 . ., label("Source document:")
FILE file_source 10 +20 390 ., error("Source document") ///
label("Browse")
TEXT tx_target 10 +25 . ., label("Target document:")
FILE file_target 10 +20 390 ., error("Target document") ///
label("Browse")
CHECKBOX cb_replace 15 +25 . ., label("replace target document")
CHECKBOX cb_hardwrap 15 +25 . ., label("hardwrap - line breaks preserved")
CHECKBOX cb_nostop 15 +25 . ., label("nostop - ignore errors")
END

OK ok1, label("OK")
CANCEL can1, label("Cancel")
SUBMIT sub1, label("Submit")
HELP hlp1, view("help stmd2dyn")
RESET res1
COPY copy1

PROGRAM command
BEGIN
put "stmd2dyn "
require main.file_source
put `"""' main.file_source `"""' " "
put ", "
if main.file_target.isneq("") {
put "saving(" `"""' main.file_target `"""' ") "
}
if main.cb_replace {
put "replace"
}
if main.cb_hardwrap {
put "hardwarp"
}
if main.cb_nostop {
put "nostop"
}
END

0 comments on commit c0b5a31

Please sign in to comment.