* Why does \doifsomething think there is content?
[not found] <317212607.516577.1673800087407.ref@mail.yahoo.com>
@ 2023-01-15 16:28 ` Joel via ntg-context
2023-01-15 17:51 ` Aditya Mahajan via ntg-context
0 siblings, 1 reply; 2+ messages in thread
From: Joel via ntg-context @ 2023-01-15 16:28 UTC (permalink / raw)
To: Mailing List for ConTeXt Users; +Cc: Joel
[-- Attachment #1.1: Type: text/plain, Size: 1475 bytes --]
I am creating a book that presents readers with a list of recommended materials.
If materials are listed, then its displayed under the \subject{Materials} heading in a simple itemized list.
I'm using \doifsomething{} to check if any items are listed.
The problem I'm having is, when fed a blank macro, `\define\needsoven{}` it thinks there is content, so it displays the "Materials" heading, but an empty list. I have a custom macro that determins "if oven is needed" independent of these other items. So I need `\define\needsoven{}` to be regarded as nothing.
How can I get \doifsomething{} to think \define\needsoven{} is an empty value?
--Joel
My minimal working example is below:
\define\needsoven{}
\define[1]\materialsneeded{%
\doifsomething{#1}{
\subject{Materials}
\startitemize
#1
\stopitemize
}
}
\starttext
\chapter{Recipe 1}
\materialsneeded{\needsoven}
\subject{Instructions}
Spread peanut butter on sandwich.
\chapter{Recipe 2}
\materialsneeded{\item pizza cutter \item stove}
\subject{Instructions}
Preheat oven to 450 degrees F.
\stoptext
[-- Attachment #1.2: Type: text/html, Size: 3028 bytes --]
[-- Attachment #2: Type: text/plain, Size: 496 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Why does \doifsomething think there is content?
2023-01-15 16:28 ` Why does \doifsomething think there is content? Joel via ntg-context
@ 2023-01-15 17:51 ` Aditya Mahajan via ntg-context
0 siblings, 0 replies; 2+ messages in thread
From: Aditya Mahajan via ntg-context @ 2023-01-15 17:51 UTC (permalink / raw)
To: Joel via ntg-context; +Cc: Aditya Mahajan
On Sun, 15 Jan 2023, Joel via ntg-context wrote:
> I am creating a book that presents readers with a list of recommended materials.
> If materials are listed, then its displayed under the \subject{Materials} heading in a simple itemized list.
> I'm using \doifsomething{} to check if any items are listed.
Try \doiftext which typesets the material and checks its width.
> The problem I'm having is, when fed a blank macro, `\define\needsoven{}` it thinks there is content, so it displays the "Materials" heading, but an empty list. I have a custom macro that determins "if oven is needed" independent of these other items. So I need `\define\needsoven{}` to be regarded as nothing.
\define\needsoven makes \needsoven non-expandable. You either need \defineexpandable\needsoven or use \doiftext
Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-15 17:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <317212607.516577.1673800087407.ref@mail.yahoo.com>
2023-01-15 16:28 ` Why does \doifsomething think there is content? Joel via ntg-context
2023-01-15 17:51 ` Aditya Mahajan via ntg-context
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).