;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (require 'cl-lib) (defvar esxml--css-selector-token-matchers (byte-code "\306\307\310\311\312\"\311\313 \"\311\314\n\f#\311\315\n\f# \316!\311\317 \n\f$\"\311\320 \n\f$#\311\321  #\311\322  #$\311\323 \"%\324\325\311\326\"##B\327B\330\311\331%\"B\332\311\333\"B\334!B\335\311\336!$#. B\337BBBBBBB\207" [h nl nonascii unicode escape nmstart "[0-9a-f]" "\n\\| \n\\| \\|\f" "[\200-􏿿]" format "\\\\%s\\{1,6\\}[ \n\f]?" "\\(?:%s\\)\\|\\\\[ -~\200-􏿿]" "[a-z_]\\|%s\\|\\(?:%s\\)" "[a-z0-9_-]\\|%s\\|\\(?:%s\\)" "[0-9]+\\|[0-9]*\\.[0-9]+" "\"\\(?:[ !#$%%&(-~]\\|\\\\\\(?:%s\\)\\|'\\|%s\\|\\(?:%s\\)\\)*\"" "'\\(?:[ !#$%%&(-~]\\|\\\\\\(?:%s\\)\\|\"\\|%s\\|\\(?:%s\\)\\)*'" "[-]?\\(?:%s\\)\\(?:%s\\)*" "[-]?\\(?:%s\\)\\(?:%s\\)+" "\\(?:%s\\)+" (whitespace . "[ \n\f]+") string "\\(?:%s\\|%s\\)" ident hash "#%s" function "%s(" number dimension "\\(?:%s\\)%s" ((prefix-match . "\\^=") (suffix-match . "\\$=") (substring-match . "\\*=") (include-match . "~=") (dash-match . "|=") (comma . ",") (gt . ">") (plus . "\\+") (minus . "-") (tilde . "~") (asterisk . "\\*") (period . "\\.") (equals . "=") (colon . ":") (lbracket . "\\[") (rbracket . "\\]") (rparen . ")")) nmchar num string1 string2 unit name] 11)) (defalias 'esxml--tokenize-css-selector #[(string) "\306\307\310\311\"r q\210\312\216\nc\210eb\210m\204v\313\306 \306\211\203]@\211@A\314!\203S\315\313!\211G\211\fV\203RB**A\211\204%* \204i\316\317`d{\"\210 B`\f\\b\210*\202+\237)\207" [result #1=#:temp-buffer string longest max-length esxml--css-selector-token-matchers nil generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] 0 looking-at match-string error "Invalid token detected: %s" matcher --dolist-tail-- re id token length] 5]) #@184 Returns escaped version of STRING for use in selectors. The logic used here corresponds to the CSS.escape API as specified in https://drafts.csswg.org/cssom/#the-css.escape()-method. (defalias 'esxml-query-css-escape #[(string) "\306 G\307\n W\203A \nH\211\310Y\203\f\311X\206 \f\312U\f\313Y\f\314Y\205/\f\315X\f\316Y\205:\f\317X\f\320Y\205E\f\321X\f\307U\203T\322B\2028 \203\323\324\f\"\325\306\"\262\306\211\203{@\211BA\211\204j*\2028\n\307U\203\261\203\261\323\324\f\"\325\306\"\262\306\211\203\255@\211BA\211\204\234*\2028\n\310U\203\353\203\353 \307H\326U\203\353\323\324\f\"\325\306\"\262\306\211\203\347@\211BA\211\204\326*\2028\n\307U\203 \f\326U\203  G\310U\203 \327B\fB\2028\204)\f\326U\204)\f\330U\204)\204)\204)\2030\fB\2028\327B\fB.\nT\211\202*\237\260)\207" [chars string i --dotimes-limit-- char unprintablep nil 0 1 31 127 128 48 57 65 90 97 122 65533 format "\\%x " append 45 92 95 nonasciip digitp upperp lowerp --dolist-tail--] 5 (#$ . 1903)]) (defalias 'esxml--parse-css-identifier #[(string) "\306\307\"\262\307\211 \203\370 \211A\242\211\310U\203\360 \211A\242\211\203\354\f\311U\204\354\f\312Y\2038\f\313X\204P\f\314Y\203D\f\315X\204P\f\316Y\203\350\f\317X\203\350\320\fC\211\321W\203\237 \203\237 @\211\312Y\203o\f\313X\204\207\f\314Y\203{\f\315X\204\207\f\316Y\203\222\f\317X\203\222 \211A\242 B\202\225\321)T\211\202W @\211\203\257\f\322U\203\257 A) \237\260\323\324\"\211\320U\204\330\325Y\203\321\326X\204\330\327V\203\337\330\nB\202\344\nB,\202\354\f\nB)\202\364\f\nB)\202\f\n\237\260+\207" [string code-points chars token char hex-chars append nil 92 10 48 57 97 102 65 70 0 5 32 string-to-number 16 55296 57343 1114111 65533 i hex-token code-point] 5]) (defalias 'esxml--parse-css-string-literal #[(string) "\301\302\303O!\207" [string esxml--parse-css-identifier 1 -1] 4]) (defalias 'esxml--with-parse-shorthands '(macro . #[(&rest body) "\301\302BB\207" [body cl-macrolet ((peek nil '(car esxml--token-stream)) (next nil '(pop esxml--token-stream)) (accept (type) `(and (peek) (eq (car (peek)) ,type) (cdr (next)))) (eat-whitespace nil '(while (accept 'whitespace))))] 3])) (put 'esxml--with-parse-shorthands 'edebug-form-spec '(body)) #@187 Parse CSS selector STRING into a list of alists. Each alist represents a complex CSS selector. The result can be passed to `esxml-query' and `esxml-query-all' as the selector argument. (defalias 'esxml-parse-css-selector #[(string) "\303!\304  \203\305\306\307\310 \311#\"\210\n*\207" [string esxml--token-stream result esxml--tokenize-css-selector esxml--parse-css-selector-list error "Trailing garbage: %s" mapconcat cdr ""] 6 (#$ . 4276)]) (defalias 'esxml--parse-css-selector-list #[nil "\304 \305\211\204 \306\307!\210 B\n@\203P\n@@\310=\203P\n\211A\242A\203P\n@\203=\n@@\311=\203=\n\211A\242A\204'\304 \211\204H\306\312!\210 B)\202\237*\207" [result first esxml--token-stream selector esxml--parse-complex-css-selector nil error "Expected at least one selector" comma whitespace "Expected selector after comma"] 3]) (defalias 'esxml--parse-complex-css-selector #[nil "\306 \307\211\211\205C\n B\204A\310 \211\203;\306 \211\203+\311\f D \"\2027 @@\312=\2047\313\314!\210)\202=\315)\202 \237+\207" [done result first combinator compound esxml--token-stream esxml--parse-compound-css-selector nil esxml--parse-css-combinator append comma error "Trailing combinator" t] 4]) (defalias 'esxml--parse-css-combinator #[nil "@@\304=\305@\203@@\304=\203\211A\242A\204@@\211\306>\203VA \307\267\202=\310\202=\311\202=\312@\203\\@@\304=\203\\\211A\242A\204=\202\\\n\203\\\313) *\207" [esxml--token-stream result leading-whitespace-p type whitespace nil (gt plus tilde) #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (gt 49 plus 54 tilde 59)) ((combinator . child)) ((combinator . direct-sibling)) ((combinator . indirect-sibling)) ((combinator . descendant))] 3]) (defalias 'esxml--parse-compound-css-selector #[nil "\304 \305\211\211\203\nB\202#\306 \211\203 B\202\"\307) \204;\306 \211\2035 B\2027\307)\202#\310\311\312\313$\314V\203J\315\316!\210\237+\207" [result done type-selector modifier esxml--parse-css-type-selector nil esxml--parse-css-modifier t cl-count id :key car 1 error "Only one id selector allowed per compound"] 6]) (defalias 'esxml--parse-css-type-selector #[nil "@\211@\302=\203A\303\304\305 A!!B\202' @\306=\203&A\307\202'\310)\207" [esxml--token-stream token ident tag intern esxml--parse-css-identifier asterisk (wildcard) nil] 5]) (defalias 'esxml--parse-css-modifier #[nil "\300 \206\301 \206\302 \206\303 \207" [esxml--parse-css-id esxml--parse-css-class esxml--parse-css-attrib esxml--parse-css-pseudo] 1]) (defalias 'esxml--parse-css-id #[nil "@\205@@\302=\205\211A\242A\211\205\303 \304\305OB)\207" [esxml--token-stream value hash id 1 nil] 5]) (defalias 'esxml--parse-css-class #[nil "@\2058@@\302=\2058\211A\242A\2058@\205)@@\303=\205)\211A\242A\211\2034\304 B\2027\305\306!)\207" [esxml--token-stream value period ident class error "Expected identifier after period"] 3]) (defalias 'esxml--parse-css-attrib #[nil "\305 @\205\251 @@\306=\205\251 \211A\242A\205\251 @\203. @@\307=\203. \211A\242A\204\310 \211\2049\311\312!\210\302\313\n!BB @\203W @@\314=\203W \211A\242A\204\244\315 \211\204b\311\316!\210\317 \211\204m\311\320!\210 @\203\203 @@\307=\203\203 \211A\242A\204m @\203\231 @@\314=\203\231 \211A\242A\204\235\311\321!\210 \fBB*)\322\237B)\207" [result esxml--token-stream name match value nil lbracket whitespace esxml--parse-css-attrib-name error "Expected attribute name" esxml--parse-css-identifier rbracket esxml--parse-css-attrib-match "Expected attribute matcher" esxml--parse-css-attrib-value "Expected attribute value" "Unterminated attribute" attribute] 4]) (defalias 'esxml--parse-css-attrib-name #[nil "@\205@@\302=\205\211A\242A\211\205/@\203.@@\303=\203.\211A\242A\204 )\207" [esxml--token-stream name ident whitespace] 3]) (defalias 'esxml--parse-css-attrib-match #[nil "\302 @\203 @@\303=\203 \211A\242A\203\304\202\241 @\2038 @@\305=\2038 \211A\242A\2038\305\202\241 @\203S @@\306=\203S \211A\242A\203S\306\202\241 @\203n @@\307=\203n \211A\242A\203n\307\202\241 @\203\211 @@\310=\203\211 \211A\242A\203\211\310\202\241 @\203\241 @@\311=\203\241 \211A\242A\203\241\311 @\203\267 @@\312=\203\267 \211A\242A\204\241)\207" [result esxml--token-stream nil equals exact-match prefix-match suffix-match substring-match include-match dash-match whitespace] 2]) (defalias 'esxml--parse-css-attrib-value #[nil "@\211@\302=\203A\303 A!\202& @\304=\203%A\305 A!\202&\306)\207" [esxml--token-stream token ident esxml--parse-css-identifier string esxml--parse-css-string-literal nil] 3]) (defalias 'esxml--parse-css-pseudo #[nil "\306\211\n@\205\220\n@@\307=\205\220\n\211A\242A\205\220\n@\2035\n@@\307=\2035\n\211A\242A\2035\310\2027\311\312 \211\203c\311=\203\\ @ A\313\314 !B B\304\fB B*\202\213\315\316!\210\202\213\n@\205v\n@@\317=\205v\n\211A\242A\211\203\206\313\314 !B B\202\212\315\320!\210)) \237B*\207" [type result esxml--token-stream functional args value nil colon pseudo-element pseudo-class esxml--parse-css-functional-pseudo name esxml--parse-css-identifier error "Pseudo-elements may not have arguments" ident "Expected function or identifier"] 4]) (defalias 'esxml--parse-css-functional-pseudo #[nil "@\205@@\302=\205\211A\242A\305\211\205\251\n\306\307O B@\2037@@\310=\2037\211A\242A\204!\311 \305@\203R@@\310=\203R\211A\242A\204<\f\204Z\312\313!\210\f B \204\214\311 \211\203\206\f B@\203^@@\310=\203^\211A\242A\204m\202^\314\211\203b*@\203\243@@\315=\203\243\211A\242A\204\247\312\316!\210 \237*\207" [esxml--token-stream result function done expression nil 0 -1 whitespace esxml--parse-css-expression error "Expected at least one expression for function" t rparen "Unterminated function argument list"] 4]) (defalias 'esxml--parse-css-expression #[nil "@@\203@@\302=\203\211A\242A\203\303\202\204@\2037@@\304=\2037\211A\242A\2037\305\202\204 @\306=\203JA\306\307 A!B\202\204 @\310=\203]A\310\311 A!B\202\204 @\312=\203pA\312\313 A!B\202\204 @\314=\203\203A\314\307 A!B\202\204\315)\207" [esxml--token-stream token plus (operator . +) minus (operator . -) dimension esxml--parse-css-identifier number string-to-number string esxml--parse-css-string-literal ident nil] 3]) #@44 Non-nil if NODE refers to an esxml branch. (defalias 'esxml-branch-p #[(node) "<\205G\301Y\205@9\205A@<\207" [node 2] 2 (#$ . 10729)]) #@39 Returns the tag of NODE if available. (defalias 'esxml-node-tag #[(node) "\301!\205@\207" [node esxml-branch-p] 2 (#$ . 10880)]) #@46 Returns the attributes of NODE if available. (defalias 'esxml-node-attributes #[(node) "\301!\205 A@\207" [node esxml-branch-p] 2 (#$ . 11019)]) #@55 Returns the attribute ATTRIBUTE of NODE if available. (defalias 'esxml-node-attribute #[(attribute node) "\302!\205\f A@\236A\207" [node attribute esxml-branch-p] 2 (#$ . 11173)]) #@44 Returns the children of NODE if available. (defalias 'esxml-node-children #[(node) "\301!\205 AA\207" [node esxml-branch-p] 2 (#$ . 11362)]) #@91 Locates a node satisfying PRED starting from ROOT. Returns the node or nil if none found. (defalias 'esxml-find-node #[(pred root) " !\203 \207\302\303\304 !\"\207" [pred root cl-some #[(node) "\302 \"\207" [pred node esxml-find-node] 3] esxml-node-children] 4 (#$ . 11512)]) #@61 Visit nodes by calling FUNCTION on each starting from ROOT. (defalias 'esxml-visit-nodes #[#'root " !\210\302\303\304 !\"\207" [function root mapc #[(node) "\302 \"\207" [function node esxml-visit-nodes] 3] esxml-node-children] 4 (#$ . 11798)]) #@105 Locates all nodes satisfying PRED starting from ROOT. Returns a list of the nodes or nil if none found. (defalias 'esxml-find-nodes #[(pred root) "\302\303\304 \"\210\237)\207" [acc root nil esxml-visit-nodes #[(node) " !\205 \nB\211\207" [pred node acc] 2]] 3 (#$ . 12052)]) #@102 Locates a node satisfying PRED starting from ROOT's children. Returns the node or nil if none found. (defalias 'esxml-find-descendant #[(pred root) "\301\302\303!\"\207" [root cl-some #[(node) "\302 \"\207" [pred node esxml-find-node] 3] esxml-node-children] 4 (#$ . 12341)]) #@116 Locates all nodes satisfying PRED starting from ROOT's children. Returns a list of the nodes or nil if none found. (defalias 'esxml-find-descendants #[(pred root) "\301\302\303!\"\207" [root cl-mapcan #[(node) "\302 \"\207" [pred node esxml-find-nodes] 3] esxml-node-children] 4 (#$ . 12626)]) #@94 Locates a node satisfying PRED among ROOT's children. Returns the node or nil if none found. (defalias 'esxml-find-child #[(pred root) "\301\302\303!\"\207" [root cl-some #[(node) " !\205 \207" [pred node] 2] esxml-node-children] 4 (#$ . 12928)]) #@108 Locates all nodes satisfying PRED among ROOT's children. Returns a list of the nodes or nil if none found. (defalias 'esxml-find-children #[(pred root) "\301\302\303!\"\207" [root mapcar #[(node) " !\205 \207" [pred node] 2] esxml-node-children] 4 (#$ . 13186)]) (defalias 'esxml--node-with-children #[(node children) "\304!\305!\306\n D \"*\207" [node attributes tag children esxml-node-tag esxml-node-attributes append] 3]) (defalias 'esxml--node-with-attributes #[(node attributes) "\304!\305!\306\n D \"*\207" [node children tag attributes esxml-node-tag esxml-node-children append] 3]) #@60 Returns a copy of ROOT with FUNCTION applied to each node. (defalias 'esxml-tree-map #[#'root "\302!\203\303 !\304\305\306!\"\"\207 !\207" [root function esxml-branch-p esxml--node-with-children mapcar #[(node) "\302 \"\207" [function node esxml-tree-map] 3] esxml-node-children] 6 (#$ . 13795)]) (defvar esxml--symbol (make-symbol "id")) (defalias 'esxml--decorate-tree #[(root) "\302\303\304 \")\207" [i root 0 esxml-tree-map #[(node) " B\305\n!\306\fC \" T\307\n!\203\310\n \"\202\n*\207" [esxml--symbol i node attributes attribute esxml-node-attributes append esxml-branch-p esxml--node-with-attributes] 3]] 3]) (defalias 'esxml--undecorate-node #[(node) "\303!\203\304!\305\306\n \"\")\207\207" [node attributes esxml--symbol esxml-branch-p esxml-node-attributes esxml--node-with-attributes assq-delete-all] 5]) (defalias 'esxml--retrieve-decoration #[(node) "\302 \"\207" [esxml--symbol node esxml-node-attribute] 3]) (defalias 'esxml--node-matches-attribute-p #[(node modifier) "\304!\305\306\307 \"*\207" [node haystack attributes modifier esxml-node-attributes nil cl-every #[(item) "@A\211\306\267\202f\307 ! \236\211A\f)\202i \232\202i\310 \"\202i\311 \"\202i\312 ! \313\314\315#)\266\203\202i \316 \317\"\235\202i \232\206i\320\321\312 !\" \313\314\315#)\266\203\202i\322\323!*\207" [item value type attributes match haystack #s(hash-table size 7 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (name 12 exact-match 26 prefix-match 32 suffix-match 39 substring-match 46 include-match 65 dash-match 74)) intern string-prefix-p string-suffix-p regexp-quote nil t string-match split-string " " format "^%s-" error "Unknown attribute modifier" inhibit-changing-match-data] 8]] 3]) (defalias 'esxml--node-matches-modifier-p #[(node type value) "\304\267\202+\305\207\306 !\n\232\207\307\310 \"\n\232\207\307\303 \"\211\205$\n\311 \312\"\235)\207\313 \n\"\207\314\315\"\207" [type node value class #s(hash-table size 5 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (wildcard 6 tag 8 id 14 class 21 attribute 38)) t esxml-node-tag esxml-node-attribute id split-string " " esxml--node-matches-attribute-p error "Unimplemented attribute type: %s"] 5]) (defalias 'esxml--find-node-for #[(attributes) "\300\207" [#[(node) "\301\302\"\207" [attributes cl-every #[(attribute) "@A\304 \n #*\207" [attribute value type node esxml--node-matches-modifier-p] 4]] 3]] 1]) (defalias 'esxml--find-nodes #[(root combinator attributes) "\300\236A\211\204 \305\202 \306\267\202\307\202\310\202\311\312\"\211\313 !\f\"*\207" [combinator type walker attributes root esxml-find-nodes #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (descendant 19 child 23)) esxml-find-descendants esxml-find-children error "Unimplemented combinator %s" esxml--find-node-for] 4]) (defalias 'esxml--query #[(selector root) "\211A\242\305\306 \305 #\211\2030\2030\211A\242\211A\242\307\310\f\"\311\305\f\"\211\204\f+\207" [selector attributes combinator root result nil esxml--find-nodes cl-mapcan #[(node) "\303 \n#\207" [node combinator attributes esxml--find-nodes] 4] delq] 5]) (defalias 'esxml--delete-dups #[(items test) "\305\306\"\307 \203& \211A\242\310\f\n\"\204\"\f B\311\f\312\n#\210)\202 \237*\207" [test result seen items item make-hash-table :test nil gethash puthash t] 4]) #@227 Locates all nodes satisfying SELECTOR starting from ROOT. SELECTOR must be a string containing a CSS selector or a parsed CSS selector returned by `esxml-parse-css-selector'. Returns a list of the nodes or nil if none found. (defalias 'esxml-query-all #[(selector root) ";\203 \303!G\304U\203\305\306@ \"\307\"\207\310 !\311\2031\n\306\211A\242 \"\244\202\312\n\313\314\315$\316\n\317\320\314\315%\321\322\n\")\207" [selector root result esxml-parse-css-selector 1 esxml--delete-dups esxml--query eq esxml--decorate-tree nil cl-sort < :key esxml--retrieve-decoration cl-delete-duplicates :test = mapcar #[(node) "\301!\207" [node esxml--undecorate-node] 2]] 6 (#$ . 17238)]) #@213 Locates a node satisfying SELECTOR starting from ROOT. SELECTOR must be a string containing a CSS selector or a parsed CSS selector returned by `esxml-parse-css-selector'. Returns the node or nil if none found. (defalias 'esxml-query #[(selector root) "\302 \"@\207" [selector root esxml-query-all] 3 (#$ . 17941)]) (provide 'esxml-query)