public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Jonathan Whiteley <jaw.biodude-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: markdown to markdown, stripping Yaml comments and keeping 3-backticks code blocks intact
Date: Tue, 29 Aug 2023 06:40:06 -0700 (PDT)	[thread overview]
Message-ID: <6e4c86d9-f030-4dcd-bf04-b9ff68b8981fn@googlegroups.com> (raw)
In-Reply-To: <9abf1645-7bd2-427c-846e-1b2e7a438760n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 3088 bytes --]

I would love a way to "comment out" blocks of Markdown.  The only way I've 
been able to do it in R Markdown is to wrap the contents in a R code chunk 
with `eval=FALSE, include=FALSE`, to stop knit() from evaluating it, and 
removing it from the intermediate md output.  Of course, such a block can 
not contain other nested R-code chunks, unless they are commented-out.

``````
---
title: Comment
---

## Section

This is a simple placeholder for the manuscript's main document [@knuth84].


```{r}
x <- 1 + 1
x
```

Note pi is `r pi`.

```{r comments, eval=FALSE, include=FALSE}
You can embed code like this:

# ```{r}
# 1 + 1
# ```
but beware, is `r .NotYetImplemented()` still executed?
```

More text.

``````

Best of luck,

Jonathan
On Saturday, 26 August 2023 at 15:57:10 UTC-4 bapt a wrote:

> Hi,
>
> I'm playing with an idea for quarto, where one could comment out portions 
> of the input document including text and code chunks. This workaround would 
> make use of the trick that 1) Yaml blocks can appear anywhere in a pandoc 
> document, and 2) commented out (#) lines in Yaml are stripped by pandoc (?).
>
> I'd like to run a pre-processing step* on the input document to return 
> essentially the same input, but getting rid off those commented out Yaml 
> lines.
>
> Consider the following input file,
>
> ``````
> ---
> title: Comment
> ---
>
> ## Section
>
> This is a simple placeholder for the manuscript's main document [@knuth84].
>
>
> ```{r}
> x <- 1 + 1
> x
> ```
>
> Note pi is `r pi`.
>
> ---
> #  You can embed code like this:
> # 
> # ```{r}
> # 1 + 1
> # ```
> # but beware, is `r .NotYetImplemented()` still executed?
> ---
>
> More text.
>
> ``````
> The commented out portion should be removed before quarto calls the 
> computational engine, otherwise the code still gets executed.
>
> I've tried various flavours of markdown, such as
>
> > quarto pandoc -t noop.lua  -f markdown  index.qmd
>
> where noop.lua is a dummy Writer doing nothing,
>
> ```
> function Writer (doc, opts)
>   local filter = {  }
>   return pandoc.write(doc:walk(filter), 'markdown', opts)
> end
> ````
>
> but I'm not finding the right combination of options, if there is one. 
> Some markdown flavours seem to keep the Yaml comments (not sure why), 
> others reformat the 3-backticks code block. Is this "identity" Writer going 
> to be difficult to achieve?
>
> Many thanks,
>
> baptiste
>
> * Note that code is currently detected via regex in quarto, so it gets 
> executed even inside comments (hence the need of a pre-processor to strip 
> it entirely from the document).
> See https://github.com/quarto-dev/quarto-cli/discussions/3330 for more 
> context
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6e4c86d9-f030-4dcd-bf04-b9ff68b8981fn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4544 bytes --]

      parent reply	other threads:[~2023-08-29 13:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26 19:57 bapt a
     [not found] ` <9abf1645-7bd2-427c-846e-1b2e7a438760n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-08-29 13:40   ` Jonathan Whiteley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e4c86d9-f030-4dcd-bf04-b9ff68b8981fn@googlegroups.com \
    --to=jaw.biodude-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).