From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30622 invoked from network); 16 Jun 2023 18:26:05 -0000 Received: from zapf.ntg.nl (5.39.185.232) by inbox.vuxu.org with ESMTPUTF8; 16 Jun 2023 18:26:05 -0000 Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7AB411C391E; Fri, 16 Jun 2023 20:25:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.ntg.nl Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L_v1I7TRTfQD; Fri, 16 Jun 2023 20:25:26 +0200 (CEST) Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B00F31C392C; Fri, 16 Jun 2023 20:25:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id C2C0D1C392C for ; Fri, 16 Jun 2023 20:25:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.ntg.nl Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1KIzu0n3hdqh for ; Fri, 16 Jun 2023 20:25:23 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=185.233.34.146; helo=outbound.soverin.net; envelope-from=j.hagen@freedom.nl; receiver= Received: from outbound.soverin.net (outbound.soverin.net [185.233.34.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id E3BAF1C391E for ; Fri, 16 Jun 2023 20:25:22 +0200 (CEST) Received: from smtp.freedom.nl (c04smtp-lb01.int.sover.in [10.10.4.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 4QjSJK4bF2zCR for ; Fri, 16 Jun 2023 18:25:21 +0000 (UTC) Received: from smtp.freedom.nl (smtp.freedom.nl [10.10.4.107]) by freedom.nl (Postfix) with ESMTPSA id 4QjSJJ6w4yz4c for ; Fri, 16 Jun 2023 18:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freedom.nl; s=default; t=1686939921; bh=vYhltXavbuawzB/zO3jL+ivBqMD0Jfr3SJrJD46ScQE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=sHmeJnIUiD+CVFhdIZE4T3Wohlx2vBsBdAfyTnRRV5Z4nwBKZcIiqw1ZMaL/j0+SM cgfKx2d+6mpE8qFVe9jKUHTtNDXUj8IemD09zDRrm7NaC2f2/lwrqOoEPEN37meHwd hwooq6bcRBpwRkVYQqQbPhtFnzKDyX/e/0xm5jRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freedom.nl; s=default; t=1686939921; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yd/vVUenRA+shGr5kFc1bQjYYao1SHIVsNRDQvobOyI=; b=FCRJ8EU9HZtKgsb/BfdPOZZsv9s/ASwknavwjuHREavOB2SWYPFcZfUBBEHP11BfSgk2J9 aKZIC1ecECsLwj7CYdE0owd9sNdSayzzn3nM5pk6g35iEpiwSr1jUOA26kuADHJCX7RWUJ W/5/jZm1Qfo5iQR8XJ7O2Zm11pbP0pQ= ARC-Seal: i=1; s=default; d=freedom.nl; t=1686939921; a=rsa-sha256; cv=none; b=Co5QVr5OyKlGTiqDbcVMmjh5wl1XVP1RUIp2kL9b+lLXFvzhoBoFpBhcssxrFRtYEGOjvJ XZO/Ly6vhHIDonHAfaaKG2F8Ap8X43BFqEiNPGYJ5sup9XN8muyfAKa0fScfGsu6itoQJj XeVK+XdGnv49E4aLac8iZRzN8toZbcE= ARC-Authentication-Results: i=1; smtp.freedom.nl; auth=pass smtp.mailfrom=j.hagen@freedom.nl Message-ID: <1d86aeb8-5009-e9e1-18e2-e5e1440b43d3@freedom.nl> Date: Fri, 16 Jun 2023 20:25:20 +0200 MIME-Version: 1.0 Content-Language: en-US To: ntg-context@ntg.nl References: X-Soverin-Authenticated: true In-Reply-To: Subject: Re: [NTG-context] Protect the lettrine X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.38 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Hans Hagen via ntg-context Reply-To: mailing list for ConTeXt users Cc: Hans Hagen Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ntg-context-bounces@ntg.nl Sender: "ntg-context" On 6/15/2023 8:35 AM, Max Chernoff via ntg-context wrote: > Hi Dave, > >> How would you instruct ConTeXt to "protect" the lettrine such that >> regardless of whether the first paragraph spans multiple lines, a short >> first paragraph will still prevent the second paragraph from overlapping >> the lettrine? > >> Here's the output I'm looking to achieve: >> >> https://i.stack.imgur.com/XeZQS.png >> >> Note how the second line honours the lettrine's width and padding, in the >> same way that the second line of the first paragraph in Knuth's quote >> respects the width and padding. > > Here's a questionable Lua-based solution: > > \startluacode > userdata.hangindent = 0 > function userdata.post_lettrine(head) > nodes.tasks.disableaction("finalizers", "userdata.post_lettrine") > > if tex.prevgraf < math.abs(tex.hangafter) then > userdata.hangindent = tex.hangindent > nodes.tasks.enableaction("processors", "userdata.next_par") > end > > return head > end > nodes.tasks.appendaction("finalizers", "before", "userdata.post_lettrine") > nodes.tasks.disableaction("finalizers", "userdata.post_lettrine") > > > function userdata.next_par(head) > nodes.tasks.disableaction("processors", "userdata.next_par") > > if head.next.id == node.id("glue") and > head.next.subtype == 20 > then > head.next.width = userdata.hangindent > end > > return head > end > nodes.tasks.appendaction("processors", "before", "userdata.next_par") > nodes.tasks.disableaction("processors", "userdata.next_par") > > > local default = typesetters.initials.actions.default > function typesetters.initials.actions.default(...) > nodes.tasks.enableaction("finalizers", "userdata.post_lettrine") > return default(...) > end > \stopluacode > > \setupinitial[n=2] > > [...] > > Normally manipulating nodes inside the callbacks is the wrong way to do > something, but in this case, that's exactly how the standard initial > code works. > > We need to modify the "default" alternative since "\setupinitial" > provides no way for us to set a different alternative. A better solution > would be to provide a new alternative so we wouldn't need to make > questionable overrides to the base code. Indeed, and it might also sort of fragile due to the prevgraf although we can assume sane usage. All this stuff is also a bit order sensitive. I'll added this: \setupinitial[n=2,continue=yes] But I'll also cheat a bit by adding a prevdepth field to the parstate that remembers the previous one (as it gets lost otherwise). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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 ___________________________________________________________________________________