Skip to content

Instantly share code, notes, and snippets.

@evan-brass
Created December 25, 2020 22:29
Show Gist options
  • Save evan-brass/06af0dafa2e41c68a38eb05ee15bb165 to your computer and use it in GitHub Desktop.
Save evan-brass/06af0dafa2e41c68a38eb05ee15bb165 to your computer and use it in GitHub Desktop.
function parse_attributes(cursor) {
while(pull(/^\s+([a-zA-Z][a-zA-Z0-9\-]+)="([^"]*)"/, (
name,
value
) => {
cursor.attributes[name] = value;
})) {}
if (!pull(/^\s*>/)) {
throw new Error("Malformed open tag");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment