From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29981 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: section ids disappear with lua filter Date: Sat, 15 Jan 2022 14:12:42 +0000 Message-ID: <86b1124244074f9f800babffde11db08@unibe.ch> References: <87fsppdsrf.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2642"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBXNMROHQMGQEGC7ZUQA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jan 15 15:12:48 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f55.google.com ([209.85.128.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n8jnU-0000WR-10 for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 15 Jan 2022 15:12:48 +0100 Original-Received: by mail-wm1-f55.google.com with SMTP id a3-20020a05600c348300b0034a0dfc86aasf7310778wmq.6 for ; Sat, 15 Jan 2022 06:12:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1642255967; cv=pass; d=google.com; s=arc-20160816; b=wuJU1G9EDLaVHiRxDMbq564a8zRRjYuWUP2G7osENXplANQOTfINVT8Kdrrw5VKOmB T9he69N73RBmZAXfgIFhs4zLszIHvAByx3nwT1fLpuG6LirqbpMn3L4bzsfKAD1r6e5p UbP61GzEVWgiiuEBRxEPxor6bdaxfL0zEPUJ7IMd5NUO/B/8594pB1CvBks58oPenJQO kDMZ89eXDRDi44m+XU6v2h6t860uHBBsCI8YChlEGNO4rpg3Ea9uuWAojYA4S/JJdSTT FwwhclZvZEoO7oq8xN6RhHOWVUHJLkdz/1kgQAFYayeFdvCvE3cdvfRTwS/OeWbehbuW SvTA== 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:sender:dkim-signature; bh=8awQZmpAW82KfcvbEKDInTiGo1m8TEGH1iT0+T5sLwQ=; b=Z5xNK7ChhyqCJEY2wpi7c6WZWJM9JFwA/nQeUHOLexBXVRK5eVdRrPPgbKWjDdNShX UReBFbb/bVZJ87MSEFo/k8P72GOv7qYwLI504cCjj6ApwvjKfUmS6qn4cJUKBHEjM1r8 w6seRZfaW/DQnVrl5korZJYel3SnKbUk/Oumkeu70l9OCchZis9uSki8QjuR45YPlikE iIoVpYNT78tXAHKkzyTte3gOKZQ4tqHOcth/qObFjwF0F+7HtWjJ7g975ejRF5/HoNEd TqTTvxp9pSeJ0vMIDFTreTeKvzN3QEX8DUtr1CvaH8nIVBqWBOCVIP7JHmGl//Rg+707 VpBQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:accept-language:content-language :content-transfer-encoding:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=8awQZmpAW82KfcvbEKDInTiGo1m8TEGH1iT0+T5sLwQ=; b=qJAk7m1a3d0zCbF/AtUr3zpDJD80Ndk0Fb19R9Lv5alaFYHVFciD0CwMPsC2zxa0DE dnk7vx34n3xeZjTTSvHNwZzzbG1YcaFG60GQdLJrt2NOfTYQ7PUcZ84bCGQ5NdIBzBdz 0kYe0dU4E2E+66UphTxsZN7eT8ndbv/gIY0WHOSDfCEv9JbWGFj1IHZ3Zb0UGcZfd69e RS2YhoYQ8rJdTLjYn5y23Ato+MbfTR5qI3JEpGcD/35AouiF/GdcHTCSL03ytS9eZ6Cz 00zC86gRe8M6Wb6SBhRqOZzAvCs9yh9zj5aM+vSDK06eMcPk9l X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:accept-language :content-language:content-transfer-encoding:mime-version :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=8awQZmpAW82KfcvbEKDInTiGo1m8TEGH1iT0+T5sLwQ=; b=FEXjPKJbkHEZgIPvLUWPx45v/5R2AZbEMURQfB5D9r3lqPiRmK7JD3U8AzJwkC6sOG M4heaBq8MlBNkDaOcEqqReSTihmKZY2n04DdPkNc7AkgasSNFMtkuTb9EAhJZgtPmcNe fs8R7TP5TgFMp32levL2yJGjGZJ0uu1kdqqlLg8K7a4Qg2WIANuDVXBYUN8vjlDYe4+d X6vqePCEbFYzKLoul6pgYaPUyUXELauKPgjI5H7Sz+ROTr7ZnzsZwqasNfmTw/GIdFcL gzjw4 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532bFdGo6aqSlHcvjWVgBZmExPT0Y6PsU7hrCvp/ZfLritnMn4G6 MirI0UwQRN+lvW+31I6Hxss= X-Google-Smtp-Source: ABdhPJyj+S3q8QT47cBX2EEcnlmDI+v2Hvb8kZfpmm7oe4gUEdVrhz4lTwvkotc7T9A8stojpovwtA== X-Received: by 2002:a1c:7303:: with SMTP id d3mr12388877wmb.154.1642255967522; Sat, 15 Jan 2022 06:12:47 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:97ca:: with SMTP id t10ls183wrb.2.gmail; Sat, 15 Jan 2022 06:12:44 -0800 (PST) X-Received: by 2002:a5d:4b84:: with SMTP id b4mr12436165wrt.490.1642255964844; Sat, 15 Jan 2022 06:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642255964; cv=none; d=google.com; s=arc-20160816; b=KKyjPy+fkrjFj+/n9oNkBMUuYAVusWGFjFjpPcqOGBBO28YNIBHO4cjNUyPOjMgpn7 ER0uTaqR55PFLl6+d3VkUkBYCK7lXt9XwploYbza1mGh1VG5p+jSEGporX+Ogn7ZJ5l8 wafm33OhVruoFfHCLsRSg/LIg103KK2mn48T8UTHkWBA6zyEq0RIVV7Ya8jdiAakJitw e7ARP0AJjCSsqsXY+i3t5VMhg9pW5cIk3GpAHg+WA81splI2kr/JNerB+6teKtyTNbey eTLx/V/e4Z9QssPZCUgZUxjFURMYrcIeJWcH7MOWq1/n6FbDYjd5qITb48G2YjLPuuOc vaqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from; bh=KQwJDCccTQoTH/TOAbIvalGbubNMyHeMezB/sKFhPr0=; b=XwXuqZIdSvPGZfxXljrq9mnAqqlXCPhkWE5MOW4sa6kR/iaJMuyDVDUngj+74LxY7l 7cYIYABUaUST8AEfAo2U4U2+w3nvCOfbe/1RN1qhHy5nGfqAfRII5ch44KWP4f9lU90J KI1NGd7q6Sv0CMEvmEUw6pKm7ZvZXCzr8xwl6Lihgs/u8CMgJ0vnN5Sxx9L7AQImAx98 9hkidQc4UoHxowQhzprkIiGDFs6in5kJ7sIbptRM3A9gN6A4mRMhEPavvIJdToSdX4n1 4XZM74vOFYCfK/zpmHSdt2SAhlR+OYiY8pE7N3Ua1s8rrca4rhFJy67ct6cRKT85HIY9 qGIw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch Original-Received: from mailhub-lb2.unibe.ch (mailhub-lb2.unibe.ch. [130.92.0.83]) by gmr-mx.google.com with ESMTPS id bi17si388054wmb.0.2022.01.15.06.12.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jan 2022 06:12:44 -0800 (PST) Received-SPF: pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) client-ip=130.92.0.83; X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-02.campus.unibe.ch [130.92.13.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb2.unibe.ch (Postfix) with ESMTPS id 8EAA2500095 for ; Sat, 15 Jan 2022 15:12:43 +0100 (CET) Thread-Topic: section ids disappear with lua filter Thread-Index: AdgKEhJAzZYVI3jvTPayZ8nkBND3gf//9ASA///kj4A= In-Reply-To: <87fsppdsrf.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> Accept-Language: de-CH, en-US Content-Language: de-DE x-originating-ip: [130.92.13.161] X-Original-Sender: denis.maier-NSENcxR/0n0@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch 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:29981 Archived-At: Thanks, that was it. I now have this filter: ``` -- local pprint =3D require('pprint') references =3D {} function getRefsFromDiv (div) if div.identifier =3D=3D 'literatur' then pandoc.walk_block(div, { Para =3D function(el) table.insert(references, el.content) end}) return {} -- remove from main body end end function addRefsToMeta (meta) if not next(references) then return meta else meta.biblio =3D references if not meta.bibliotitle then if pandoc.utils.stringify(meta['lang']) =3D=3D 'en' then meta.bibliotitle =3D "References" else=20 meta.bibliotitle =3D "Literatur" end end -- pprint(references) return meta end end function put_in_divs(doc) local blocks =3D {} for i,el in pairs(doc.blocks) do table.insert(blocks, el) =20 end local newblocks =3D pandoc.utils.make_sections(nil, 1, blocks) return pandoc.Pandoc(newblocks, doc.meta) end -- Helper functions for flatten_divs -- Returns true iff a div is a section div. local function is_section_div (div) return div.t =3D=3D 'Div' and div.classes[1] =3D=3D 'section' and div.attributes.number end local function section_header (div) local header =3D div.content and div.content[1] local is_header =3D is_section_div(div) and header and header.t =3D=3D 'Header' return is_header and header or nil end --- Remove remaining section divs local function flatten_divs (div) local header =3D section_header(div) if not header then return nil else header.identifier =3D div.identifier header.attributes.number =3D nil div.content[1] =3D header return div.content end end return { { Pandoc =3D put_in_divs }, { Div =3D getRefsFromDiv }, { Meta =3D addRefsToMeta }, { Div =3D flatten_divs}, } ``` Best, Denis > -----Urspr=C3=BCngliche Nachricht----- > Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Albert Krewinkel > Gesendet: Samstag, 15. Januar 2022 14:33 > An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Betreff: Re: section ids disappear with lua filter >=20 > writes: >=20 > > I use this lua filter to move references after a special heading to > > the document metadata : > > > > [...] > > > > The filter works, but it has the side effect that it also removes all > > section ids. >=20 > The cause is that pandoc moves the IDs from the headings to the section > divs; they must be transferred back. See the link below for an example. > https://github.com/pandoc/lua-filters/blob/master/section-refs/section- > refs.lua#L93-L104 >=20 >=20 > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 >=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 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/87fsppdsrf.fsf%40zeitkraut.de. --=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/86b1124244074f9f800babffde11db08%40unibe.ch.