nokolexbor 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nokolexbor
4
+ module XPath
5
+ class SyntaxError < StandardError
6
+ attr_reader :domain
7
+ attr_reader :code
8
+ attr_reader :level
9
+ attr_reader :file
10
+ attr_reader :line
11
+ attr_reader :str1
12
+ attr_reader :str2
13
+ attr_reader :str3
14
+ attr_reader :int1
15
+ attr_reader :column
16
+
17
+ ###
18
+ # return true if this is a non error
19
+ def none?
20
+ level == 0
21
+ end
22
+
23
+ ###
24
+ # return true if this is a warning
25
+ def warning?
26
+ level == 1
27
+ end
28
+
29
+ ###
30
+ # return true if this is an error
31
+ def error?
32
+ level == 2
33
+ end
34
+
35
+ ###
36
+ # return true if this error is fatal
37
+ def fatal?
38
+ level == 3
39
+ end
40
+
41
+ def to_s
42
+ message = super.chomp
43
+ [location_to_s, level_to_s, message]
44
+ .compact.join(": ")
45
+ .force_encoding(message.encoding)
46
+ end
47
+
48
+ private
49
+
50
+ def level_to_s
51
+ case level
52
+ when 3 then "FATAL"
53
+ when 2 then "ERROR"
54
+ when 1 then "WARNING"
55
+ end
56
+ end
57
+
58
+ def nil_or_zero?(attribute)
59
+ attribute.nil? || attribute.zero?
60
+ end
61
+
62
+ def location_to_s
63
+ return nil if nil_or_zero?(line) && nil_or_zero?(column)
64
+
65
+ "#{line}:#{column}"
66
+ end
67
+ end
68
+ end
69
+ end
data/lib/nokolexbor.rb CHANGED
@@ -6,6 +6,7 @@ require 'nokolexbor/node'
6
6
  require 'nokolexbor/document'
7
7
  require 'nokolexbor/node_set'
8
8
  require 'nokolexbor/attribute'
9
+ require 'nokolexbor/xpath'
9
10
  require 'nokolexbor/xpath_context'
10
11
 
11
12
  module Nokolexbor
@@ -11,3 +11,16 @@ index 884fede..29c1e69 100755
11
11
  element->content->node.ns = LXB_NS_HTML;
12
12
  element->content->host = lxb_dom_interface_element(element);
13
13
 
14
+ diff --git i/source/lexbor/html/serialize.c w/source/lexbor/html/serialize.c
15
+ index df9689d..5e2ff91 100755
16
+ --- i/source/lexbor/html/serialize.c
17
+ +++ w/source/lexbor/html/serialize.c
18
+ @@ -272,7 +272,7 @@ lxb_html_serialize_node_cb(lxb_dom_node_t *node,
19
+ }
20
+ }
21
+
22
+ - skip_it = lxb_html_node_is_void(node);
23
+ + skip_it = lxb_html_node_is_void(node) || node->local_name == LXB_TAG_TEMPLATE;
24
+
25
+ if (skip_it == false && node->first_child != NULL) {
26
+ node = node->first_child;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokolexbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yicheng Zhou
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-16 00:00:00.000000000 Z
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
27
41
  description: Nokolexbor is a high performance HTML5 parser, with support for both
28
42
  CSS selectors and XPath. It's API is designed to be compatible with Nokogiri.
29
43
  email: zyc9012@gmail.com
@@ -105,6 +119,7 @@ files:
105
119
  - lib/nokolexbor/node.rb
106
120
  - lib/nokolexbor/node_set.rb
107
121
  - lib/nokolexbor/version.rb
122
+ - lib/nokolexbor/xpath.rb
108
123
  - lib/nokolexbor/xpath_context.rb
109
124
  - patches/0001-lexbor-support-text-pseudo-element.patch
110
125
  - patches/0002-lexbor-match-id-class-case-sensitive.patch
@@ -522,7 +537,7 @@ licenses:
522
537
  - MIT
523
538
  metadata:
524
539
  msys2_mingw_dependencies: cmake
525
- post_install_message:
540
+ post_install_message:
526
541
  rdoc_options: []
527
542
  require_paths:
528
543
  - lib
@@ -537,8 +552,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
537
552
  - !ruby/object:Gem::Version
538
553
  version: '0'
539
554
  requirements: []
540
- rubygems_version: 3.1.4
541
- signing_key:
555
+ rubygems_version: 3.0.3.1
556
+ signing_key:
542
557
  specification_version: 4
543
558
  summary: High performance HTML5 parser, with support for both CSS selectors and XPath.
544
559
  test_files: []