From: bapt a <auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: markdown to markdown, stripping Yaml comments and keeping 3-backticks code blocks intact
Date: Sat, 26 Aug 2023 12:57:10 -0700 (PDT) [thread overview]
Message-ID: <9abf1645-7bd2-427c-846e-1b2e7a438760n@googlegroups.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 2160 bytes --]
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/9abf1645-7bd2-427c-846e-1b2e7a438760n%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 3006 bytes --]
next reply other threads:[~2023-08-26 19:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-26 19:57 bapt a [this message]
[not found] ` <9abf1645-7bd2-427c-846e-1b2e7a438760n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-08-29 13:40 ` Jonathan Whiteley
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=9abf1645-7bd2-427c-846e-1b2e7a438760n@googlegroups.com \
--to=auguieba-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).