Last active
November 23, 2022 10:45
-
-
Save JJ/c68db9e890b12b96445da76b17a1b51c to your computer and use it in GitHub Desktop.
Find items in a markdown list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Text::Markdown; | |
use JSON::Tiny; | |
sub MAIN( Str $letter-to-santa = 'letters/dear-santa-list.md' ) { | |
my $letter = Text::Markdown::Document.new($letter-to-santa.IO.slurp()); | |
my $flip = False; | |
my $list = $letter.items | |
.grep( { $flip = ( $flip | |
or so ($^þ ~~ Text::Markdown::Heading | |
and $^þ.level == 2 | |
and $^þ.text ~~ m/<[Rr]>equest/) ) } ) | |
.grep( { $^þ ~~ Text::Markdown::List }) | |
.map( {$^þ.items} ).flat | |
.map( {$^þ.items} ).flat | |
.map( {$^þ.items} ).flat; | |
say to-json $list ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment