Hemken / Statamarkdown

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

eval=FALSE does not work in combination with cleanlog=FALSE #33

Closed jules-bec closed 1 year ago

jules-bec commented 1 year ago

Dear Mr. Hemken,

I have a problem with displaying code. I want to display certain Stata commands without showing the respective result. It is possible to use the chunk options "eval=FALSE" or "results="hide"" to do so, however these chunk options don't seem to be compatible with the chunk option "cleanlog=FALSE", as it does not show anything when used together, not the result and not the command. As I would like to display Stata code in the typical black and white format, this is somewhat bothersome. Is there a way to suppress the output and merely show the Stata commands while still using "cleanlog=FALSE" ? I have attached a pdf to exemplify my problem and would be very thankful for your help!

Kind regards, Julien

Stata-Block-Test.pdf

Hemken commented 1 year ago

You might try using the “verbatim “ engine, rather than the Stata engine.

With the eval=FALSE option, Stata does not run and no log is produced. With results=‘hide’, Stata runs but no output is shown. With cleanlog=FALSE, Stata’s command echo in the log is left intact, as would be normal when working in Stata. The echo=FALSE is an independent option that suppresses the independent code block shown in a document.


From: jules-bec @.> Sent: Sunday, January 22, 2023 3:20:04 PM To: Hemken/Statamarkdown @.> Cc: Subscribed @.***> Subject: [Hemken/Statamarkdown] eval=FALSE does not work in combination with cleanlog=FALSE (Issue #33)

Dear Mr. Hemken,

I have a problem with displaying code. I want to display certain Stata commands without showing the respective result. It is possible to use the chunk options "eval=FALSE" or "results="hide"" to do so, however these chunk options don't seem to be compatible with the chunk option "cleanlog=FALSE", as it does not show anything when used together, not the result and not the command. As I would like to display Stata code in the typical black and white format, this is somewhat bothersome. Is there a way to suppress the output and merely show the Stata commands while still using "cleanlog=FALSE" ? I have attached a pdf to exemplify my problem and would be very thankful for your help!

Kind regards, Julien

Stata-Block-Test.pdfhttps://github.com/Hemken/Statamarkdown/files/10475523/Stata-Block-Test.pdf

— Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/issues/33, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYBMEYX7AHWNMZYN4FDT3DWTWQAJANCNFSM6AAAAAAUDGHG5Y. You are receiving this because you are subscribed to this thread.Message ID: @.***>

remlapmot commented 1 year ago

It's also worth pointing out that you can simply use a code chunk without fences, i.e., a code chunk such as

```stata
display "Here's some Stata code that won't be executed"

You only need the verbatim approach if you want to show the backticks and fences, i.e.,
```{stata}
display "Some more Stata code that won't be executed"
remlapmot commented 1 year ago

And in a Quarto document as an equivalent to the verbatim syntax you can use the double {{}} approach

```{{stata}}
display "Some Stata code that won't be executed"
Hemken commented 1 year ago

Thanks for pointing that out.

And glad to see someone is experimenting with how everything interacts with Quarto!

-- Doug Hemken Statistical consultant 4226I Social Science Bldg.

@.*** 608-262-4327

To make a consulting appointment send me an email, or use the on-line scheduler: https://doodle.com/mm/doughemken/book-a-time

From: Tom Palmer @.> Sent: Tuesday, January 24, 2023 1:31 AM To: Hemken/Statamarkdown @.> Cc: Doug Hemken @.>; Comment @.> Subject: Re: [Hemken/Statamarkdown] eval=FALSE does not work in combination with cleanlog=FALSE (Issue #33)

And in a Quarto document as an equivalent to the verbatim syntax you can use the double {{}} approach


display "Some Stata code that won't be executed"

— Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/issues/33#issuecomment-1401494905, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYBME5QG4OR37MIBLBPUKTWT6AMPANCNFSM6AAAAAAUDGHG5Y. You are receiving this because you commented.Message ID: @.**@.>>

remlapmot commented 1 year ago

Absolutely, I find that Statamarkdown works similarly great with Quarto's knitr engine.

remlapmot commented 1 year ago

But just to clarify to you that for all 3 of those syntaxes I gave Statamarkdown is not actually required - because they are just verbatim syntaxes generating markdown (well the first is already plain markdown).

In those syntaxes you could actually write almost anything you wanted instead of stata. In those syntaxes when we write stata the generated markdown gets Stata syntax highlighting at least on GitHub because Stata is a language included in Linguist. The entry for Stata is here.

Just to show this here are example Rmd and qmd files.

Example Rmd file

---
output: html_document
---

```stata
display "Here's some Stata code that won't be executed"
```{stata}
display "Some more Stata code that won't be executed"

Example qmd file

---
format:
  html:
    embed-resources: true
engine: knitr
---

```stata
display "Here's some Stata code that won't be executed"
```{stata}
display "Some more Stata code that won't be executed"

```{{stata}}
display "Some Stata code that won't be executed"