From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29828 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bastien DUMONT Newsgroups: gmane.text.pandoc Subject: Re: Lua filter for section numbers in internal references Date: Wed, 22 Dec 2021 11:12:07 +0000 Message-ID: References: <186dfc25-8ebd-43ef-8a5b-0fae22106712n@googlegroups.com> 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="37543"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDCINCES2QJRBX4QRSHAMGQE7IP2WDA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Dec 22 12:13:38 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ed1-f60.google.com ([209.85.208.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mzzYv-0009aC-RA for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 22 Dec 2021 12:13:37 +0100 Original-Received: by mail-ed1-f60.google.com with SMTP id h22-20020a056402281600b003f839627a38sf1556163ede.23 for ; Wed, 22 Dec 2021 03:13:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1640171617; cv=pass; d=google.com; s=arc-20160816; b=O1eBse8jNLFBhVQmB3DOgsJ5mEb1+zV0aOF6nxBfcCM7r5kRSqiPomslEiNHea/nTc INcefbOpMJUMf7KkmS8SvflpLPMPvexPIucohaWr+00GuhmbI6FAfsFwfailfpVIjp7V dVGy+J5vuzM0G87CpfDUzwBVdcPL0SvRVMs9U0y1pr5MyjAHibORUULS/zuXzZ0+qSzO cwt+WpTiFiKBTrqy7yohLthX2R1iQW43Gnjw/haQ3J+1+TglAK2zhnYxKSg1SsMOq3lR mQnmj/V+P/4NLpchATmU5hhAkLv6NioqsjSNz/aZSAhYmgTDAATj+voFPXielkG6uMvq 58lA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date:sender:dkim-signature; bh=unqs+5GiXNv6z8w6ItNV84WBlEbmwC92cC8/Zh6fc9U=; b=sugxgCGURi11QGtWIj/5FSJymiZijKrNsbLOV2FWYd1tGCIrYDOz24Wn8Enj8OfWDB hHuOwq1kC9np4AW+1kWnRovSb565oy+ReesNH7lLB+pow+BbY63Q1SkMR++JqigAwTzi UeCrKMIsdJAvc5HGPvcgU/dOlAaYga51GocTXwRXvrlXr/Nw8xUhk6aYtkSY7Zd7/rbn p549fjKe+kYlN1yQP9B+UQItOcbbZFQm2GzC/3S7Y1BygDRrAk31MHAeo/xFAiQQaV5+ nm0MkjZapc3KNiV+TKV1mbbV4hgBaGXN6q9TVDZTVcMqCKhOEIzNqdtE8k/u1q5eofRP VHlA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=SKNQSXS7; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :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=unqs+5GiXNv6z8w6ItNV84WBlEbmwC92cC8/Zh6fc9U=; b=ZaJ21NRwtha/vytEtH4nrZbaIR8m+QJukEB1SMqj20RL4BYJ94egIXzMN75PIDs3CS q0RqrpamqsEZTw/vAoehghnUcUlxoVu4sfInU5sT1e781yfyLKx6KYjq04z7B1t6a0Nc vcpWRf5Cr0XpPTbvNN50qGXov5xO4cDv1ofe2+qBzqfOtD/pq4yoCRBbtWiyirEhoHLR wpuCNnaZbfJiDMMCr9tjz/Wlk2GS6S/U8BpW4NKR1zodsyyf4kj3XhaTUY0ML4LRwpyP EspPdom2bqAFuS0Jxz/5JfNuyyWr2BmTCTI8EzZkAxP2o62Cpe3ghTw1EQB4nVHlqG3v /izA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to: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=unqs+5GiXNv6z8w6ItNV84WBlEbmwC92cC8/Zh6fc9U=; b=0BI1kDJ6tLQetp7cy7HS86i5oiJWkE9g3bHofY/5YECqehmpeYAv1KfBcNl6FgGz7Y krwQIfEBZS8pYG+Q3cLOWUzErefhwih0mQCxZo4nWA9IA12kPSR12AmjNwBOD4VZTvyo bKiARJj4VPzV2XeubrkXyuFA0xtX9jF4siKcCyFTMkelU2h1U3nUQhEykkJrLUtoMqXu 7hnoaLK/hm3o874J8wsRWowK//+dbLHgmAuQ2G+Gru5P+l/OxbGhXXK/GWkE6CAor2eH lo3ahIbDbuZHEa0dL4QBnkThwnwVWXNwRJN/OMfinSgm Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532xs4dqyHON9BkvQImj/H4VnoMWBMbcg7VYEAmXjfZSyV6NN9hf Sv0G9KX9fXIJspcNL8VbOdk= X-Google-Smtp-Source: ABdhPJzY8pRGs4c7yuQT95/kwRVfReTBiLSgkGHjK39l0O83dA7BFktbrA3COqV47WHWskuuSheQBA== X-Received: by 2002:aa7:d394:: with SMTP id x20mr2452209edq.268.1640171617466; Wed, 22 Dec 2021 03:13:37 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6402:2691:: with SMTP id w17ls572912edd.0.gmail; Wed, 22 Dec 2021 03:13:35 -0800 (PST) X-Received: by 2002:a05:6402:1d52:: with SMTP id dz18mr2425871edb.285.1640171615182; Wed, 22 Dec 2021 03:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640171615; cv=none; d=google.com; s=arc-20160816; b=BybH+ihEG1CAnTk46IGnHL7cCxHRhbAUGzCqEtt0Mt07JrKgp84rp8T2F0SzxOdWO0 JJHtUQ4k1O61pBD/VwMMo9DeFXlIOVBED9rZZBh5vObJEZ26EqcSroNVhiNKmlvF0d8W QCFnayun4FOiRHzq9aFVeWMZBXKT1V/e6iiRat3CLatBMQsDGQw+3/mUeHhUuFnQisGc 1qjDkxl3R83p5wRHIbqjnrPiwe9ricw4eWStmeovWBW5Nh0rHyOljb8Spqc7KIdKTEr0 cVxtom2Y50VnB598xY1b6ng4Lh6lnhK+B53O/eQFORZV9KjPDC1a7kJqRq2U2uMCOTyG /pxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=x6n0yM5kwI2DiAe6W+hZbC/eIBe6lYjCcRVQgAWwSG0=; b=VLNUEWxM6T2qRa4SvfsoChijWim07rG8eQrUV3wWKrBbq+FhDn0CPX5iRMIYtTXnBX XIF+YTpgHnaBbZ+0/kQUkba44CwHfftdhYLPwJE8BIn5sl8V6XkWX8ETt2UgY8m84HLA xit8HzhVRts4HBBphKxSHZz0mBBd7/PNB8ifTWL/iwnF7K157U2BpYqTa2O+LjphT5A4 /Gs0sP7G9obnJzmtZaERo8eqmC4o2wZQrXOZwdOcE48zk/f3l+q5zqmhKiFmiXE3EWNy QJy4qju622USTB+H/Ez1ro3KO2xQsNo8i8vAXd4tPArfhEKnUpDxjJu+4LpxO6GWCK72 rjqw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=SKNQSXS7; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Original-Received: from mout02.posteo.de (mout02.posteo.de. [185.67.36.66]) by gmr-mx.google.com with ESMTPS id g16si81353edz.1.2021.12.22.03.13.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 03:13:35 -0800 (PST) Received-SPF: pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) client-ip=185.67.36.66; Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id B3295240109 for ; Wed, 22 Dec 2021 12:13:34 +0100 (CET) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JJrKp2T4Sz6tnW for ; Wed, 22 Dec 2021 12:13:34 +0100 (CET) Content-Disposition: inline In-Reply-To: <186dfc25-8ebd-43ef-8a5b-0fae22106712n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b=SKNQSXS7; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.66 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net 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:29828 Archived-At: It seems that you can use pandoc-crossref for such case: see the manual her= e (https://github.com/lierdakil/pandoc-crossref/blob/master/docs/index.md). To answer the technical part of the question, `pandoc -t native <<< 'See th= e [Quick introduction].'` shows that "[Quick introduction]" is parsed as a = normal string. You can create a span instead by adding a class: [Quick intr= oduction]{.sectionref}. But even then, it will be simplier to parse its con= tent if it is limited to one string (like "Quick-introduction"). Le Wednesday 22 December 2021 =C3=A0 01:16:01AM, be...-GbY3e145aRm8w6eVIr4Tmg@public.gmane.org a = =C3=A9crit : > Hi, >=20 > I am trying to make a Lua filter that will replace the normal link text i= n > internal links with section numbers. I want to use internal links in my > markdown document like this: >=20 > See the [Quick introduction]. >=20 > So, the links are given by the full title of the respective section they = refer > to. I found a recipe at stackoverflow (https://stackoverflow.com/question= s/ > 54128461/how-to-use-latex-section-numbers-in-pandoc-cross-reference) whic= h does > this if the link is given like this: >=20 > See the [](#quick-introduction) >=20 > This is the Lua code: >=20 > local make_sections =3D (require 'pandoc.utils').make_sections > local section_numbers =3D {} >=20 > function populate_section_numbers (doc) > function populate (elements) > for _, el in pairs(elements) do > if el.t =3D=3D 'Div' and el.attributes.number then > section_numbers['#' .. el.attr.identifier] =3D el.attributes.numb= er > populate(el.content) > end > end > end > populate(make_sections(true, nil, doc.blocks)) =20 > end >=20 > function resolve_section_ref (link) > if #link.content > 0 or link.target:sub(1, 1) ~=3D '#' then > return nil > end > local section_number =3D pandoc.Str(section_numbers[link.target]) > return pandoc.Link({section_number}, link.target, link.title, link.attr= ) > end >=20 > return { > {Pandoc =3D populate_section_numbers}, > {Link =3D resolve_section_ref} > } >=20 >=20 >=20 > While I do understand what it does, I cannot find out how to change it to= my > case. How can I retrieve the part written in [] instead of the attributes= when > scanning the document for those internal links? Or is the not even possib= le?=20 >=20 > Any idea is appreciated. >=20 >=20 > Torsten >=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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit [2]https://groups.google.com/d/m= sgid/ > pandoc-discuss/186dfc25-8ebd-43ef-8a5b-0fae22106712n%40googlegroups.com. >=20 > References: >=20 > [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [2] https://groups.google.com/d/msgid/pandoc-discuss/186dfc25-8ebd-43ef-8= a5b-0fae22106712n%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/YcMIB/cIBo3JwTa5%40localhost.