From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33142 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Martin Post Newsgroups: gmane.text.pandoc Subject: Re: Shell (zsh) for loop: apply correct suffix based on Pandoc output format? Date: Mon, 2 Oct 2023 08:06:48 -0700 (PDT) Message-ID: <5843b3a9-e780-4816-8a6d-70277d1295d6n@googlegroups.com> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_23191_206401430.1696259208148" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20243"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCHYFZ6CWYNBBCNZ5OUAMGQEVFGZHJI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Oct 02 17:06:53 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f55.google.com ([209.85.160.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qnKVZ-0004uw-E2 for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 02 Oct 2023 17:06:53 +0200 Original-Received: by mail-oa1-f55.google.com with SMTP id 586e51a60fabf-1dd5dee0774sf3894923fac.1 for ; Mon, 02 Oct 2023 08:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1696259212; x=1696864012; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=g2oVLKSNsDtIMWe3slCx6ESKVFJLzNMmNTvm6AhUGUk=; b=YrnI7hXghrx5SF6XFn0vI4OOW6kzOxdkgOPMXfdcOAQyBrzmHPFm79dgOcMEp0skhr HKntSgHdGFODn2uocQex2XplVdqAL9BVDbodSaP03BA6CPC2pDt7fEMBP0fHnm2RFZO9 YoIDlDEhuSc0zn/jyJyDUMKReJ5MzHgvYlF++LX5XI21sZb6Uf2huBc6ZK1CxlXzt026 Qxh9cQ3wJRnAxyChg6uIxaQTc0OKWBSkXPUl/oHv5yfiRvXUIAwyUWQTd/Yt8rbTv+cn kpRQN0rNkOYi4mrbYdP4pTRZd8o1gVhMpr/OlAHahM0Fl+G1y4ZJYoiOE4sODYYzTwE8 B+9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696259212; x=1696864012; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=g2oVLKSNsDtIMWe3slCx6ESKVFJLzNMmNTvm6AhUGUk=; b=NcgcXgyp3Tno+uwFDOnwoXZbJ1HwFKV8Yxg2XZGY3+rQwcFiDj68EmO8WoPN2KB6Vu oMWT1eoyNUkMntJruyFzWz/lCX3P3s496mJEAtUDWakwSlikGmH30CiOtUEyTyfd8FAy GwMLM4OOKJhXM7iqgZvHHxI6mkVF/tOvg6O/tpH8bZ88ujVR5J0MUGdnD1ikwP7G/gRr c8FS4Z/Knw7m1DS7vSSnDGggoO4hbzRy54MzqON8ilyqNAEGRcyLBeOnPNaUgVrXVdUK bxEE6y5p8V5galAKGhRGjyunMXO1ZJYmSS+Si53ecbKSvykhTA+wpvDerTZ4aPWzlLMW m9lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696259212; x=1696864012; 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-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=g2oVLKSNsDtIMWe3slCx6ESKVFJLzNMmNTvm6AhUGUk=; b=fu1LXHgq6qakMpdhrB0GGGWBmJUju8j3CE/yVOLpjDwrFlq72xkphEbySOUnZNN7mT Yd+fhMaztojbXRFI76QOIwiN8QBojjXM7QochluFDDh/OLBmyua+WgPg8vcOux/vko54 dn/idky/VIndEhJLXMRumiv2V4CkT3wNPpkxR2nycOM4khFMh5lu7o+7utDDRcDIoY8Q 9XLqzXu6nVgSCxxyUzAyv/DDvhimtgzQkPHCsVXqJJt7gmsPqBr3JrC1ZIA9CwsQ+e64 OnGF92ZcO/1zOAlkMDS9LKzrpoL0jL8OU11Ag4XFFKPVPh0Jkx Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YxUMKh+z9EVADDIht5Uc/Emn+3E9vrFOF9v3BVJCUsaxm5aYSUn mqCaTyc1n58mffK7VESFVRf9+Q== X-Google-Smtp-Source: AGHT+IFSQl3IGUtR4uuAWB8SSaCEzKP1eKH3qkBWfchv/B5wEJHZSgr34xbhdTlBwuiuuwSMJVTaAQ== X-Received: by 2002:a05:6870:b612:b0:1dd:bd0:aa45 with SMTP id cm18-20020a056870b61200b001dd0bd0aa45mr6632165oab.18.1696259212264; Mon, 02 Oct 2023 08:06:52 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:f714:b0:1c4:bc4f:d01 with SMTP id ej20-20020a056870f71400b001c4bc4f0d01ls551955oab.1.-pod-prod-03-us; Mon, 02 Oct 2023 08:06:49 -0700 (PDT) X-Received: by 2002:a05:6870:1e8e:b0:1e1:3152:93fc with SMTP id pb14-20020a0568701e8e00b001e1315293fcmr3313587oab.6.1696259208915; Mon, 02 Oct 2023 08:06:48 -0700 (PDT) In-Reply-To: X-Original-Sender: MartinPostBerlin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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:33142 Archived-At: ------=_Part_23191_206401430.1696259208148 Content-Type: multipart/alternative; boundary="----=_Part_23192_184618020.1696259208148" ------=_Part_23192_184618020.1696259208148 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you, Bastien. This is a good idea, but the Pandoc output format is=20 not necessarily the proper generic file suffix. E.g., for to: markdown or= =20 markdown_strict, one would want/expect =E2=80=9C.md=E2=80=9D, html5 =3D .ht= ml etc. For=20 chunkedhtml, it would actually (have to) be empty, so Pandoc will create a= =20 folder with HTML files.=20 Hmm. Bastien DUMONT schrieb am Montag, 2. Oktober 2023 um 16:17:28 UTC+2: > I would search for the output suffix in the YAML file itself: > > export SUFFIX=3D"$(grep -x 'to: .*' defaults.yml | cut -d ' ' -f 2)"; > for f in *.md; > do pandoc \ > --defaults=3Ddefaults.yml \ > "$f" \ > --output=3D"${f%.md}.$SUFFIX"; > done > > Instead of "to", you can use a dedicated variable in the YAML file if you= =20 > export to output formats whose name differ from their file suffix (e.g.= =20 > latex/tex or commonmark/md). > > Le Monday 02 October 2023 =C3=A0 06:58:57AM, Martin Post a =C3=A9crit : > > I used to do this (in macOS / zsh), as seen in the Pandoc FAQ: > >=20 > > for f in *.md; > > do pandoc \ > > --defaults=3Ddefaults.yml \ > > "$f" \ > > --output=3D"${f%.md}.htm"; > > done > >=20 > > But I am now changing output formats in defaults.yml (or additional=20 > default > > files), e.g. =E2=80=9Cto: docx=E2=80=9D, and the target files obviously= shouldn=E2=80=99t have=20 > =E2=80=9C.htm=E2=80=9D > > then. > >=20 > > How can I modify the for loop so the correct suffix is applied for the= =20 > output > > format set in a defaults file? > >=20 > > (I realize I could manually add a =E2=80=9Coutput-format-suffix=E2=80= =9D shell variable=20 > and use > > that in the loop, but I hope there=E2=80=99s something more elegant tha= n that.) > >=20 > > Thank you. > >=20 > > -- > > You received this message because you are subscribed to the Google Grou= ps > > "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email > > to [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit [2] > https://groups.google.com/d/msgid/ > > pandoc-discuss/e8d686ec-e667-4dff-97c3-133af2a6f731n%40googlegroups.com= . > >=20 > > References: > >=20 > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2]=20 > https://groups.google.com/d/msgid/pandoc-discuss/e8d686ec-e667-4dff-97c3-= 133af2a6f731n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter > > --=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/5843b3a9-e780-4816-8a6d-70277d1295d6n%40googlegroups.com. ------=_Part_23192_184618020.1696259208148 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you, Bastien. This is a good idea, but the Pandoc output format is no= t necessarily the proper generic file suffix. E.g., for to: markdown or mar= kdown_strict, one would want/expect =E2=80=9C.md=E2=80=9D, html5 =3D .html = etc. For chunkedhtml, it would actually (have to) be empty, so Pandoc will = create a folder with HTML files.=C2=A0

Hmm.

Ba= stien DUMONT schrieb am Montag, 2. Oktober 2023 um 16:17:28 UTC+2:
I would search for th= e output suffix in the YAML file itself:

export SUFFIX=3D"$(grep -x 'to: .*' defaults.yml | cut -d = ' ' -f 2)";
for f in *.md;
do pandoc \
--defaults=3Ddefaults.yml \
"$f" \
--output=3D"${f%.md}.$SUFFIX";
done

Instead of "to", you can use a dedicated variable in the YAML= file if you export to output formats whose name differ from their file suf= fix (e.g. latex/tex or commonmark/md).

Le Monday 02 October 2023 =C3=A0 06:58:57AM, Martin Post a =C3=A9crit :
> I used to do this (in macOS / zsh), as seen in the Pandoc FAQ:
>=20
> for f in *.md;
> do pandoc \
> --defaults=3Ddefaults.yml \
> "$f" \
> --output=3D"${f%.md}.htm";
> done
>=20
> But I am now changing output formats in defaults.yml (or additiona= l default
> files), e.g. =E2=80=9Cto: docx=E2=80=9D, and the target files obvi= ously shouldn=E2=80=99t have =E2=80=9C.htm=E2=80=9D
> then.
>=20
> How can I modify the for loop so the correct suffix is applied for= the output
> format set in a defaults file?
>=20
> (I realize I could manually add a =E2=80=9Coutput-format-suffix=E2= =80=9D shell variable and use
> that in the loop, but I hope there=E2=80=99s something more elegan= t than that.)
>=20
> Thank you.
>=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 email
> to [1]pandoc-discus...@= googlegroups.com.
> To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/e8d686ec-e667-4dff-97c3-133af2a6f731n%40googlegroups.com.
>=20
> References:
>=20
> [1] mailto:pandoc-discu= s...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups= .google.com/d/msgid/pandoc-discuss/e8d686ec-e667-4dff-97c3-133af2a6f731n%40= googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter

--
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/pandoc-discuss/5843b3a9-e780-4816-8a6d-70277d1295d6n%40googlegroups.= com.
------=_Part_23192_184618020.1696259208148-- ------=_Part_23191_206401430.1696259208148--