From be18757492c8a3358e4dffc6ab7520b616fd6ed9 Mon Sep 17 00:00:00 2001 From: "perlancar (@pc-home)" Date: Sat, 3 Jan 2015 11:39:24 +0700 Subject: [PATCH] Add option: --with-preamble --- lib/App/FilterOrgByHeadlines.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/App/FilterOrgByHeadlines.pm b/lib/App/FilterOrgByHeadlines.pm index 332a589..90b7247 100644 --- a/lib/App/FilterOrgByHeadlines.pm +++ b/lib/App/FilterOrgByHeadlines.pm @@ -113,6 +113,13 @@ _ "Don't include headline content, just print the headlines", default => 1, }, + with_preamble => { + schema => 'bool', + summary => 'Include text before any headline', + 'summary.alt.bool.not' => + "Don't include text before any headline", + default => 1, + }, }, result_naked => 1, result => { @@ -122,8 +129,9 @@ _ sub filter_org_by_headlines { my %args = @_; - my $input = $args{input}; - my $with_ct = $args{with_content} // 1; + my $input = $args{input}; + my $with_ct = $args{with_content} // 1; + my $with_pre = $args{with_preamble} // 1; my $curhl; my $curlevel; @@ -177,7 +185,7 @@ sub filter_org_by_headlines { my $include; FILTER: { if (!$curhl) { - $include++; + $include++ if $with_pre; last FILTER; } last if !$with_ct && !$is_hl;