Hemken / Statamarkdown

Functions to write Stata documentation with knitr
Other
59 stars 11 forks source link

Statamarkdown returns no result #40

Open xiangao opened 3 weeks ago

xiangao commented 3 weeks ago

library(Statamarkdown) Stata found at /usr/local/bin/stata-mp The 'stata' engine is ready to use. example("stata_engine", package="Statamarkdown")

stt_ng> indoc <- ' stt_ng+ # An R console example stt_ng+ ## In a first code chunk, set up with stt_ng+ {r} stt_ng+ library(Statamarkdown) stt_ng+ stt_ng+ stt_ng+ ## Then mark Stata code chunks with stt_ng+ {stata} stt_ng+ sysuse auto, clear stt_ng+ generate gpm = 1/mpg stt_ng+ summarize price gpm stt_ng+ stt_ng+ '

stt_ng> if (!is.null(Statamarkdown::find_stata())) { stt_ng+ # To run this example, remove tempdir(). stt_ng+ fmd <- file.path(tempdir(), "test.md") stt_ng+ fhtml <- file.path(tempdir(), "test.html") stt_ng+ stt_ng+ knitr::knit(text=indoc, output=fmd) stt_ng+ rmarkdown::render(fmd, "html_document", fhtml) stt_ng+ } Stata found at /usr/local/bin/stata-mp

/usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/pandoc +RTS -K512m -RTS test.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmphanmks/test.html --lua-filter /home/xao/R/x86_64-pc-linux-gnu-library/4.4/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/xao/R/x86_64-pc-linux-gnu-library/4.4/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --template /home/xao/R/x86_64-pc-linux-gnu-library/4.4/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/Rtmphanmks/rmarkdown-str4f63445fc7de.html [WARNING] This document format requires a nonempty element. Defaulting to 'test' as the title. To specify a title, use 'title' in metadata or --metadata title="...".</p> <p>Output created: /tmp/Rtmphanmks/test.html Warning message: In min(grep("[[:alnum:]]", y)) : no non-missing arguments to min; returning Inf</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/remlapmot"><img src="https://avatars.githubusercontent.com/u/3777473?v=4" />remlapmot</a> commented <strong> 3 weeks ago</strong> </div> <div class="markdown-body"> <p>Please read the text in the example carefully.</p> <p>As indicated in the comment, to save the output files from that example, you need to remove the calls to <code>tempdir()</code>.</p> <p>Here is the code with the <code>tempdir()</code> calls removed.</p> <pre><code class="language-r">indoc <- ' # An R console example ## In a first code chunk, set up with ```{r} library(Statamarkdown)</code></pre> <h2>Then mark Stata code chunks with</h2> <pre><code class="language-{stata}">sysuse auto, clear generate gpm = 1/mpg summarize price gpm</code></pre> <p>'</p> <p>if (!is.null(Statamarkdown::find_stata())) { fmd <- file.path("test.md") fhtml <- file.path("test.html")</p> <p>knitr::knit(text=indoc, output=fmd) rmarkdown::render(fmd, "html_document", fhtml) }</p> <pre><code> When you run it, you will find both _test.md_ and _test.html_ created in your working directory. The _test.html_ file looks like this ![CleanShot 2024-10-30 at 20 18 02@2x](https://github.com/user-attachments/assets/f41b89af-f04e-4545-a7a3-a040cf1dd9e5) Hope this helps.</code></pre> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>