From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31460 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Newsgroups: gmane.text.pandoc Subject: Re: How do I write a standalone document with pandoc.write? Date: Sun, 25 Sep 2022 19:49:04 +0200 Message-ID: References: <878rm7scie.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 (1.0) Content-Type: multipart/alternative; boundary=Apple-Mail-583DF699-9A1C-4DFE-B4FA-AFCE923C15D0 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14786"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDQLFNXWVILBBE5JYKMQMGQE3XS3GSQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Sep 25 19:49:12 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f60.google.com ([209.85.167.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ocVke-0003jI-3k for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 25 Sep 2022 19:49:12 +0200 Original-Received: by mail-lf1-f60.google.com with SMTP id u3-20020a056512094300b00497a14e7589sf1550033lft.12 for ; Sun, 25 Sep 2022 10:49:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664128151; cv=pass; d=google.com; s=arc-20160816; b=NxC1xxnyTgjZN+CJkarPTJO9xRs63urXS7QW8h2kr//EZGd0pklRinSH1KXQ65G/Nw w8TJt4/m5/kgypH/Gf7gDLlvpDqlxqzCOaRucyBujVwLUUYxfcyviPO7ThWpnSIJWIlP 0nj3cdc0//a66HRmH8rNed6YHz1YxAiCuHJHwMKyePPnzUrw/rHi0z5ND2kGcTxjRhpS BPG604GAutVnbg+64IqHNmfk74t03wF7KdhDlPCX4LOKqe6cWZ+u55Qw4ChJwNiADoJf EJANtKtXSYKXWggjTD+clopO70wd2bcFKb2yWPaBV9MwrnwG5ldm8jXGG5XAvPEZuXKF VGgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:in-reply-to:references :message-id:date:subject:mime-version:from:content-transfer-encoding :sender:dkim-signature:dkim-signature; bh=M73LLMBEq/nxWEQ4GSPlwRXuV0uiR2tCocTcVRpF8Qc=; b=RdTRDsr5bmt5aznYF388f7CwaO9ydrMd9oF4nwLa1KoJswjyi7jRg4TX2z5CN9vy6f i7ZhrdV+wNRq+pLfFCNM2r0g5uTXWfGU8tE/uh6grVi0SMILLWt3l8gd21XHsf3ZoV/Y uB7yDYVx+tMOA2IWptz07glj41kwFvLisqeCkQpGbE9ZNgLmOHToLDru1dUj8dz8p6GB yBsHb3f53MDaokGHndso7s/pQDI0Eh0B1tfAAKwif6MqCE6PQO+0fynRputQrVfTxoCm fvkkCeeEnAEVQY66Jv+lFgN+bzG8sFc9KtXz67mPLAa+8xn+MmSACZiHHyohmXyUHC2o FT8g== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X+wjAN2y; spf=pass (google.com: domain of ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) smtp.mailfrom=ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:in-reply-to :references:message-id:date:subject:mime-version:from :content-transfer-encoding:sender:from:to:cc:subject:date; bh=M73LLMBEq/nxWEQ4GSPlwRXuV0uiR2tCocTcVRpF8Qc=; b=mzzZyETdwzGSSKPCW11tpy1mbpZrTVlybaABKfwLFkO61jGXCY+YEIO7xHSH9WStNU D88Cj6XzjxKbnPMCUG9T+Uy1C7igRpl28DjL1+jcjG27v4t9AP7JItnEeKwhqYHDSYil xZr6nO2JLOYhKgs3XQDT44v05Hju+oqa8Dewb+Bb1C1/EvcauJZGWZP0Dh2BnfkzGj5o 69QRWyR/rQsdpPtayw9vI9sDV7pwdXiHpdcqS6j6X3gzbH4Illflh8hhSk8qEVO7WoRE MFVdXhXkzQdH4j5x75GzVw0gjkNCHQIcUfB3tqDR9zFT0x3DKoJ4Ltnja3aEW/+qD15b HFdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:in-reply-to :references:message-id:date:subject:mime-version:from :content-transfer-encoding:from:to:cc:subject:date; bh=M73LLMBEq/nxWEQ4GSPlwRXuV0uiR2tCocTcVRpF8Qc=; b=jyYBLjgk+Ai5Uy7HvyLHRpzQFsmzr0DFIw++D743upUBNQK1tGVfgntDzGYBuHiUE6 kKQS7dpGCq8W8F4lQxDeKN5wmBogtOrn7nmBqkJZ6zgYtJ9bRoz0uCnHHNhrTzdVPxp+ I2wFyRSktuS83FsJ7lcsCuZE4HFPIDo6nwsNhgmVTksA9Ov0cga1rYRq8mVU3A6svkOX 65qMi7Qse0DwKt1Kp+6eOn6Pt2YXlrNDr6hHJA/7Whn5sV0fUl64Dv2eYvGX76fvtK3v oD4oJaiVtudnunwf33ET6fjcfxw4Jboh+u9RUn2J/gfkMKyAQTY7/Ec2of4w8aIx3zPn Kuvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:in-reply-to :references:message-id:date:subject:mime-version:from :content-transfer-encoding:x-gm-message-state:sender:from:to:cc :subject:date; bh=M73LLMBEq/nxWEQ4GSPlwRXuV0uiR2tCocTcVRpF8Qc=; b=nIDlyNdrOxsKNaYTcHdsqarWqBqvvAAnAcZwBYAXwzPRB5aCxuX8pH8iIoFGEQJ2F1 69URpEUZu/FWoVzBMcn2YQyQdhXGsDiVgCjRE8F8JxyGadTI76V/h8HIkAGGj7v0bwST e08BOnSH98/YVNaFHNcuP0w5/scRrR/TNlzDactJW4Fv0Nw3aldpiLJO0AtW31zdGcBB OZXZbtDUjmjkgVPQ3LdzciRM87RxoMY9jp4zLUDrul4oMBQHagl2FIX0l6q5OQ6rdzbF 2/V1u+B6PEVRP6PiSHxHyQsAFRhRJIJEl/rUN316 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ACrzQf2MvuFOsyuov5ksbJLkHMfddlmsvW87ohTGGbLqux1z5OyQa0Tw p4MrJoassRGZs1+zH7iGDZs= X-Google-Smtp-Source: AMsMyM72PJk9xCXPGIHORA47hRTPlQnrfmHoT6XSek0AFEfQfHUY8RvQOMe9opqg1FmwonT6hrZSTw== X-Received: by 2002:a2e:b693:0:b0:26c:3ddc:4175 with SMTP id l19-20020a2eb693000000b0026c3ddc4175mr6651761ljo.486.1664128151449; Sun, 25 Sep 2022 10:49:11 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a2e:bc27:0:b0:26b:fc94:e182 with SMTP id b39-20020a2ebc27000000b0026bfc94e182ls3247773ljf.1.-pod-prod-gmail; Sun, 25 Sep 2022 10:49:06 -0700 (PDT) X-Received: by 2002:a2e:9f51:0:b0:26c:3db9:3660 with SMTP id v17-20020a2e9f51000000b0026c3db93660mr6327344ljk.528.1664128146101; Sun, 25 Sep 2022 10:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664128146; cv=none; d=google.com; s=arc-20160816; b=GABQqD7gusCqFC7irlOYHwenue0N7E4CdTKSvCfs0fdv0IFhcqJ/9GwSrzGn+kmC76 S/ITLpGwmgndVuuDxyQL78GrVZmA1pLSCPt7ZiPnu6tf9qG2fi0WfjSkQg23UoXgSOMj hxVs81q0HACxBsTJiDwDN1K7tdG7S9sHNXVaNsA53ny5LOTDxs3GvuvXq7opp0wLi9+9 Pd8Bfvzca57jnNq2WkXdEF83I3qmTZNkPdDwYDIq7xsFaOQ8PuXyo1Mvb6cERiU3O8eW 0ceWsOJh0GE9/Ks2OL9xgRQQqrJ1d1yGICgz3VSuVZYVKdnx2lF5uMpYUo+EGejR6II5 ugMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:in-reply-to:references:message-id:date:subject:mime-version:from :content-transfer-encoding:dkim-signature; bh=hnFe932dhJhREGJ2QGgYBT/x4XaXNU7J+E9i4SCj2mM=; b=zSFp745pGPcReb+DkHXee03rF09B+NG2RSEh+K6bEdtZVRdBkR1W9qOJaZ76H/ZN/0 CNRkxn/mYfnoQ4NsSUSYLTEvnuMJh2TiFysQ//eI+Eu6zXIYzdV7tFQaXO/8/68e5U/n bFtVIaZMmFfFN2TS4NplKSsQ+1DukRJSmzuAPxOb8b/TH0kZtDm0kuO0Ob5KH0NMKtbn 9vrsRTZ4wl95fBvf0jaBmMS2FKlnEKCiToyRNzJnDBProl/2VW4QdRfjvNOAx+hjOaPQ AkRz7ND8slR9D1sL4xbcYpcEkxul4UcjmOMlO4wH5DnAsrf9tmp0SKB/9K0Lkb4NSpr1 HJgw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X+wjAN2y; spf=pass (google.com: domain of ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) smtp.mailfrom=ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com. [2a00:1450:4864:20::62a]) by gmr-mx.google.com with ESMTPS id h4-20020a05651c124400b0026c2cb5925esi405802ljh.5.2022.09.25.10.49.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Sep 2022 10:49:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) client-ip=2a00:1450:4864:20::62a; Original-Received: by mail-ej1-x62a.google.com with SMTP id y3so9903970ejc.1 for ; Sun, 25 Sep 2022 10:49:06 -0700 (PDT) X-Received: by 2002:a17:907:760d:b0:77b:1d8d:7700 with SMTP id jx13-20020a170907760d00b0077b1d8d7700mr15123389ejc.195.1664128145552; Sun, 25 Sep 2022 10:49:05 -0700 (PDT) Original-Received: from smtpclient.apple (host-87-10-63-233.retail.telecomitalia.it. [87.10.63.233]) by smtp.gmail.com with ESMTPSA id ci2-20020a170906c34200b0073d796a1043sm7019130ejb.123.2022.09.25.10.49.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Sep 2022 10:49:05 -0700 (PDT) In-Reply-To: <878rm7scie.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Mailer: iPad Mail (19G82) X-Original-Sender: ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X+wjAN2y; spf=pass (google.com: domain of ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) smtp.mailfrom=ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:31460 Archived-At: --Apple-Mail-583DF699-9A1C-4DFE-B4FA-AFCE923C15D0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > On Sep 25, 2022, at 5:24 PM, Albert Krewinkel wrote: >=20 > =EF=BB=BF > jcr writes: >=20 >> How do I tell `pandoc.write` to produce a standalone Markdown >> document (with YAML metadata)? There's no `standalone` option for >> `pandoc.WriterOptions`. I thought setting a template might work,=20 >> but it doesn't: the saved file does not contain a YAML block, even >> though the document has metadata. My attempt is below: >>=20 >> ``` >> function write_markdown_file(doc, filename) >> local options =3D pandoc.WriterOptions{ >> template =3D pandoc.template.default('markdown') >> } >> local data =3D pandoc.write(doc, 'markdown', options) >> local file , error =3D io.open(filename, 'w') >> if file =3D=3D fail then >> io.stderr:write(string.format('Failed to write Markdown file: %s\ >> n', error)) >> os.exit(1) >> end >> file:write(data) >> end >> ``` >>=20 >> I'm using pandoc 2.19.2. >=20 > The template needs to be compile for it to become usable: >=20 >=20 > local options =3D pandoc.WriterOptions{ > template =3D pandoc.template.compile( > pandoc.template.default('markdown') > ) > } >=20 > Pandoc's current behavior is a bit strange though. You can raise a bug > for that if you'd like. >=20 > --=20 > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 Thank you for pointing out the problem with my code. I filed this bug, sinc= e I think an error should have been thrown for the invalid `template` value= : https://github.com/jgm/pandoc/issues/8321=20 --=20 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 e= mail 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/C9A01954-B2BF-404C-860E-FA2716E2F24C%40gmail.com. --Apple-Mail-583DF699-9A1C-4DFE-B4FA-AFCE923C15D0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sep 25, 2022, = at 5:24 PM, Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> wrote:
<= br>
=EF=BB=BF<= span>
jcr <ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

How do I tell `pandoc.write`= to produce a standalone Markdown
document (with YAML metadata)? There's no `standalone` opti= on for
`pandoc.Write= rOptions`. I thought setting a template  might  work,
=
but it doesn't: the saved file= does not contain a YAML block, even
though the document has metadata. My attempt is below:

```
function write_markdown_file(doc, filename)
 local options =3D pandoc.Wr= iterOptions{
 =   template =3D pandoc.template.default('markdown')
 }
 local data =3D pandoc.write(doc, 'mark= down', options)
&nb= sp;local file <close>, error =3D io.open(filename, 'w')
 if file =3D=3D fail then
   io= .stderr:write(string.format('Failed to write Markdown file: %s\
<= /blockquote>
n', error))
   os.exit(1)
 end
 file:write(data)
end
```

I'm using = pandoc 2.19.2.

The template n= eeds to be compile for it to become usable:


   local options =3D pandoc.WriterOption= s{
     template =3D pandoc.templ= ate.compile(
       pan= doc.template.default('markdown')
    &= nbsp;)
   }

Pandoc's current behavior is a bit strange though. You can raise a bug
for that if you'd like.

-- <= /span>
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 8= 1fe  e836 388d c0b2 1f63 1124

Th= ank you for pointing out the problem with my code. I filed this bug, since = I think an error should have been thrown for the invalid `template` value:&= nbsp;https://github.c= om/jgm/pandoc/issues/8321 

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/p= andoc-discuss/C9A01954-B2BF-404C-860E-FA2716E2F24C%40gmail.com.
--Apple-Mail-583DF699-9A1C-4DFE-B4FA-AFCE923C15D0--