From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/26670 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: jiewuza Newsgroups: gmane.text.pandoc Subject: Re: How to deal with nested divs in lua filter Date: Thu, 29 Oct 2020 13:57:44 +0800 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25179"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Cancel-Lock: sha1:++UAnIFbgK161mwaf2KLvjtx6+k= Original-X-From: pandoc-discuss+bncBAABB64H6H6AKGQETX3ADKQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Oct 30 17:49:03 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qk1-f186.google.com ([209.85.222.186]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kYXaI-0006NF-DH for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 30 Oct 2020 17:49:02 +0100 Original-Received: by mail-qk1-f186.google.com with SMTP id k12sf4225866qkj.18 for ; Fri, 30 Oct 2020 09:49:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1604076541; cv=pass; d=google.com; s=arc-20160816; b=SHdFhM/CVJlKwM9P5JSatJu3hATHeZZsDtYm6Bvt8NN2t3GZh60R+K5/I9dLBN/FF3 Facs0CU3bE7m7sQNWkM7Lw9IuxdbbAxTpATSdEA6S2W+QfEHlCd/0JNe70aj2x81l6dB UufNYgMZFzEdiYXqQoMA0rK/e7T9wvFl21afjQAvtiDhTZVznH9Bc+PBXISiuYemvABY +TNTP6e5ETiN/yAGCy6VFPl1JIcA0ES2Q4Or0rzCwyiiClrWM/QKXAyaLe4rCKI+LImL snflbUkTc1r94nrikgHo+2AENzAvnggkhmgMmyi+3AiRnUY72mJSTHV7NKTa2aFfOr3U g6Sg== 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:cancel-lock:user-agent :mime-version:references:message-id:date:subject:from:to:sender :dkim-signature; bh=Icm1E623FeHNcuc2N0fs4QIJuwT37NCLYQMpSo+WLIY=; b=v19xYJlUd4yHh96CaaW0onxEHr9zKuBVEJd2ZkDmH0n0gDx6iRTHMrjBerLn5NxYHz xpusivVebwqkDv0UEsU9TKNdZ+XpvnMMPa7It7EpMaKkjiFlx5uDardspy2gLfY1mVoK 0Q9t6UkclVXWM2H8qMtaukiXvivpJ5e8K5/zyEFpH8MUS+UYvYdiRsfV01TS3DhKLHkf z3qotsYtfrOaCJHqi0/e57JaTfIXX/cgbC6O1tVVn59sasrv7zam5mj5HVpeJGRDbhgy IBLIm2+Tw9rYHguc37UGfc+4KFNubpayKIHMtZCW1yK2YH7xl5Sbb5civuvzdLoW2UU9 ijzQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of gtp-pandoc-discuss@m.gmane-mx.org designates 116.202.254.214 as permitted sender) smtp.mailfrom=gtp-pandoc-discuss@m.gmane-mx.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:to:from:subject:date:message-id:references:mime-version :user-agent:cancel-lock: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=Icm1E623FeHNcuc2N0fs4QIJuwT37NCLYQMpSo+WLIY=; b=qUOSa2BI7IyEJed1xjlho3Nxsx2hBpW73RmjPV5sE7tud2oIpd2rUBJhecBDamJs3y 7A0qxFFAwqyZ0Ia817lZvIgw2B29JAwlZgmkDuVSrLMFa2bAFaXF5Uc0/X+79RLguJaH z5NSHkfB3qtO9Ox4pe2xzoJGXD1vPy14lQ3ZbOaf0oghbdSkagMu4MHN74idAAwM7GPK GJtArsSIyR2L/Fn+B3Tsl+TCBVQyzbFov7frLF6d/a/6cLbTG2z09R8aM2y6Zqou+YAF noPUUjB/K/E4pZLU8cyF3Yq3IGdRw32mU8MqoJeW2K+FaKji/u4QgqDtZpZvZCGKUxIz Phgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:to:from:subject:date:message-id :references:mime-version:user-agent:cancel-lock: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=Icm1E623FeHNcuc2N0fs4QIJuwT37NCLYQMpSo+WLIY=; b=aaH0mx1siIjRAzTZjdXOm83uVdqLpOXISDUAh+WWUf637aIEP3II0Ak2ysoZ0uoi3O 1KFA2x0CjjtLjFiCPvFQ/Iuc5jgnzuSgt075PXMuBGoMVHilXcWPzC3kiVsPyZ4EKK0v e8lWHqfjgKNsgHsymzCcZpSQezumIxA7dg18/pdktcGu9YwlkukqhAl3jR2lHD1maKGy NuGU5iBgJtdi+t7XGCYliyd4ph2feCKW1D+1WjrP+5K86tqF0ymCUEgtx+srD8rUzRzn y0vXsmi43Ohh/Ep6vaYFSCK0KoR3d3NTNDXevbWQKV1z6amVPQZh9925AP6yC6v4e2xr sAww== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531clpN9/uksQtMw1KhFhxSVV144Y3MdayD5mUuiq6xSfzzkp9Ot VTqI8ZcuBnfosy27u2dx1Ik= X-Google-Smtp-Source: ABdhPJxET5hvsToFmuFhxCowH3k6r1ZIe2MFq3vc9C4FPPe34RbD9gvGrLRW9hkusqIBLCOhtvtGMw== X-Received: by 2002:ae9:ea14:: with SMTP id f20mr2984197qkg.239.1604076541533; Fri, 30 Oct 2020 09:49:01 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ac8:71cf:: with SMTP id i15ls2705819qtp.7.gmail; Fri, 30 Oct 2020 09:48:59 -0700 (PDT) X-Received: by 2002:ac8:7218:: with SMTP id a24mr2869013qtp.92.1604076539074; Fri, 30 Oct 2020 09:48:59 -0700 (PDT) Original-Received: by 2002:a37:aa58:0:b029:15f:5603:a7ad with SMTP id t85-20020a37aa580000b029015f5603a7admsqke; Wed, 28 Oct 2020 23:00:04 -0700 (PDT) X-Received: by 2002:ac2:58d2:: with SMTP id u18mr880598lfo.496.1603951204126; Wed, 28 Oct 2020 23:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603951204; cv=none; d=google.com; s=arc-20160816; b=LemFhnT4ZfKva+lYaK8JKLZICgCeBmyDYMTab2LqCtRzKXLkdKLmgtYc9bPVbyRG+I blQ/BnxEPdiTqwBGDGDWribugSQpGv3jnoLGSx4Z0mPuSO7rF2HfKVEP4gmdi60t//Xm a9vAfQWMRr0B1MdayMrJwbsQwGcor2yR/OoksoLsJH729MB0zAVsGNhLQB1f4+sQHfpU aquvKzYlvDW8shipgFKJ3WpcQDZXbSDe2ZrtwuU3yY9+p/bLvpOBniaMybNCAwo4pJaz ZR+7+fcommUjYtwrjWL6t+gADoDRLb3F5XPT80yrh6AG998aVOyXi7LwIxQ2KiiR2G4z mIUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cancel-lock:user-agent:mime-version:references:message-id:date :subject:from:to; bh=+9XDvf1cWWigF9lngDNqxhPvm1Zd4xPwvSbLbArhH80=; b=06P0MZ70MxUySL18g+p5X7GKGIPUJ2WB4/GrwlIVqFNG1sfQJD3ncv3vQFsZIh+das gdXj6J8DkPiGtNRTEKzdptnYEncIEmIOfIFuj+0AGJ/Ev2WlnttDdoJd2Mb0P2MRHA0t GAgthqGgspUk9KML62Kw/upEpK4v5DPCVYD38wtuineTbzSBwVArL8AIgrfnHNUdn2eW efNy9W6gnjvtvDUmzed7EIsdrCyX6x3T0LUBlipZMqYiiTaZpRr/8C7+pWCJ16MTWHn6 h0G8tAvONMDMqSc/bL5k01Px/Kf37dcryPSGIUCcmGakSKaqfJEh/NnonNDUzygscXWz wUCw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of gtp-pandoc-discuss@m.gmane-mx.org designates 116.202.254.214 as permitted sender) smtp.mailfrom=gtp-pandoc-discuss@m.gmane-mx.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=163.com Original-Received: from ciao.gmane.io (static.214.254.202.116.clients.your-server.de. [116.202.254.214]) by gmr-mx.google.com with ESMTPS id l28si55435lfp.11.2020.10.28.23.00.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 23:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gtp-pandoc-discuss@m.gmane-mx.org designates 116.202.254.214 as permitted sender) client-ip=116.202.254.214; Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kY0yf-0000yo-RU for pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; Thu, 29 Oct 2020 07:00:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ X-Original-Sender: jiewuza-9Onoh4P/yGk@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gtp-pandoc-discuss@m.gmane-mx.org designates 116.202.254.214 as permitted sender) smtp.mailfrom=gtp-pandoc-discuss@m.gmane-mx.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=163.com 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:26670 Archived-At: Nice to know it. Now I just keep them when it is dealing with the child nodes. And do the process when it comes to the parent. John MacFarlane writes: > Yes, it's a bottom-up traversal of the tree, so child nodes > will be processed before the parent. > > Doing top-down traversals in filters is currently tricky. > > You can, of course, do it manually, with a for loop around > the blocks in Pandoc, but that's clunky. > > Maybe Albert has ideas on how we could make top-down > traversals possible. (I needed one in pandoc's citation > processing and resorted to an inefficient workaround.) > > jiewuza writes: > >> I have nested divs in my document. >> I have in my lua filter: >> >> ``` >> function handleDiv(el) >> if el.classes:includes("parent") then >> return handleChild(el.content) ----- here content is {} >> end >> return {} >> end >> ``` >> >> But I find the content of the parent div is empty. And it seems that >> each child div triggers `handleDiv` before the parent does. >> >> What I want is to deal with the child divs only in `handleChild` without >> triggering `handleDiv`. >> >> Is there any suggestions? >> >> -- >> 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/m2a6w6zwxu.fsf%40163.com.