nokolexbor 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/nokolexbor/config.h +186 -0
- data/ext/nokolexbor/extconf.rb +131 -0
- data/ext/nokolexbor/libxml/HTMLparser.h +320 -0
- data/ext/nokolexbor/libxml/SAX2.h +173 -0
- data/ext/nokolexbor/libxml/chvalid.h +230 -0
- data/ext/nokolexbor/libxml/debugXML.h +217 -0
- data/ext/nokolexbor/libxml/dict.h +81 -0
- data/ext/nokolexbor/libxml/encoding.h +232 -0
- data/ext/nokolexbor/libxml/entities.h +153 -0
- data/ext/nokolexbor/libxml/globals.h +529 -0
- data/ext/nokolexbor/libxml/hash.h +236 -0
- data/ext/nokolexbor/libxml/list.h +137 -0
- data/ext/nokolexbor/libxml/parser.h +1264 -0
- data/ext/nokolexbor/libxml/parserInternals.h +641 -0
- data/ext/nokolexbor/libxml/pattern.h +100 -0
- data/ext/nokolexbor/libxml/threads.h +94 -0
- data/ext/nokolexbor/libxml/tree.h +1315 -0
- data/ext/nokolexbor/libxml/uri.h +94 -0
- data/ext/nokolexbor/libxml/valid.h +448 -0
- data/ext/nokolexbor/libxml/xmlIO.h +369 -0
- data/ext/nokolexbor/libxml/xmlautomata.h +146 -0
- data/ext/nokolexbor/libxml/xmlerror.h +919 -0
- data/ext/nokolexbor/libxml/xmlexports.h +79 -0
- data/ext/nokolexbor/libxml/xmlmemory.h +226 -0
- data/ext/nokolexbor/libxml/xmlregexp.h +222 -0
- data/ext/nokolexbor/libxml/xmlstring.h +140 -0
- data/ext/nokolexbor/libxml/xmlversion.h +526 -0
- data/ext/nokolexbor/libxml/xpath.h +575 -0
- data/ext/nokolexbor/libxml/xpathInternals.h +632 -0
- data/ext/nokolexbor/libxml/xpointer.h +137 -0
- data/ext/nokolexbor/libxml.h +76 -0
- data/ext/nokolexbor/memory.c +39 -0
- data/ext/nokolexbor/nl_document.c +51 -0
- data/ext/nokolexbor/nl_node.c +790 -0
- data/ext/nokolexbor/nl_node_set.c +368 -0
- data/ext/nokolexbor/nl_xpath_context.c +200 -0
- data/ext/nokolexbor/nokolexbor.c +63 -0
- data/ext/nokolexbor/nokolexbor.h +37 -0
- data/ext/nokolexbor/private/buf.h +70 -0
- data/ext/nokolexbor/private/dict.h +11 -0
- data/ext/nokolexbor/private/enc.h +17 -0
- data/ext/nokolexbor/private/error.h +21 -0
- data/ext/nokolexbor/private/globals.h +9 -0
- data/ext/nokolexbor/private/memory.h +9 -0
- data/ext/nokolexbor/private/parser.h +27 -0
- data/ext/nokolexbor/private/string.h +9 -0
- data/ext/nokolexbor/private/threads.h +50 -0
- data/ext/nokolexbor/private/tree.h +18 -0
- data/ext/nokolexbor/private/xpath.h +7 -0
- data/ext/nokolexbor/timsort.h +601 -0
- data/ext/nokolexbor/xml_SAX2.c +80 -0
- data/ext/nokolexbor/xml_buf.c +363 -0
- data/ext/nokolexbor/xml_chvalid.c +334 -0
- data/ext/nokolexbor/xml_dict.c +1264 -0
- data/ext/nokolexbor/xml_encoding.c +124 -0
- data/ext/nokolexbor/xml_error.c +134 -0
- data/ext/nokolexbor/xml_globals.c +1085 -0
- data/ext/nokolexbor/xml_hash.c +1141 -0
- data/ext/nokolexbor/xml_memory.c +203 -0
- data/ext/nokolexbor/xml_parser.c +127 -0
- data/ext/nokolexbor/xml_parserInternals.c +338 -0
- data/ext/nokolexbor/xml_pattern.c +2375 -0
- data/ext/nokolexbor/xml_string.c +1051 -0
- data/ext/nokolexbor/xml_threads.c +881 -0
- data/ext/nokolexbor/xml_tree.c +148 -0
- data/ext/nokolexbor/xml_xpath.c +14743 -0
- data/lib/nokolexbor/attribute.rb +18 -0
- data/lib/nokolexbor/document.rb +6 -0
- data/lib/nokolexbor/node.rb +264 -0
- data/lib/nokolexbor/node_set.rb +124 -0
- data/lib/nokolexbor/version.rb +5 -0
- data/lib/nokolexbor/xpath_context.rb +14 -0
- data/lib/nokolexbor.rb +17 -0
- data/patches/0001-lexbor-support-text-pseudo-element.patch +137 -0
- data/patches/0002-lexbor-match-id-class-case-sensitive.patch +22 -0
- data/patches/0003-lexbor-attach-template-content-to-self.patch +13 -0
- data/vendor/lexbor/CMakeLists.txt +331 -0
- data/vendor/lexbor/config.cmake +890 -0
- data/vendor/lexbor/feature.cmake +134 -0
- data/vendor/lexbor/source/lexbor/core/array.c +208 -0
- data/vendor/lexbor/source/lexbor/core/array.h +100 -0
- data/vendor/lexbor/source/lexbor/core/array_obj.c +216 -0
- data/vendor/lexbor/source/lexbor/core/array_obj.h +134 -0
- data/vendor/lexbor/source/lexbor/core/avl.c +442 -0
- data/vendor/lexbor/source/lexbor/core/avl.h +82 -0
- data/vendor/lexbor/source/lexbor/core/base.h +86 -0
- data/vendor/lexbor/source/lexbor/core/bst.c +468 -0
- data/vendor/lexbor/source/lexbor/core/bst.h +108 -0
- data/vendor/lexbor/source/lexbor/core/bst_map.c +238 -0
- data/vendor/lexbor/source/lexbor/core/bst_map.h +87 -0
- data/vendor/lexbor/source/lexbor/core/config.cmake +12 -0
- data/vendor/lexbor/source/lexbor/core/conv.c +203 -0
- data/vendor/lexbor/source/lexbor/core/conv.h +53 -0
- data/vendor/lexbor/source/lexbor/core/core.h +35 -0
- data/vendor/lexbor/source/lexbor/core/def.h +57 -0
- data/vendor/lexbor/source/lexbor/core/diyfp.c +153 -0
- data/vendor/lexbor/source/lexbor/core/diyfp.h +258 -0
- data/vendor/lexbor/source/lexbor/core/dobject.c +187 -0
- data/vendor/lexbor/source/lexbor/core/dobject.h +92 -0
- data/vendor/lexbor/source/lexbor/core/dtoa.c +404 -0
- data/vendor/lexbor/source/lexbor/core/dtoa.h +28 -0
- data/vendor/lexbor/source/lexbor/core/fs.h +60 -0
- data/vendor/lexbor/source/lexbor/core/hash.c +476 -0
- data/vendor/lexbor/source/lexbor/core/hash.h +218 -0
- data/vendor/lexbor/source/lexbor/core/in.c +267 -0
- data/vendor/lexbor/source/lexbor/core/in.h +172 -0
- data/vendor/lexbor/source/lexbor/core/lexbor.h +35 -0
- data/vendor/lexbor/source/lexbor/core/mem.c +228 -0
- data/vendor/lexbor/source/lexbor/core/mem.h +141 -0
- data/vendor/lexbor/source/lexbor/core/mraw.c +428 -0
- data/vendor/lexbor/source/lexbor/core/mraw.h +114 -0
- data/vendor/lexbor/source/lexbor/core/perf.h +45 -0
- data/vendor/lexbor/source/lexbor/core/plog.c +73 -0
- data/vendor/lexbor/source/lexbor/core/plog.h +102 -0
- data/vendor/lexbor/source/lexbor/core/print.c +168 -0
- data/vendor/lexbor/source/lexbor/core/print.h +39 -0
- data/vendor/lexbor/source/lexbor/core/sbst.h +59 -0
- data/vendor/lexbor/source/lexbor/core/serialize.c +27 -0
- data/vendor/lexbor/source/lexbor/core/serialize.h +32 -0
- data/vendor/lexbor/source/lexbor/core/shs.c +118 -0
- data/vendor/lexbor/source/lexbor/core/shs.h +82 -0
- data/vendor/lexbor/source/lexbor/core/str.c +617 -0
- data/vendor/lexbor/source/lexbor/core/str.h +247 -0
- data/vendor/lexbor/source/lexbor/core/str_res.h +369 -0
- data/vendor/lexbor/source/lexbor/core/strtod.c +326 -0
- data/vendor/lexbor/source/lexbor/core/strtod.h +28 -0
- data/vendor/lexbor/source/lexbor/core/types.h +39 -0
- data/vendor/lexbor/source/lexbor/core/utils.c +43 -0
- data/vendor/lexbor/source/lexbor/core/utils.h +36 -0
- data/vendor/lexbor/source/lexbor/css/base.h +44 -0
- data/vendor/lexbor/source/lexbor/css/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/css/css.h +25 -0
- data/vendor/lexbor/source/lexbor/css/log.c +336 -0
- data/vendor/lexbor/source/lexbor/css/log.h +103 -0
- data/vendor/lexbor/source/lexbor/css/node.h +29 -0
- data/vendor/lexbor/source/lexbor/css/parser.c +473 -0
- data/vendor/lexbor/source/lexbor/css/parser.h +368 -0
- data/vendor/lexbor/source/lexbor/css/selectors/base.h +48 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo.c +91 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo.h +66 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_const.h +109 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_res.h +302 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_state.c +279 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_state.h +85 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selector.c +927 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selector.h +200 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selectors.c +340 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selectors.h +137 -0
- data/vendor/lexbor/source/lexbor/css/selectors/state.c +1718 -0
- data/vendor/lexbor/source/lexbor/css/selectors/state.h +79 -0
- data/vendor/lexbor/source/lexbor/css/stylesheet.h +37 -0
- data/vendor/lexbor/source/lexbor/css/syntax/anb.c +443 -0
- data/vendor/lexbor/source/lexbor/css/syntax/anb.h +45 -0
- data/vendor/lexbor/source/lexbor/css/syntax/base.h +33 -0
- data/vendor/lexbor/source/lexbor/css/syntax/parser.c +9 -0
- data/vendor/lexbor/source/lexbor/css/syntax/parser.h +25 -0
- data/vendor/lexbor/source/lexbor/css/syntax/res.h +48 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state.c +2603 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state.h +140 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state_res.h +273 -0
- data/vendor/lexbor/source/lexbor/css/syntax/syntax.c +67 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token.c +618 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token.h +298 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token_res.h +68 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer/error.c +30 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer/error.h +58 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer.c +278 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer.h +121 -0
- data/vendor/lexbor/source/lexbor/dom/base.h +32 -0
- data/vendor/lexbor/source/lexbor/dom/collection.c +97 -0
- data/vendor/lexbor/source/lexbor/dom/collection.h +112 -0
- data/vendor/lexbor/source/lexbor/dom/config.cmake +3 -0
- data/vendor/lexbor/source/lexbor/dom/dom.h +29 -0
- data/vendor/lexbor/source/lexbor/dom/exception.c +18 -0
- data/vendor/lexbor/source/lexbor/dom/exception.h +73 -0
- data/vendor/lexbor/source/lexbor/dom/interface.c +110 -0
- data/vendor/lexbor/source/lexbor/dom/interface.h +88 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr.c +445 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr.h +152 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr_const.h +62 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr_res.h +143 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/cdata_section.c +55 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/cdata_section.h +38 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/character_data.c +110 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/character_data.h +51 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/comment.c +64 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/comment.h +42 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document.c +536 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document.h +243 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_fragment.c +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_fragment.h +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_type.c +125 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_type.h +108 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/element.c +1411 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/element.h +319 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/event_target.c +32 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/event_target.h +34 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/node.c +661 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/node.h +192 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/processing_instruction.c +87 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/processing_instruction.h +66 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/shadow_root.c +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/shadow_root.h +44 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/text.c +63 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/text.h +42 -0
- data/vendor/lexbor/source/lexbor/encoding/base.h +218 -0
- data/vendor/lexbor/source/lexbor/encoding/big5.c +42839 -0
- data/vendor/lexbor/source/lexbor/encoding/config.cmake +12 -0
- data/vendor/lexbor/source/lexbor/encoding/const.h +65 -0
- data/vendor/lexbor/source/lexbor/encoding/decode.c +3193 -0
- data/vendor/lexbor/source/lexbor/encoding/decode.h +370 -0
- data/vendor/lexbor/source/lexbor/encoding/encode.c +1931 -0
- data/vendor/lexbor/source/lexbor/encoding/encode.h +377 -0
- data/vendor/lexbor/source/lexbor/encoding/encoding.c +252 -0
- data/vendor/lexbor/source/lexbor/encoding/encoding.h +475 -0
- data/vendor/lexbor/source/lexbor/encoding/euc_kr.c +53883 -0
- data/vendor/lexbor/source/lexbor/encoding/gb18030.c +47905 -0
- data/vendor/lexbor/source/lexbor/encoding/iso_2022_jp_katakana.c +159 -0
- data/vendor/lexbor/source/lexbor/encoding/jis0208.c +22477 -0
- data/vendor/lexbor/source/lexbor/encoding/jis0212.c +15787 -0
- data/vendor/lexbor/source/lexbor/encoding/multi.h +53 -0
- data/vendor/lexbor/source/lexbor/encoding/range.c +71 -0
- data/vendor/lexbor/source/lexbor/encoding/range.h +34 -0
- data/vendor/lexbor/source/lexbor/encoding/res.c +222 -0
- data/vendor/lexbor/source/lexbor/encoding/res.h +34 -0
- data/vendor/lexbor/source/lexbor/encoding/single.c +13748 -0
- data/vendor/lexbor/source/lexbor/encoding/single.h +116 -0
- data/vendor/lexbor/source/lexbor/html/base.h +44 -0
- data/vendor/lexbor/source/lexbor/html/config.cmake +3 -0
- data/vendor/lexbor/source/lexbor/html/encoding.c +574 -0
- data/vendor/lexbor/source/lexbor/html/encoding.h +106 -0
- data/vendor/lexbor/source/lexbor/html/html.h +107 -0
- data/vendor/lexbor/source/lexbor/html/interface.c +165 -0
- data/vendor/lexbor/source/lexbor/html/interface.h +186 -0
- data/vendor/lexbor/source/lexbor/html/interface_res.h +4449 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/anchor_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/anchor_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/area_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/area_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/audio_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/audio_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/base_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/base_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/body_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/body_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/br_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/br_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/button_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/button_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/canvas_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/canvas_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/d_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/d_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/details_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/details_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/dialog_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/dialog_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/directory_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/directory_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/div_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/div_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/document.c +444 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/document.h +256 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/element.c +64 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/element.h +54 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/embed_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/embed_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/field_set_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/field_set_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/font_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/font_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/form_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/form_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_set_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_set_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/head_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/head_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/heading_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/heading_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/hr_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/hr_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/html_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/html_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/iframe_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/iframe_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/image_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/image_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/input_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/input_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/label_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/label_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/legend_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/legend_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/li_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/li_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/link_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/link_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/map_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/map_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/marquee_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/marquee_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/media_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/media_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/menu_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/menu_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meta_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meta_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meter_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meter_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/mod_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/mod_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/o_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/o_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/object_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/object_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/opt_group_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/opt_group_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/option_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/option_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/output_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/output_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/paragraph_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/paragraph_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/param_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/param_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/picture_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/picture_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/pre_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/pre_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/progress_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/progress_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/quote_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/quote_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/script_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/script_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/select_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/select_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/slot_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/slot_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/source_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/source_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/span_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/span_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/style_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/style_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_caption_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_caption_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_cell_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_cell_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_col_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_col_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_row_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_row_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_section_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_section_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/template_element.c +46 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/template_element.h +38 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/text_area_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/text_area_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/time_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/time_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/title_element.c +133 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/title_element.h +42 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/track_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/track_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/u_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/u_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/unknown_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/unknown_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/video_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/video_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/window.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/window.h +34 -0
- data/vendor/lexbor/source/lexbor/html/node.c +14 -0
- data/vendor/lexbor/source/lexbor/html/node.h +67 -0
- data/vendor/lexbor/source/lexbor/html/parser.c +469 -0
- data/vendor/lexbor/source/lexbor/html/parser.h +170 -0
- data/vendor/lexbor/source/lexbor/html/serialize.c +1510 -0
- data/vendor/lexbor/source/lexbor/html/serialize.h +93 -0
- data/vendor/lexbor/source/lexbor/html/tag.h +103 -0
- data/vendor/lexbor/source/lexbor/html/tag_res.h +2262 -0
- data/vendor/lexbor/source/lexbor/html/token.c +386 -0
- data/vendor/lexbor/source/lexbor/html/token.h +130 -0
- data/vendor/lexbor/source/lexbor/html/token_attr.c +44 -0
- data/vendor/lexbor/source/lexbor/html/token_attr.h +67 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/error.c +28 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/error.h +141 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/res.h +4956 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state.c +2171 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state.h +225 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_comment.c +489 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_comment.h +27 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_doctype.c +1654 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_doctype.h +27 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rawtext.c +303 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rawtext.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rcdata.c +311 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rcdata.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_script.c +1209 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_script.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer.c +499 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer.h +343 -0
- data/vendor/lexbor/source/lexbor/html/tree/active_formatting.c +241 -0
- data/vendor/lexbor/source/lexbor/html/tree/active_formatting.h +117 -0
- data/vendor/lexbor/source/lexbor/html/tree/error.c +26 -0
- data/vendor/lexbor/source/lexbor/html/tree/error.h +114 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_after_body.c +62 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_after_frameset.c +63 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_body.c +82 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_frameset.c +88 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_head.c +222 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/before_head.c +144 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/before_html.c +166 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/foreign_content.c +358 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_body.c +1974 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_caption.c +158 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_cell.c +187 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_column_group.c +194 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_frameset.c +149 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_head.c +374 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_head_noscript.c +121 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_row.c +211 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_select.c +341 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_select_in_table.c +115 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table.c +451 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table_body.c +208 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table_text.c +127 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_template.c +189 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/initial.c +411 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/text.c +61 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode.h +135 -0
- data/vendor/lexbor/source/lexbor/html/tree/open_elements.c +251 -0
- data/vendor/lexbor/source/lexbor/html/tree/open_elements.h +105 -0
- data/vendor/lexbor/source/lexbor/html/tree/template_insertion.c +10 -0
- data/vendor/lexbor/source/lexbor/html/tree/template_insertion.h +100 -0
- data/vendor/lexbor/source/lexbor/html/tree.c +1726 -0
- data/vendor/lexbor/source/lexbor/html/tree.h +431 -0
- data/vendor/lexbor/source/lexbor/html/tree_res.h +111 -0
- data/vendor/lexbor/source/lexbor/ns/base.h +32 -0
- data/vendor/lexbor/source/lexbor/ns/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/ns/const.h +37 -0
- data/vendor/lexbor/source/lexbor/ns/ns.c +154 -0
- data/vendor/lexbor/source/lexbor/ns/ns.h +66 -0
- data/vendor/lexbor/source/lexbor/ns/res.h +97 -0
- data/vendor/lexbor/source/lexbor/ports/posix/config.cmake +11 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/fs.c +236 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/memory.c +33 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/perf.c +158 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/config.cmake +18 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/fs.c +239 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/memory.c +33 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/perf.c +81 -0
- data/vendor/lexbor/source/lexbor/selectors/base.h +30 -0
- data/vendor/lexbor/source/lexbor/selectors/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/selectors/selectors.c +1591 -0
- data/vendor/lexbor/source/lexbor/selectors/selectors.h +71 -0
- data/vendor/lexbor/source/lexbor/tag/base.h +32 -0
- data/vendor/lexbor/source/lexbor/tag/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/tag/const.h +225 -0
- data/vendor/lexbor/source/lexbor/tag/res.h +562 -0
- data/vendor/lexbor/source/lexbor/tag/tag.c +144 -0
- data/vendor/lexbor/source/lexbor/tag/tag.h +123 -0
- data/vendor/lexbor/source/lexbor/utils/base.h +32 -0
- data/vendor/lexbor/source/lexbor/utils/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/utils/http.c +534 -0
- data/vendor/lexbor/source/lexbor/utils/http.h +90 -0
- data/vendor/lexbor/source/lexbor/utils/utils.h +15 -0
- data/vendor/lexbor/source/lexbor/utils/warc.c +817 -0
- data/vendor/lexbor/source/lexbor/utils/warc.h +126 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/pseudo.py +231 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/tmp/const.h +21 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/tmp/res.h +26 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/definitions.py +49 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/token_res.py +54 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/tokenizer_code_map.py +36 -0
- data/vendor/lexbor/version +1 -0
- metadata +542 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nokolexbor
|
4
|
+
class Attribute
|
5
|
+
attr_accessor :name
|
6
|
+
attr_accessor :value
|
7
|
+
|
8
|
+
def initialize(name, value)
|
9
|
+
@name = name
|
10
|
+
@value = value
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :text, :value
|
14
|
+
alias_method :content, :value
|
15
|
+
alias_method :to_s, :value
|
16
|
+
alias_method :to_str, :value
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nokolexbor
|
4
|
+
class Node
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
ELEMENT_NODE = 1
|
8
|
+
ATTRIBUTE_NODE = 2
|
9
|
+
TEXT_NODE = 3
|
10
|
+
CDATA_SECTION_NODE = 4
|
11
|
+
ENTITY_REF_NODE = 5
|
12
|
+
ENTITY_NODE = 6
|
13
|
+
PI_NODE = 7
|
14
|
+
COMMENT_NODE = 8
|
15
|
+
DOCUMENT_NODE = 9
|
16
|
+
DOCUMENT_TYPE_NODE = 10
|
17
|
+
DOCUMENT_FRAG_NODE = 11
|
18
|
+
NOTATION_NODE = 12
|
19
|
+
|
20
|
+
attr_reader :document
|
21
|
+
|
22
|
+
LOOKS_LIKE_XPATH = %r{^(\./|/|\.\.|\.$)}
|
23
|
+
|
24
|
+
def comment?
|
25
|
+
type == COMMENT_NODE
|
26
|
+
end
|
27
|
+
|
28
|
+
def cdata?
|
29
|
+
type == CDATA_SECTION_NODE
|
30
|
+
end
|
31
|
+
|
32
|
+
def processing_instruction?
|
33
|
+
type == PI_NODE
|
34
|
+
end
|
35
|
+
|
36
|
+
def text?
|
37
|
+
type == TEXT_NODE
|
38
|
+
end
|
39
|
+
|
40
|
+
def fragment?
|
41
|
+
type == DOCUMENT_FRAG_NODE
|
42
|
+
end
|
43
|
+
|
44
|
+
def element?
|
45
|
+
type == ELEMENT_NODE
|
46
|
+
end
|
47
|
+
|
48
|
+
def ancestors(selector = nil)
|
49
|
+
return NodeSet.new(@document) unless respond_to?(:parent)
|
50
|
+
return NodeSet.new(@document) unless parent
|
51
|
+
|
52
|
+
parents = [parent]
|
53
|
+
|
54
|
+
while parents.last.respond_to?(:parent)
|
55
|
+
break unless (ctx_parent = parents.last.parent)
|
56
|
+
|
57
|
+
parents << ctx_parent
|
58
|
+
end
|
59
|
+
|
60
|
+
return NodeSet.new(@document, parents) unless selector
|
61
|
+
|
62
|
+
root = parents.last
|
63
|
+
search_results = root.search(selector)
|
64
|
+
|
65
|
+
NodeSet.new(@document, parents.find_all do |parent|
|
66
|
+
search_results.include?(parent)
|
67
|
+
end)
|
68
|
+
end
|
69
|
+
|
70
|
+
def matches?(selector)
|
71
|
+
ancestors.last.css(selector).any? { |node| node == self }
|
72
|
+
end
|
73
|
+
|
74
|
+
def attribute(name)
|
75
|
+
return nil unless key?(name)
|
76
|
+
Attribute.new(name, attr(name))
|
77
|
+
end
|
78
|
+
|
79
|
+
def attributes
|
80
|
+
attrs.map { |k, v| [k, Attribute.new(k, v)] }.to_h
|
81
|
+
end
|
82
|
+
|
83
|
+
def replace(node)
|
84
|
+
if node.is_a?(NodeSet)
|
85
|
+
node.each { |n| add_sibling(:previous, n) }
|
86
|
+
else
|
87
|
+
add_sibling(:previous, node)
|
88
|
+
end
|
89
|
+
remove
|
90
|
+
end
|
91
|
+
|
92
|
+
def children=(node)
|
93
|
+
children.remove
|
94
|
+
if node.is_a?(NodeSet)
|
95
|
+
node.each { |n| add_child(n) }
|
96
|
+
else
|
97
|
+
add_child(node)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def each
|
102
|
+
attributes.each do |node|
|
103
|
+
yield [node.name, node.value]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
alias_method :inner_html=, :children=
|
108
|
+
|
109
|
+
def css(*args)
|
110
|
+
css_impl(args.join(', '))
|
111
|
+
end
|
112
|
+
|
113
|
+
def at_css(*args)
|
114
|
+
at_css_impl(args.join(', '))
|
115
|
+
end
|
116
|
+
|
117
|
+
def xpath(*args)
|
118
|
+
paths, handler, ns, binds = extract_params(args)
|
119
|
+
|
120
|
+
xpath_internal(self, paths, handler, ns, binds)
|
121
|
+
end
|
122
|
+
|
123
|
+
def at_xpath(*args)
|
124
|
+
xpath(*args).first
|
125
|
+
end
|
126
|
+
|
127
|
+
def search(*args)
|
128
|
+
paths, handler, ns, binds = extract_params(args)
|
129
|
+
|
130
|
+
if paths.size == 1 && !LOOKS_LIKE_XPATH.match?(paths.first)
|
131
|
+
return css(paths.first)
|
132
|
+
end
|
133
|
+
|
134
|
+
xpath(*(paths + [ns, handler, binds].compact))
|
135
|
+
end
|
136
|
+
|
137
|
+
alias_method :/, :search
|
138
|
+
|
139
|
+
def at(*args)
|
140
|
+
paths, handler, ns, binds = extract_params(args)
|
141
|
+
|
142
|
+
if paths.size == 1 && !LOOKS_LIKE_XPATH.match?(paths.first)
|
143
|
+
return at_css(paths.first)
|
144
|
+
end
|
145
|
+
|
146
|
+
at_xpath(*(paths + [ns, handler, binds].compact))
|
147
|
+
end
|
148
|
+
|
149
|
+
alias_method :%, :at
|
150
|
+
|
151
|
+
def classes
|
152
|
+
kwattr_values("class")
|
153
|
+
end
|
154
|
+
|
155
|
+
def add_class(names)
|
156
|
+
kwattr_add("class", names)
|
157
|
+
end
|
158
|
+
|
159
|
+
def append_class(names)
|
160
|
+
kwattr_append("class", names)
|
161
|
+
end
|
162
|
+
|
163
|
+
def remove_class(names = nil)
|
164
|
+
kwattr_remove("class", names)
|
165
|
+
end
|
166
|
+
|
167
|
+
def kwattr_values(attribute_name)
|
168
|
+
keywordify(attr(attribute_name) || [])
|
169
|
+
end
|
170
|
+
|
171
|
+
def kwattr_add(attribute_name, keywords)
|
172
|
+
keywords = keywordify(keywords)
|
173
|
+
current_kws = kwattr_values(attribute_name)
|
174
|
+
new_kws = (current_kws + (keywords - current_kws)).join(" ")
|
175
|
+
set_attr(attribute_name, new_kws)
|
176
|
+
self
|
177
|
+
end
|
178
|
+
|
179
|
+
def kwattr_append(attribute_name, keywords)
|
180
|
+
keywords = keywordify(keywords)
|
181
|
+
current_kws = kwattr_values(attribute_name)
|
182
|
+
new_kws = (current_kws + keywords).join(" ")
|
183
|
+
set_attr(attribute_name, new_kws)
|
184
|
+
self
|
185
|
+
end
|
186
|
+
|
187
|
+
def kwattr_remove(attribute_name, keywords)
|
188
|
+
if keywords.nil?
|
189
|
+
remove_attr(attribute_name)
|
190
|
+
return self
|
191
|
+
end
|
192
|
+
|
193
|
+
keywords = keywordify(keywords)
|
194
|
+
current_kws = kwattr_values(attribute_name)
|
195
|
+
new_kws = current_kws - keywords
|
196
|
+
if new_kws.empty?
|
197
|
+
remove_attr(attribute_name)
|
198
|
+
else
|
199
|
+
set_attr(attribute_name, new_kws.join(" "))
|
200
|
+
end
|
201
|
+
self
|
202
|
+
end
|
203
|
+
|
204
|
+
def keywordify(keywords)
|
205
|
+
case keywords
|
206
|
+
when Enumerable
|
207
|
+
keywords
|
208
|
+
when String
|
209
|
+
keywords.scan(/\S+/)
|
210
|
+
else
|
211
|
+
raise ArgumentError,
|
212
|
+
"Keyword attributes must be passed as either a String or an Enumerable, but received #{keywords.class}"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
217
|
+
|
218
|
+
def xpath_internal(node, paths, handler, ns, binds)
|
219
|
+
# document = node.document
|
220
|
+
# return NodeSet.new(document) unless document
|
221
|
+
|
222
|
+
if paths.length == 1
|
223
|
+
return xpath_impl(node, paths.first, handler, ns, binds)
|
224
|
+
end
|
225
|
+
|
226
|
+
NodeSet.new(@document) do |combined|
|
227
|
+
paths.each do |path|
|
228
|
+
xpath_impl(node, path, handler, ns, binds).each { |set| combined << set }
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def xpath_impl(node, path, handler, ns, binds)
|
234
|
+
ctx = XPathContext.new(node)
|
235
|
+
ctx.register_namespaces(ns)
|
236
|
+
# path = path.gsub(/xmlns:/, " :") unless Nokogiri.uses_libxml?
|
237
|
+
|
238
|
+
binds&.each do |key, value|
|
239
|
+
ctx.register_variable(key.to_s, value)
|
240
|
+
end
|
241
|
+
|
242
|
+
ctx.evaluate(path, handler)
|
243
|
+
end
|
244
|
+
|
245
|
+
def extract_params(params)
|
246
|
+
handler = params.find do |param|
|
247
|
+
![Hash, String, Symbol].include?(param.class)
|
248
|
+
end
|
249
|
+
params -= [handler] if handler
|
250
|
+
|
251
|
+
hashes = []
|
252
|
+
while Hash === params.last || params.last.nil?
|
253
|
+
hashes << params.pop
|
254
|
+
break if params.empty?
|
255
|
+
end
|
256
|
+
ns, binds = hashes.reverse
|
257
|
+
|
258
|
+
# ns ||= (document.root&.namespaces || {})
|
259
|
+
ns ||= {}
|
260
|
+
|
261
|
+
[params, handler, ns, binds]
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nokolexbor
|
4
|
+
class NodeSet < Node
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(document, list = [])
|
8
|
+
@document = document
|
9
|
+
list.each { |x| self << x }
|
10
|
+
yield self if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
def each
|
14
|
+
return to_enum unless block_given?
|
15
|
+
|
16
|
+
0.upto(length - 1) do |x|
|
17
|
+
yield self[x]
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def first(n = nil)
|
23
|
+
return self[0] unless n
|
24
|
+
|
25
|
+
list = []
|
26
|
+
[n, length].min.times { |i| list << self[i] }
|
27
|
+
list
|
28
|
+
end
|
29
|
+
|
30
|
+
def last
|
31
|
+
self[-1]
|
32
|
+
end
|
33
|
+
|
34
|
+
def empty?
|
35
|
+
length == 0
|
36
|
+
end
|
37
|
+
|
38
|
+
def index(node = nil)
|
39
|
+
if node
|
40
|
+
each_with_index { |member, j| return j if member == node }
|
41
|
+
elsif block_given?
|
42
|
+
each_with_index { |member, j| return j if yield(member) }
|
43
|
+
end
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def content
|
48
|
+
self.map(&:content).join
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_method :text, :content
|
52
|
+
alias_method :inner_text, :content
|
53
|
+
alias_method :to_str, :content
|
54
|
+
|
55
|
+
def inner_html
|
56
|
+
self.map(&:inner_html).join
|
57
|
+
end
|
58
|
+
|
59
|
+
def outer_html
|
60
|
+
self.map(&:outer_html).join
|
61
|
+
end
|
62
|
+
|
63
|
+
alias_method :to_s, :outer_html
|
64
|
+
alias_method :to_html, :outer_html
|
65
|
+
|
66
|
+
def remove
|
67
|
+
self.each(&:remove)
|
68
|
+
end
|
69
|
+
|
70
|
+
alias_method :destroy, :remove
|
71
|
+
alias_method :to_ary, :to_a
|
72
|
+
|
73
|
+
def pop
|
74
|
+
return nil if length == 0
|
75
|
+
|
76
|
+
delete(last)
|
77
|
+
end
|
78
|
+
|
79
|
+
def shift
|
80
|
+
return nil if length == 0
|
81
|
+
|
82
|
+
delete(first)
|
83
|
+
end
|
84
|
+
|
85
|
+
def ==(other)
|
86
|
+
return false unless other.is_a?(NodeSet)
|
87
|
+
return false unless length == other.length
|
88
|
+
|
89
|
+
each_with_index do |node, i|
|
90
|
+
return false unless node == other[i]
|
91
|
+
end
|
92
|
+
true
|
93
|
+
end
|
94
|
+
|
95
|
+
def children
|
96
|
+
node_set = NodeSet.new(@document)
|
97
|
+
each do |node|
|
98
|
+
node.children.each { |n| node_set.push(n) }
|
99
|
+
end
|
100
|
+
node_set
|
101
|
+
end
|
102
|
+
|
103
|
+
def reverse
|
104
|
+
node_set = NodeSet.new(@document)
|
105
|
+
(length - 1).downto(0) do |x|
|
106
|
+
node_set.push(self[x])
|
107
|
+
end
|
108
|
+
node_set
|
109
|
+
end
|
110
|
+
|
111
|
+
def xpath(*args)
|
112
|
+
paths, handler, ns, binds = extract_params(args)
|
113
|
+
|
114
|
+
NodeSet.new(@document) do |set|
|
115
|
+
each do |node|
|
116
|
+
node.send(:xpath_internal, node, paths, handler, ns, binds).each do |inner_node|
|
117
|
+
set << inner_node
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nokolexbor
|
4
|
+
class XPathContext
|
5
|
+
###
|
6
|
+
# Register namespaces in +namespaces+
|
7
|
+
def register_namespaces(namespaces)
|
8
|
+
namespaces.each do |k, v|
|
9
|
+
k = k.to_s.gsub(/.*:/, "") # strip off 'xmlns:' or 'xml:'
|
10
|
+
register_ns(k, v)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/nokolexbor.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nokolexbor/nokolexbor'
|
4
|
+
require 'nokolexbor/version'
|
5
|
+
require 'nokolexbor/node'
|
6
|
+
require 'nokolexbor/document'
|
7
|
+
require 'nokolexbor/node_set'
|
8
|
+
require 'nokolexbor/attribute'
|
9
|
+
require 'nokolexbor/xpath_context'
|
10
|
+
|
11
|
+
module Nokolexbor
|
12
|
+
class << self
|
13
|
+
def HTML(*args)
|
14
|
+
Document.parse(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
diff --git i/source/lexbor/css/selectors/pseudo_const.h w/source/lexbor/css/selectors/pseudo_const.h
|
2
|
+
index 2b19f18..5e56181 100644
|
3
|
+
--- i/source/lexbor/css/selectors/pseudo_const.h
|
4
|
+
+++ w/source/lexbor/css/selectors/pseudo_const.h
|
5
|
+
@@ -95,7 +95,8 @@ typedef enum {
|
6
|
+
LXB_CSS_SELECTOR_PSEUDO_ELEMENT_SELECTION = 0x000a,
|
7
|
+
LXB_CSS_SELECTOR_PSEUDO_ELEMENT_SPELLING_ERROR = 0x000b,
|
8
|
+
LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TARGET_TEXT = 0x000c,
|
9
|
+
- LXB_CSS_SELECTOR_PSEUDO_ELEMENT__LAST_ENTRY = 0x000d
|
10
|
+
+ LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TEXT = 0x000d,
|
11
|
+
+ LXB_CSS_SELECTOR_PSEUDO_ELEMENT__LAST_ENTRY = 0x000e
|
12
|
+
}
|
13
|
+
lxb_css_selector_pseudo_element_id_t;
|
14
|
+
|
15
|
+
diff --git i/source/lexbor/css/selectors/pseudo_res.h w/source/lexbor/css/selectors/pseudo_res.h
|
16
|
+
index 398d1bb..b35bfab 100644
|
17
|
+
--- i/source/lexbor/css/selectors/pseudo_res.h
|
18
|
+
+++ w/source/lexbor/css/selectors/pseudo_res.h
|
19
|
+
@@ -124,7 +124,8 @@ static const lxb_css_selectors_pseudo_data_t lxb_css_selectors_pseudo_data_pseud
|
20
|
+
{(lxb_char_t *) "placeholder", 11, LXB_CSS_SELECTOR_PSEUDO_ELEMENT_PLACEHOLDER},
|
21
|
+
{(lxb_char_t *) "selection", 9, LXB_CSS_SELECTOR_PSEUDO_ELEMENT_SELECTION},
|
22
|
+
{(lxb_char_t *) "spelling-error", 14, LXB_CSS_SELECTOR_PSEUDO_ELEMENT_SPELLING_ERROR},
|
23
|
+
- {(lxb_char_t *) "target-text", 11, LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TARGET_TEXT}
|
24
|
+
+ {(lxb_char_t *) "target-text", 11, LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TARGET_TEXT},
|
25
|
+
+ {(lxb_char_t *) "text", 4, LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TEXT}
|
26
|
+
};
|
27
|
+
|
28
|
+
static const lxb_css_selectors_pseudo_data_func_t lxb_css_selectors_pseudo_data_pseudo_element_function[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_FUNCTION__LAST_ENTRY] =
|
29
|
+
@@ -268,7 +269,7 @@ static const lexbor_shs_entry_t lxb_css_selectors_pseudo_element_shs[24] =
|
30
|
+
{"placeholder", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_PLACEHOLDER], 11, 0},
|
31
|
+
{"after", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_AFTER], 5, 0},
|
32
|
+
{"first-letter", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_FIRST_LETTER], 12, 0},
|
33
|
+
- {NULL, NULL, 0, 0},
|
34
|
+
+ {"text", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TEXT], 4, 0},
|
35
|
+
{NULL, NULL, 0, 0},
|
36
|
+
{"grammar-error", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_GRAMMAR_ERROR], 13, 0},
|
37
|
+
{"before", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_BEFORE], 6, 0},
|
38
|
+
diff --git i/source/lexbor/selectors/selectors.c w/source/lexbor/selectors/selectors.c
|
39
|
+
index c2d18ea..84b5b14 100644
|
40
|
+
--- i/source/lexbor/selectors/selectors.c
|
41
|
+
+++ w/source/lexbor/selectors/selectors.c
|
42
|
+
@@ -156,6 +156,12 @@ lxb_selectors_descendant(lxb_selectors_t *selectors, lxb_selectors_entry_t *entr
|
43
|
+
{
|
44
|
+
return node;
|
45
|
+
}
|
46
|
+
+ else if (selector->type == LXB_CSS_SELECTOR_TYPE_PSEUDO_ELEMENT &&
|
47
|
+
+ node->type == LXB_DOM_NODE_TYPE_TEXT &&
|
48
|
+
+ lxb_selectors_pseudo_element(selectors, selector, node))
|
49
|
+
+ {
|
50
|
+
+ return node;
|
51
|
+
+ }
|
52
|
+
|
53
|
+
if (node->first_child != NULL) {
|
54
|
+
node = node->first_child;
|
55
|
+
@@ -201,6 +207,12 @@ lxb_selectors_descendant_next(lxb_selectors_t *selectors, lxb_selectors_entry_t
|
56
|
+
{
|
57
|
+
return node;
|
58
|
+
}
|
59
|
+
+ else if (selector->type == LXB_CSS_SELECTOR_TYPE_PSEUDO_ELEMENT &&
|
60
|
+
+ node->type == LXB_DOM_NODE_TYPE_TEXT &&
|
61
|
+
+ lxb_selectors_pseudo_element(selectors, selector, node))
|
62
|
+
+ {
|
63
|
+
+ return node;
|
64
|
+
+ }
|
65
|
+
}
|
66
|
+
while (true);
|
67
|
+
}
|
68
|
+
@@ -229,6 +241,12 @@ lxb_selectors_child(lxb_selectors_t *selectors, lxb_selectors_entry_t *entry,
|
69
|
+
{
|
70
|
+
return node;
|
71
|
+
}
|
72
|
+
+ else if (selector->type == LXB_CSS_SELECTOR_TYPE_PSEUDO_ELEMENT &&
|
73
|
+
+ node->type == LXB_DOM_NODE_TYPE_TEXT &&
|
74
|
+
+ lxb_selectors_pseudo_element(selectors, selector, node))
|
75
|
+
+ {
|
76
|
+
+ return node;
|
77
|
+
+ }
|
78
|
+
|
79
|
+
node = node->next;
|
80
|
+
}
|
81
|
+
@@ -249,6 +267,12 @@ lxb_selectors_child_next(lxb_selectors_t *selectors, lxb_selectors_entry_t *entr
|
82
|
+
{
|
83
|
+
return node;
|
84
|
+
}
|
85
|
+
+ else if (selector->type == LXB_CSS_SELECTOR_TYPE_PSEUDO_ELEMENT &&
|
86
|
+
+ node->type == LXB_DOM_NODE_TYPE_TEXT &&
|
87
|
+
+ lxb_selectors_pseudo_element(selectors, selector, node))
|
88
|
+
+ {
|
89
|
+
+ return node;
|
90
|
+
+ }
|
91
|
+
|
92
|
+
node = node->next;
|
93
|
+
}
|
94
|
+
@@ -262,6 +286,8 @@ lxb_selectors_sibling(lxb_selectors_t *selectors, lxb_selectors_entry_t *entry,
|
95
|
+
{
|
96
|
+
node = node->next;
|
97
|
+
|
98
|
+
+ if (node == NULL) return NULL;
|
99
|
+
+
|
100
|
+
do {
|
101
|
+
if (node->type == LXB_DOM_NODE_TYPE_ELEMENT) {
|
102
|
+
if (lxb_selectors_match(selectors, entry, selector, node)) {
|
103
|
+
@@ -290,6 +316,12 @@ lxb_selectors_following(lxb_selectors_t *selectors, lxb_selectors_entry_t *entry
|
104
|
+
{
|
105
|
+
return node;
|
106
|
+
}
|
107
|
+
+ else if (selector->type == LXB_CSS_SELECTOR_TYPE_PSEUDO_ELEMENT &&
|
108
|
+
+ node->type == LXB_DOM_NODE_TYPE_TEXT &&
|
109
|
+
+ lxb_selectors_pseudo_element(selectors, selector, node))
|
110
|
+
+ {
|
111
|
+
+ return node;
|
112
|
+
+ }
|
113
|
+
|
114
|
+
node = node->next;
|
115
|
+
}
|
116
|
+
@@ -1429,6 +1461,8 @@ lxb_selectors_pseudo_element(lxb_selectors_t *selectors,
|
117
|
+
lxb_css_selector_pseudo_t *pseudo = &selector->u.pseudo;
|
118
|
+
|
119
|
+
switch (pseudo->type) {
|
120
|
+
+ case LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TEXT:
|
121
|
+
+ return node->local_name == LXB_TAG__TEXT;
|
122
|
+
case LXB_CSS_SELECTOR_PSEUDO_ELEMENT_AFTER:
|
123
|
+
case LXB_CSS_SELECTOR_PSEUDO_ELEMENT_BACKDROP:
|
124
|
+
case LXB_CSS_SELECTOR_PSEUDO_ELEMENT_BEFORE:
|
125
|
+
diff --git i/utils/lexbor/css/selectors/pseudo.py w/utils/lexbor/css/selectors/pseudo.py
|
126
|
+
index 57e2b7b..bf3bc01 100755
|
127
|
+
--- i/utils/lexbor/css/selectors/pseudo.py
|
128
|
+
+++ w/utils/lexbor/css/selectors/pseudo.py
|
129
|
+
@@ -49,7 +49,7 @@ pseudo_elements = [
|
130
|
+
# https://drafts.csswg.org/css-pseudo-4/#index
|
131
|
+
"after", "before", "first-letter", "first-line", "grammar-error",
|
132
|
+
"inactive-selection", "marker", "placeholder", "selection",
|
133
|
+
- "spelling-error", "target-text",
|
134
|
+
+ "spelling-error", "target-text", "text",
|
135
|
+
|
136
|
+
# https://fullscreen.spec.whatwg.org/#index
|
137
|
+
"backdrop"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
diff --git i/source/lexbor/selectors/selectors.c w/source/lexbor/selectors/selectors.c
|
2
|
+
index c2d18ea..84b5b14 100644
|
3
|
+
--- i/source/lexbor/selectors/selectors.c
|
4
|
+
+++ w/source/lexbor/selectors/selectors.c
|
5
|
+
@@ -751,7 +783,7 @@ lxb_selectors_match(lxb_selectors_t *selectors, lxb_selectors_entry_t *entry,
|
6
|
+
src = &selector->name;
|
7
|
+
|
8
|
+
if (trg->length == src->length
|
9
|
+
- && lexbor_str_data_ncasecmp(trg->data, src->data, src->length))
|
10
|
+
+ && lexbor_str_data_ncmp(trg->data, src->data, src->length))
|
11
|
+
{
|
12
|
+
return true;
|
13
|
+
}
|
14
|
+
@@ -766,7 +798,7 @@ lxb_selectors_match(lxb_selectors_t *selectors, lxb_selectors_entry_t *entry,
|
15
|
+
}
|
16
|
+
|
17
|
+
return lxb_selectors_match_class(element->attr_class->value,
|
18
|
+
- &selector->name, true);
|
19
|
+
+ &selector->name, false);
|
20
|
+
|
21
|
+
case LXB_CSS_SELECTOR_TYPE_ATTRIBUTE:
|
22
|
+
element = lxb_dom_interface_element(node);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
diff --git i/source/lexbor/html/interfaces/template_element.c w/source/lexbor/html/interfaces/template_element.c
|
2
|
+
index 884fede..29c1e69 100755
|
3
|
+
--- i/source/lexbor/html/interfaces/template_element.c
|
4
|
+
+++ w/source/lexbor/html/interfaces/template_element.c
|
5
|
+
@@ -29,6 +29,8 @@ lxb_html_template_element_interface_create(lxb_html_document_t *document)
|
6
|
+
return lxb_html_template_element_interface_destroy(element);
|
7
|
+
}
|
8
|
+
|
9
|
+
+ lxb_dom_node_insert_child(&element->element.element.node, &element->content->node);
|
10
|
+
+
|
11
|
+
element->content->node.ns = LXB_NS_HTML;
|
12
|
+
element->content->host = lxb_dom_interface_element(element);
|
13
|
+
|