From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/21846 Path: news.gmane.org!.POSTED!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: Chapter TOC via filter? Date: Fri, 11 Jan 2019 18:21:25 +0100 Message-ID: References: <1bb6e5f4-04ce-4209-8223-f928f2943998@googlegroups.com> <4f0905e3-c55d-4d97-958c-8478ada10bcf@googlegroups.com> <6e119a06-0158-452e-84e3-b248a4efd4a6@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000007be73b057f31eda5" X-Trace: blaine.gmane.org 1547227172 23120 195.159.176.226 (11 Jan 2019 17:19:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 11 Jan 2019 17:19:32 +0000 (UTC) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBIVB4PQQKGQEKB3BNIY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Jan 11 18:19:28 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-wr1-f57.google.com ([209.85.221.57]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gi0Su-0005sU-4n for gtp-pandoc-discuss@m.gmane.org; Fri, 11 Jan 2019 18:19:28 +0100 Original-Received: by mail-wr1-f57.google.com with SMTP id v16sf4731115wru.8 for ; Fri, 11 Jan 2019 09:21:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1547227299; cv=pass; d=google.com; s=arc-20160816; b=mPGoPXF1k0R5uHz4hzF6IZ7oxlCCc16NIQAgS4zsj3ih3GKxuOTtkr1L2a17pRxaK2 n0efgLx7KNNsrvbBCnphHxAcybROo5SQRDPk0R/v50JvkaolQcSShPatxG0Ic2WUGUs8 spwTYgVJbR58jKnLiPNQS6MNQ1PX+8dt8uc84gPzSmfsNM5GaVANBPs4TVU/72+ocYjS ltHPqhveIMtLxhqHH5WNRAVrdS9V0IKsIRrBRaJZoGs/PGzMgUQi3erB9SFwu1oAzFFV cPxzn31KP7D3iYdZ4l2qoxzJHJPi3db6K13CG8mSPIOOAS3AXstdzCxQDJvPKdxcJc0j w0Xw== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=6OuQJx3LeUbRI8a4Fn2d6jhbqeUr9/N13P3Li64eIjU=; b=A7p/qHnSlPHiH5T2vJE93a9zGTksCvLoHK1t8yW8Z3FveDK6vIrnAHy9LEd+kHWsZ4 hg0bQ9TPyDFFgDzmKckJVSykd7CTGIY3htuRa++dCUfGZmY+cKTCq+RCGB0s4+iOrzKp keg5WV0sZZsM0sM6i7wJ6jFwABDTpY1iayQzm5Gxa7I2NYhkg31SgjO9iUYKfDZ8qY5o urqCJxTvNED12MG7gu6Es5jbRs4gQD0M44K0RlPYxa/wPPj9aLvLAPyhfNsPTxmrLU/d yBArcDkceNiD4uPNRHSsY9y2RL/SjJmQAoBvcUDtggIrSfBC/2nBFVjy/HRJn7r2jFdw YkFg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=myJ2k4V6; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::334 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject: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=6OuQJx3LeUbRI8a4Fn2d6jhbqeUr9/N13P3Li64eIjU=; b=ZsGcMsYSd15yR8WB6zbWOATBuP8wrVMV0Hpf5meIHCI3e96bZBdpw8+4LdJGmfLMCu ob23MSxIri881XO2Ywm/KMfxEoRYzgZiv1VVTEG7+k422b7YBXhY3MYX2uarAyeX5E2Z 3SLh9b0uEL7Rl/F07Al/PfYI519T4g1s2SYXyTmIcdPRls1YwN9OS1rdjGLIy6TB65X/ TfnaesJkciHoCouTXYuOXgQiI4GSDOeqjdIbDq4RE8DVPFR3w9Ap4Gp2C/kv8ABa6dvY rZewXtERc2PzhsyHVuYATG30fIiAq3p8h51TV8TIqVBGE3eCHR4MMKTspY0CDkdk6px8 aZHQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject: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=6OuQJx3LeUbRI8a4Fn2d6jhbqeUr9/N13P3Li64eIjU=; b=X32+6+s6E6PgyoBjZufFvjp7elOq9LOT9aAdAKaea+EDfh4C0mDV5b1ZEisQdhWKz8 bzJssI/NlIHSOCKFVDRmcau+lsf0rWI9E1LLxQKExX1FyjPvw9658dVoqEUGJhGPb0C3 FdOnjsBIADb0dUlKwnDW9fMnSJ7AK7PM7jByesRmv9rpgLWcZB8GbQrclTUpfRQp6RAp t/hKrNFBKwBqfr4D18RWp+ayDhIg4EJKowvnNCqwmRRBwz7Qng4dH+nzpQfVq8c4IWdZ BUKQtlrfnlSFTO4NUBbjeDp6E8Ol+zMNx2kX21FCf60HxTgP53TKz3M4X7pBOioWFXYf vWtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject: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=6OuQJx3LeUbRI8a4Fn2d6jhbqeUr9/N13P3Li64eIjU=; b=i2FuxqDgvK9y8yn28HQxayvroUigRiE3XoeCNyXFI1V2gDGr40r1BETfzXMVUlD6Ig GzhX+Tc0/z77pBU7cLj7vLcK+8ZWEPqEgDeFaux2EW2O4eoZdkNok09SIRDWJIvFzkwK a/LMkbxSBZxrcApRk6Wrqz6ehOh+Y9YFYCNL0PuiPJrC9Zj6xyx2UCNToS/Qjf/QL5r+ UN67zs5VpMNxwn7eA26Pp1IMOvmF5STtZbj722w4LnwG7KUV3hV+/Wjw7SjbeRng+fka AqjGvGn293C3r0yheaZqFZFCesv8z3rLiq+Zvo3Ggr3aoXZEYsu7bBT3ZPNIG0rJIRYN xupA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJcUukeM2bQgnGhB7xRXxYhuyHPWpgiI+ubp0m9oF6QFgsXB/joVspPG nt8Iu5xgU7OYO/0NaboJPUo= X-Google-Smtp-Source: ALg8bN6hlcuag5ROuci3hJwIMhBqR4LQ2O+flojmXFLImFkiKesSRkmqgd39g9btTzhY3bWdRiqbPw== X-Received: by 2002:a1c:96ce:: with SMTP id y197mr6275wmd.3.1547227299405; Fri, 11 Jan 2019 09:21:39 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a1c:2d50:: with SMTP id t77ls561981wmt.11.canary-gmail; Fri, 11 Jan 2019 09:21:38 -0800 (PST) X-Received: by 2002:a1c:aa47:: with SMTP id t68mr121791wme.6.1547227298489; Fri, 11 Jan 2019 09:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547227298; cv=none; d=google.com; s=arc-20160816; b=HZFnUnOxhP7GyJpFEfV9GGRP7Gwwkl/APrN4+0TUlABPZU94Okf5fHcDdxxvwffFGz bG6ELUJj7H3/tellNrYfoomvo7RI3xGcn0rv3yXe6kwjFVGUhSSTPF8lCGkkHAhU/veI nFVETkeeQOOswxqpqwPFFzmA9GnWPbAgMnnY3XIMQD6uNKguCuBZbYTyCXU5kxDpgG+x fTkWSKxKJTumoybkl+7wXUYQdN5D5F8oqi4rzCs4ooBSeB/rd5rR6wF2jjE62ScdODVr YMxjaqBAXWob2nU82egw51cGXJm7QNA9XEZs7vWXMXAPcb04tuP5CC8uHVgdW6amwpWW B5rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ADUIrNLGqSws79bbyMj9brjMjvf8VQGujoSzdLPa+Gw=; b=EWWp7vW/eRC7H/j2xRXioanV8IRkXzZnL9QXiBfSolYwf0yKHvDODqjwr9Yklwdu+e F74KbtQHsVHbKz2YcPgqS0KNSCz0+KsrNadFNVnkKXIUGkoX+627/SdkymXnWVr0DcWS LR0p3pwxoggUTykD7grbdwye+ySRdVXlM1SdG60mSXPLE69+R75/8T4CIeIsFrXZIW/C zgHpAdBlVsoF4kMoOoaJIldmVLPgawD8PYpvtBiss11P12FVxE5i3OXXuC6kEbImPrb/ vzU7MrSq3V+OWYDXHtRG80FB2EnFUHasmChsNQ/Iq3FRaLSAF/qaZzHSV5KoPyv/apzh 8e9g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=myJ2k4V6; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::334 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com. [2a00:1450:4864:20::334]) by gmr-mx.google.com with ESMTPS id 69si2130290wrb.1.2019.01.11.09.21.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 09:21:38 -0800 (PST) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::334 as permitted sender) client-ip=2a00:1450:4864:20::334; Original-Received: by mail-wm1-x334.google.com with SMTP id p6so3115430wmc.1 for ; Fri, 11 Jan 2019 09:21:38 -0800 (PST) X-Received: by 2002:a1c:7719:: with SMTP id t25mr3286548wmi.7.1547227297997; Fri, 11 Jan 2019 09:21:37 -0800 (PST) In-Reply-To: <6e119a06-0158-452e-84e3-b248a4efd4a6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=myJ2k4V6; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::334 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Spam-Checked-In-Group: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:21846 Archived-At: --0000000000007be73b057f31eda5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You need to keep a counter for the chapter numbers, basically a variable holding a number to which you add 1 each time you encounter a new chapter and then replace the "local" number at the chapter level with the value of this variable for each heading. BTW number incrementing in Lua is very old school: var =3D var + 1. Den fre 11 jan. 2019 13:57 skrev Axel Rauschmayer : > > I haven't looked at this in detail, but I would have >> thought you could have extracted what you needed from >> the `numbering` part of a Sec, which is just >> a list of integers, e.g. 2, 4, 2. >> >> If your top level header is parts, then the first >> number is the part, the second the chapter, the >> third the section. Then it's just a matter of >> converting the part to a roman numeral when the >> other numbers are absent, and otherwise ignoring >> the part and concatenating the other numbers >> with '.' between... >> > > The problem is that part numbers don=E2=80=99t affect chapter numbers: > > - I. Part 1 > - Chapter 1 > - Chapter 2 > - II. Part 2 > - Chapter 3 > - Chapter 4 > > The first part of my filter numbers Headers properly (to be used with HTM= L > and parts): > > - Visit Headers via a filter. > - Per Header: > - Update a counter (with one integer per content entity): depending > on the level of the Header, while correctly handling part numbers. > - Prefix the Header=E2=80=99s content with the properly formatted c= ounter. > > Given that I already track Headers and their numbers: > > - I just additionally keep a mapping from chapter IDs to a list of the > chapter=E2=80=99s Headers. > - For the chapter TOC, I transform this list to nested bullet lists, > in a second pass. > > -- > 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/6e119a06-0158-452e-84e3-= b248a4efd4a6%40googlegroups.com > > . > For more options, visit https://groups.google.com/d/optout. > --=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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/CADAJKhDkztkE%2Bk35A4r4XuZJFoy9ivEm3%3D48YHkbdfNJbMYhrA%40ma= il.gmail.com. For more options, visit https://groups.google.com/d/optout. --0000000000007be73b057f31eda5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You need to keep a counter for the chapter numbers, basic= ally a variable holding a number to which you add 1 each time you encounter= a new chapter and then replace the "local" number at the chapter= level with the value of this variable for each heading.
<= br>
BTW number incrementing in Lua is very old schoo= l: var =3D var + 1.


Den fre 11 jan. 2019 13:57 skrev Axel Rau= schmayer <rauschma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org&g= t;:

I haven't looked at this in detail, but I= would have
thought you could have extracted what you needed from
the `numbering` part of a Sec, which is just
a list of integers, e.g. 2, 4, 2.

If your top level header is parts, then the first
number is the part, the second the chapter, the
third the section.=C2=A0 Then it's just a matter of
converting the part to a roman numeral when the
other numbers are absent, and otherwise ignoring
the part and concatenating the other numbers
with '.' between...

The problem is that part numbers don= =E2=80=99t affect chapter numbers:
  • I. Part 1
    • = Chapter 1
    • Chapter 2
  • II. Part 2
    • Chapter 3
    • Chapter 4
The first part of my filter numbers Hea= ders properly (to be used with HTML and parts):
  • Vis= it Headers via a filter.
  • Per Header:
    • Update a counter (= with one integer per content entity): depending on the level of the Header,= while correctly handling part numbers.
    • Prefix the Header=E2=80=99s= content with the properly formatted counter.
Given that I al= ready track Headers and their numbers:
  • I just additionall= y keep a mapping from chapter IDs to a list of the chapter=E2=80=99s Header= s.
  • For the chapter TOC, I transform this list to nested bullet list= s, in a second pass.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To post to this group, send email to pandoc-discuss@googlegrou= ps.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6e119a06-0158= -452e-84e3-b248a4efd4a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://gro= ups.google.com/d/msgid/pandoc-discuss/CADAJKhDkztkE%2Bk35A4r4XuZJFoy9ivEm3%= 3D48YHkbdfNJbMYhrA%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--0000000000007be73b057f31eda5--