fork(1) download
  1. #!/bin/bash
  2.  
  3. awk 'BEGIN { RS=ORS="===="}
  4. /(^|\n)\.[^\n]*\n\[%collapsible]/{
  5. sub(/(^|\n)\.[^\n]*\n\[%collapsible]/, ""); print; p=1; next }
  6. !(p && p--)'
Success #stdin #stdout 0.01s 5308KB
stdin
here is some text
====
foo
====
bar
====
Some text to keep
.Click here to reveal the spoiler
[%collapsible]
====
This is the answer
====
more foo
====
more bar
.not a match
because not collapsible
====
not a match because no dot
[%collapsible] not really
foo bar baz
ick poo
====
this is the end
stdout
here is some text
====
foo
====
bar
====
Some text to keep
====
more foo
====
more bar
.not a match
because not collapsible
====
not a match because no dot
[%collapsible] not really
foo bar baz
ick poo
====
this is the end====