* Use a pipe to generate only first word of a variable?
@ 2023-02-03 17:55 Paul Kelleher
[not found] ` <074330dd-ae01-4471-9550-ea09b2fe7363n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Paul Kelleher @ 2023-02-03 17:55 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1084 bytes --]
Hello,
Is it possible to use a pipe in a template to generate just the first word
of a variable?
My specific use case is to produce just the first name of a first-and-last
name that I place in the "to" field of a YAML block that passes info to a
letter template. I'd like to generate "Dear <first name>,". To do this now,
I've defined "to" as an array, with the first name as the first value of
the array and the last name as the second value; then I can use the
predefined 'first' pipe to return just the first name. But for reasons
specific to my particular use case, it'd be great to have a pipe that
returns the first word of a multi-word variable.
Thanks!
--
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/074330dd-ae01-4471-9550-ea09b2fe7363n%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 1446 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use a pipe to generate only first word of a variable?
[not found] ` <074330dd-ae01-4471-9550-ea09b2fe7363n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-02-03 18:57 ` Paul Kelleher
[not found] ` <CAD0VMekeTBm__Qt6bAqFMCQ8TVXF+s9Uf4_xsZHxmJ3b_CNVuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Paul Kelleher @ 2023-02-03 18:57 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]
Just realized that one approach is to have Pandoc pass the full name string
(e.g. 'First Last') to the template, but then to create a macro inside the
template that will return just the first word in the string, as described
here
<https://tex.stackexchange.com/questions/316730/extract-first-word-in-a-string>.
That worked for me!
On Fri, Feb 3, 2023 at 11:55 AM Paul Kelleher <paul-JZTKsBFbLNkkm2bSNb+QWw@public.gmane.org> wrote:
> Hello,
>
> Is it possible to use a pipe in a template to generate just the first word
> of a variable?
>
> My specific use case is to produce just the first name of a first-and-last
> name that I place in the "to" field of a YAML block that passes info to a
> letter template. I'd like to generate "Dear <first name>,". To do this now,
> I've defined "to" as an array, with the first name as the first value of
> the array and the last name as the second value; then I can use the
> predefined 'first' pipe to return just the first name. But for reasons
> specific to my particular use case, it'd be great to have a pipe that
> returns the first word of a multi-word variable.
>
> Thanks!
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pandoc-discuss/cEe1t7Fw4-o/unsubscribe.
> To unsubscribe from this group and all its topics, 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/074330dd-ae01-4471-9550-ea09b2fe7363n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/074330dd-ae01-4471-9550-ea09b2fe7363n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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/CAD0VMekeTBm__Qt6bAqFMCQ8TVXF%2Bs9Uf4_xsZHxmJ3b_CNVuw%40mail.gmail.com.
[-- Attachment #2: Type: text/html, Size: 3191 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Use a pipe to generate only first word of a variable?
[not found] ` <CAD0VMekeTBm__Qt6bAqFMCQ8TVXF+s9Uf4_xsZHxmJ3b_CNVuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-02-04 10:29 ` Bastien DUMONT
0 siblings, 0 replies; 3+ messages in thread
From: Bastien DUMONT @ 2023-02-04 10:29 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
You can also write:
---
author:
first: John
last: Doe
---
And use in your template use $author.first$
Le Friday 03 February 2023 à 12:57:16PM, Paul Kelleher a écrit :
> Just realized that one approach is to have Pandoc pass the full name string
> (e.g. 'First Last') to the template, but then to create a macro inside the
> template that will return just the first word in the string, as described [1]
> here. That worked for me!
>
> On Fri, Feb 3, 2023 at 11:55 AM Paul Kelleher <[2]paul-JZTKsBFbLNkkm2bSNb+QWw@public.gmane.org> wrote:
>
> Hello,
>
> Is it possible to use a pipe in a template to generate just the first word
> of a variable?
>
> My specific use case is to produce just the first name of a first-and-last
> name that I place in the "to" field of a YAML block that passes info to a
> letter template. I'd like to generate "Dear <first name>,". To do this now,
> I've defined "to" as an array, with the first name as the first value of
> the array and the last name as the second value; then I can use the
> predefined 'first' pipe to return just the first name. But for reasons
> specific to my particular use case, it'd be great to have a pipe that
> returns the first word of a multi-word variable.
>
> Thanks!
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit [3]https://groups.google.com/d/topic/
> pandoc-discuss/cEe1t7Fw4-o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to [4]
> pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [5]https://groups.google.com/d/
> msgid/pandoc-discuss/
> 074330dd-ae01-4471-9550-ea09b2fe7363n%40googlegroups.com.
>
> --
> 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 [6]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [7]https://groups.google.com/d/msgid/
> pandoc-discuss/
> CAD0VMekeTBm__Qt6bAqFMCQ8TVXF%2Bs9Uf4_xsZHxmJ3b_CNVuw%40mail.gmail.com.
>
> References:
>
> [1] https://tex.stackexchange.com/questions/316730/extract-first-word-in-a-string
> [2] mailto:paul-JZTKsBFbLNkkm2bSNb+QWw@public.gmane.org
> [3] https://groups.google.com/d/topic/pandoc-discuss/cEe1t7Fw4-o/unsubscribe
> [4] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [5] https://groups.google.com/d/msgid/pandoc-discuss/074330dd-ae01-4471-9550-ea09b2fe7363n%40googlegroups.com?utm_medium=email&utm_source=footer
> [6] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [7] https://groups.google.com/d/msgid/pandoc-discuss/CAD0VMekeTBm__Qt6bAqFMCQ8TVXF%2Bs9Uf4_xsZHxmJ3b_CNVuw%40mail.gmail.com?utm_medium=email&utm_source=footer
--
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/Y94zkCXSuBYj2ePA%40localhost.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-04 10:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 17:55 Use a pipe to generate only first word of a variable? Paul Kelleher
[not found] ` <074330dd-ae01-4471-9550-ea09b2fe7363n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-02-03 18:57 ` Paul Kelleher
[not found] ` <CAD0VMekeTBm__Qt6bAqFMCQ8TVXF+s9Uf4_xsZHxmJ3b_CNVuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-02-04 10:29 ` Bastien DUMONT
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).