File: RELEASE_DRAFT_FILTER.lua

package info (click to toggle)
plover 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,356 kB
  • sloc: python: 21,589; sh: 682; ansic: 25; makefile: 11
file content (36 lines) | stat: -rw-r--r-- 988 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- Keep only the blocks that belong to the first level-1 section (release),
-- but drop the level-1 header itself.

local in_first_release = false
local past_first_release = false

return {
  {
    Header = function(h)
      if h.level == 1 then
        if not in_first_release and not past_first_release then
          -- Enter the first release; drop this H1 itself
          in_first_release = true
          return {}
        else
          -- Any subsequent H1 ends the first release; drop it and everything after
          past_first_release = true
          return {}
        end
      end
      -- For subheaders inside the first release, keep them; otherwise drop
      if past_first_release or not in_first_release then
        return {}
      end
      return h
    end,

    Block = function(b)
      -- Drop everything before the first H1 and after the next H1
      if past_first_release or not in_first_release then
        return {}
      end
      return b
    end,
  }
}