Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created February 4, 2021 20:21
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 baweaver/2f6e1e80cbe667fab9bd67b4c043853d to your computer and use it in GitHub Desktop.
Save baweaver/2f6e1e80cbe667fab9bd67b4c043853d to your computer and use it in GitHub Desktop.
# Pattern to match a link: <a/>
node in { name: 'a' }
# Pattern for a link with a class: <a class="foo"/>
node in { name: 'a', class: 'foo' }
# Pattern to select that link: <a class="foo">{.}</a>
node => { name: 'a', class: 'foo', children: }
# Pattern to select the target URL: <a class="foo" href="{.}"/>
node => { name: 'a', href: }
# Pattern for multiple links: <a class="foo" href="{.}"/>+
nodes => [*, { name: 'a', href: => link_one }, { name: 'a', href: => link_two } *]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment