From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/21844 Path: news.gmane.org!.POSTED!not-for-mail From: Axel Rauschmayer Newsgroups: gmane.text.pandoc Subject: Re: Chapter TOC via filter? Date: Fri, 11 Jan 2019 04:56:55 -0800 (PST) Message-ID: <6e119a06-0158-452e-84e3-b248a4efd4a6@googlegroups.com> References: <1bb6e5f4-04ce-4209-8223-f928f2943998@googlegroups.com> <4f0905e3-c55d-4d97-958c-8478ada10bcf@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_825_1195583124.1547211415161" X-Trace: blaine.gmane.org 1547211290 28909 195.159.176.226 (11 Jan 2019 12:54:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 11 Jan 2019 12:54:50 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDYNJWVNWQLBBGFF4LQQKGQEIRBUVAQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Jan 11 13:54:46 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-oi1-f192.google.com ([209.85.167.192]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ghwKj-0007Nj-Uy for gtp-pandoc-discuss@m.gmane.org; Fri, 11 Jan 2019 13:54:46 +0100 Original-Received: by mail-oi1-f192.google.com with SMTP id x65sf6741937oix.0 for ; Fri, 11 Jan 2019 04:56:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=fQupz7hezPrhsbOXXyGlBF79TYxHTrNTVKPcXLZ0nGY=; b=QGDbjEeV7nQ2hVbcYU2EoF0tCtz2XWscsxa4OfVGSdLqRLSGh6+AnuQFizE5kEgfoQ 8Bk1XDeQwUA3ZaCvSz9nszlttompAk1HdM58mg9PM/mwmEzNT0KiJxgZWTsQvT8vaUim RtJYlICLDgXd11jfrK97o/2tVa4wsZKmjgq/Hae71YRV8r7njLf+dVy+vf3npsGLKF7J XDhXpxswX5dfPV7Hb88mDqDqty+iwSC1ZIqU8mSF9y730ob7KOYHkYty2DFGuYSQcuJM 5/9bC8vXGN+QT/oC0hoR30cASAlXzuw5X6ZoSOgQedSBnkIjPgoLpyNfxcOpQ6sW6jZY 0Jng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=fQupz7hezPrhsbOXXyGlBF79TYxHTrNTVKPcXLZ0nGY=; b=fajBn3P+8by0IgWIdsl2QllCphFF5acsSoGgPG7C0HyoCLn+Bu/mctkEokkcYyQRxp yzoZXaa+OigB13AwdiEQliulWE5sePQiKT52sxfb4h0pHRFdxo71EiZn/Tt1C4jlAxfD Gxm9KGoij8QqUB8q5Dp3HtlJTtQHHevFwka75+hDNajzccUdhKD8Ee4b+dohI2JUkcdh PVWNGMBRzlKutSFss/u7zrwU3k9eddZqQsN8jS+M/FmVF81f6gcipVqwx57BjGBqewTa NKWcYOfAE0KlW4cFNzL47owE1PvLfHBLK4ljxqZcTEFEQ6fovAYd9qdo6ILyzo2FVGmM HPIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=fQupz7hezPrhsbOXXyGlBF79TYxHTrNTVKPcXLZ0nGY=; b=RlA2xORnq4Df78kyy9mJWfEV07IcwVWU8CZiUPSH6Xp5ebYeO37k7Eioy8qGk3MJRJ t584+/SQ8AXBLFeLd6jf0X37bETdPWHMEbxRY4R7s450wvzOKlEEzN7XE6M2Au05xU5m roGEdfG2DhC0yQuNweK9nSNde4GBgJz5xm86FGe7DjVGVu3yYWkKidsecwhUtIQs6YuV iBkChbI2iQWzXTPsrtg7OfzqJRdLHqKs0mW0tm/S+ANdf7tOzs7A1XZH78936t0D99al JsvgouNkyhnZKw+jrBNT1C+82GjRTWYHpqqZC7RjsRlsay8MOD8vCWpIwJ8fAPeNOBoI LfWA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJcUukdmtVV3xulXRENIncZo370pUHAGNHL3re727R7euxNYT66nIRg2 ARo4JwBJS5H+QsZ1W6wlra8= X-Google-Smtp-Source: ALg8bN7m34URwovZPV3Mjl0qf+yoFGStv9jqexcjQXQdn5qjSDo33PJU3CAeCAl10bm2wnHIMbRaWQ== X-Received: by 2002:a9d:7310:: with SMTP id e16mr1028otk.7.1547211416891; Fri, 11 Jan 2019 04:56:56 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:75d0:: with SMTP id c16ls229990otl.3.gmail; Fri, 11 Jan 2019 04:56:56 -0800 (PST) X-Received: by 2002:a9d:2c22:: with SMTP id f31mr1414otb.4.1547211415789; Fri, 11 Jan 2019 04:56:55 -0800 (PST) In-Reply-To: X-Original-Sender: rauschma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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:21844 Archived-At: ------=_Part_825_1195583124.1547211415161 Content-Type: multipart/alternative; boundary="----=_Part_826_1488976678.1547211415162" ------=_Part_826_1488976678.1547211415162 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > I haven't looked at this in detail, but I would have=20 > thought you could have extracted what you needed from=20 > the `numbering` part of a Sec, which is just=20 > a list of integers, e.g. 2, 4, 2.=20 > > If your top level header is parts, then the first=20 > number is the part, the second the chapter, the=20 > third the section. Then it's just a matter of=20 > converting the part to a roman numeral when the=20 > other numbers are absent, and otherwise ignoring=20 > the part and concatenating the other numbers=20 > with '.' between...=20 > 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 =20 The first part of my filter numbers Headers properly (to be used with HTML= =20 and parts): - Visit Headers via a filter. - Per Header: - Update a counter (with one integer per content entity): depending= =20 on the level of the Header, while correctly handling part numbers. - Prefix the Header=E2=80=99s content with the properly formatted cou= nter. =20 Given that I already track Headers and their numbers: - I just additionally keep a mapping from chapter IDs to a list of the= =20 chapter=E2=80=99s Headers. - For the chapter TOC, I transform this list to nested bullet lists, in= =20 a second pass. =20 --=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/6e119a06-0158-452e-84e3-b248a4efd4a6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_826_1488976678.1547211415162 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

I haven&#= 39;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=A0Then 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 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://groups.google.com/d/= msgid/pandoc-discuss/6e119a06-0158-452e-84e3-b248a4efd4a6%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_826_1488976678.1547211415162-- ------=_Part_825_1195583124.1547211415161--