public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: EBkysko <ebkysko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: ignore section & content in output
Date: Mon, 11 Feb 2019 15:27:25 -0800 (PST)	[thread overview]
Message-ID: <b4c57563-7c47-4b1d-accd-2bdaf2e39e75@googlegroups.com> (raw)
In-Reply-To: <717bc9dc-b99a-4472-9965-1c84a737fc01-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1717 bytes --]

Your filter looks good, except that any subsection of the "marked" section 
will remain present... but perhaps that's what you want.

If not, or if anyone else would like to remove all subsections of that 
section, the following seems to work:

local looking_at_section = false
local remove = {}
local lvl = 0

function Block (elem)
  if looking_at_section then
    remove[#remove + 1] = elem
    return {}
  end
end

function Header (elem)
  if elem.identifier == 'remove' then
    looking_at_section = true
    lvl = elem.level
    return {}
  else
    looking_at_section = looking_at_section and elem.level > lvl
    if looking_at_section then
      remove[#remove + 1] = elem
      return {}
    end
  end
end

The original filter has the same problem... but an abstract usually doesn't 
have subsections/sublevels (I think).

Note also that usually an identifier should identify only one element, and 
pandoc will (rightly) be annoyed when there's more than one header with the 
same ID.
A class would be ideal for this situation, and one might then use `if 
elem.classes:includes('remove',1)` rather than `if elem.identifier == 
'remove'`

-- 
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/b4c57563-7c47-4b1d-accd-2bdaf2e39e75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 9558 bytes --]

  parent reply	other threads:[~2019-02-11 23:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09 18:55 Colin McLear
     [not found] ` <bbe3cee2-f65b-41c2-a1e0-04eceedd463f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-02-09 21:40   ` Albert Krewinkel
     [not found]     ` <87a7j4iqtc.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2019-02-11  5:17       ` Colin McLear
2019-02-11 17:48   ` Colin McLear
     [not found]     ` <717bc9dc-b99a-4472-9965-1c84a737fc01-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-02-11 23:27       ` EBkysko [this message]
     [not found]         ` <b4c57563-7c47-4b1d-accd-2bdaf2e39e75-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-02-12 22:47           ` Colin McLear
     [not found]             ` <5a59f103-d049-453e-b677-d85a2a2d3a76-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-02-13  0:00               ` EBkysko
     [not found]                 ` <50ee8006-c909-4b7f-a81b-98d83c2a4aa9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-02-13  1:13                   ` EBkysko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4c57563-7c47-4b1d-accd-2bdaf2e39e75@googlegroups.com \
    --to=ebkysko-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).