Skip to content

Instantly share code, notes, and snippets.

@titsuki
Created December 3, 2017 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save titsuki/49981e506424208b40a84e8c69909d98 to your computer and use it in GitHub Desktop.
Save titsuki/49981e506424208b40a84e8c69909d98 to your computer and use it in GitHub Desktop.
class Infobox::Actions {
method TOP($/) { make $<infobox>.made }
method infobox($/) {
make %( name => $<name>.made, propertylist => $<propertylist>.made )
}
method name($/) { make ~$/.trim }
method propertylist($/) {
make $<property>>>.made
}
method property($/) {
make $<key>.made => $<value>.made
}
method key-content($/) { make $/.trim }
method value-content-list($/) {
make $<value-content>>>.made
}
method value-content($/) { # (#1)
my $rawtext = $<rawtext>>>.made>>.trim.grep({ $_ ne "" });
make %(
anchortext => $<anchortext>>>.made,
weblink => $<weblink>>>.made,
rawtext => $rawtext.elems == 0 ?? $[] !! $rawtext.Array
);
}
method anchortext($/) {
make ~$/;
}
method weblink($/) {
make ~$/;
}
method rawtext($/) {
make ~$/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment