selma 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +40 -40
- data/README.md +48 -46
- data/ext/selma/src/rewriter.rs +3 -3
- data/lib/selma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27c1b5bcd36e8c5627fb874937079041dc07b1b54dc326a8e2eae9b52236b478
|
4
|
+
data.tar.gz: 46fabb6609038ab3c43b89959e5fa82175633ab8df77eeba6c77a1382d2bf3c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b443634bc2a6e77d2514501489cf9e84e7ee52d0210a8424291a1794a9eb181f508448753c1eb9084d0d4341f41fb4863ed95199c8f8040e7aca269943488d
|
7
|
+
data.tar.gz: 674f0edf5f22c721340b6ff428f9704663437272bdc37596ba5da098c3b98fcc68de42c4ce1a52f3f447498a5e27414527bc1a076c8c442a5c894f50fdf03941
|
data/Cargo.lock
CHANGED
@@ -25,9 +25,9 @@ dependencies = [
|
|
25
25
|
|
26
26
|
[[package]]
|
27
27
|
name = "bindgen"
|
28
|
-
version = "0.69.
|
28
|
+
version = "0.69.5"
|
29
29
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
30
|
-
checksum = "
|
30
|
+
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
31
31
|
dependencies = [
|
32
32
|
"bitflags 2.6.0",
|
33
33
|
"cexpr",
|
@@ -40,7 +40,7 @@ dependencies = [
|
|
40
40
|
"regex",
|
41
41
|
"rustc-hash",
|
42
42
|
"shlex",
|
43
|
-
"syn 2.0.
|
43
|
+
"syn 2.0.89",
|
44
44
|
]
|
45
45
|
|
46
46
|
[[package]]
|
@@ -117,7 +117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
117
117
|
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
|
118
118
|
dependencies = [
|
119
119
|
"quote",
|
120
|
-
"syn 2.0.
|
120
|
+
"syn 2.0.89",
|
121
121
|
]
|
122
122
|
|
123
123
|
[[package]]
|
@@ -130,7 +130,7 @@ dependencies = [
|
|
130
130
|
"proc-macro2",
|
131
131
|
"quote",
|
132
132
|
"rustc_version",
|
133
|
-
"syn 2.0.
|
133
|
+
"syn 2.0.89",
|
134
134
|
]
|
135
135
|
|
136
136
|
[[package]]
|
@@ -156,9 +156,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
|
156
156
|
|
157
157
|
[[package]]
|
158
158
|
name = "encoding_rs"
|
159
|
-
version = "0.8.
|
159
|
+
version = "0.8.35"
|
160
160
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
161
|
-
checksum = "
|
161
|
+
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
|
162
162
|
dependencies = [
|
163
163
|
"cfg-if",
|
164
164
|
]
|
@@ -186,7 +186,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b"
|
|
186
186
|
dependencies = [
|
187
187
|
"proc-macro2",
|
188
188
|
"quote",
|
189
|
-
"syn 2.0.
|
189
|
+
"syn 2.0.89",
|
190
190
|
]
|
191
191
|
|
192
192
|
[[package]]
|
@@ -262,9 +262,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
262
262
|
|
263
263
|
[[package]]
|
264
264
|
name = "libc"
|
265
|
-
version = "0.2.
|
265
|
+
version = "0.2.165"
|
266
266
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
267
|
-
checksum = "
|
267
|
+
checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e"
|
268
268
|
|
269
269
|
[[package]]
|
270
270
|
name = "libloading"
|
@@ -321,7 +321,7 @@ checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
|
|
321
321
|
dependencies = [
|
322
322
|
"proc-macro2",
|
323
323
|
"quote",
|
324
|
-
"syn 2.0.
|
324
|
+
"syn 2.0.89",
|
325
325
|
]
|
326
326
|
|
327
327
|
[[package]]
|
@@ -366,9 +366,9 @@ dependencies = [
|
|
366
366
|
|
367
367
|
[[package]]
|
368
368
|
name = "once_cell"
|
369
|
-
version = "1.
|
369
|
+
version = "1.20.2"
|
370
370
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
371
|
-
checksum = "
|
371
|
+
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
372
372
|
|
373
373
|
[[package]]
|
374
374
|
name = "phf"
|
@@ -447,18 +447,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
|
|
447
447
|
|
448
448
|
[[package]]
|
449
449
|
name = "proc-macro2"
|
450
|
-
version = "1.0.
|
450
|
+
version = "1.0.92"
|
451
451
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
452
|
-
checksum = "
|
452
|
+
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
453
453
|
dependencies = [
|
454
454
|
"unicode-ident",
|
455
455
|
]
|
456
456
|
|
457
457
|
[[package]]
|
458
458
|
name = "quote"
|
459
|
-
version = "1.0.
|
459
|
+
version = "1.0.37"
|
460
460
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
461
|
-
checksum = "
|
461
|
+
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
462
462
|
dependencies = [
|
463
463
|
"proc-macro2",
|
464
464
|
]
|
@@ -516,18 +516,18 @@ dependencies = [
|
|
516
516
|
|
517
517
|
[[package]]
|
518
518
|
name = "rb-sys"
|
519
|
-
version = "0.9.
|
519
|
+
version = "0.9.103"
|
520
520
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
521
|
-
checksum = "
|
521
|
+
checksum = "91dbe37ab6ac2fba187480fb6544b92445e41e5c6f553bf0c33743f3c450a1df"
|
522
522
|
dependencies = [
|
523
523
|
"rb-sys-build",
|
524
524
|
]
|
525
525
|
|
526
526
|
[[package]]
|
527
527
|
name = "rb-sys-build"
|
528
|
-
version = "0.9.
|
528
|
+
version = "0.9.103"
|
529
529
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
530
|
-
checksum = "
|
530
|
+
checksum = "c4d56a49dcb646b70b758789c0d16c055a386a4f2a3346333abb69850fa860ce"
|
531
531
|
dependencies = [
|
532
532
|
"bindgen",
|
533
533
|
"lazy_static",
|
@@ -535,7 +535,7 @@ dependencies = [
|
|
535
535
|
"quote",
|
536
536
|
"regex",
|
537
537
|
"shell-words",
|
538
|
-
"syn 2.0.
|
538
|
+
"syn 2.0.89",
|
539
539
|
]
|
540
540
|
|
541
541
|
[[package]]
|
@@ -546,9 +546,9 @@ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
|
546
546
|
|
547
547
|
[[package]]
|
548
548
|
name = "regex"
|
549
|
-
version = "1.
|
549
|
+
version = "1.11.1"
|
550
550
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
551
|
-
checksum = "
|
551
|
+
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
552
552
|
dependencies = [
|
553
553
|
"aho-corasick",
|
554
554
|
"memchr",
|
@@ -558,9 +558,9 @@ dependencies = [
|
|
558
558
|
|
559
559
|
[[package]]
|
560
560
|
name = "regex-automata"
|
561
|
-
version = "0.4.
|
561
|
+
version = "0.4.9"
|
562
562
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
563
|
-
checksum = "
|
563
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
564
564
|
dependencies = [
|
565
565
|
"aho-corasick",
|
566
566
|
"memchr",
|
@@ -569,9 +569,9 @@ dependencies = [
|
|
569
569
|
|
570
570
|
[[package]]
|
571
571
|
name = "regex-syntax"
|
572
|
-
version = "0.8.
|
572
|
+
version = "0.8.5"
|
573
573
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
574
|
-
checksum = "
|
574
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
575
575
|
|
576
576
|
[[package]]
|
577
577
|
name = "rustc-hash"
|
@@ -581,9 +581,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
581
581
|
|
582
582
|
[[package]]
|
583
583
|
name = "rustc_version"
|
584
|
-
version = "0.4.
|
584
|
+
version = "0.4.1"
|
585
585
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
586
|
-
checksum = "
|
586
|
+
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
587
587
|
dependencies = [
|
588
588
|
"semver",
|
589
589
|
]
|
@@ -684,9 +684,9 @@ dependencies = [
|
|
684
684
|
|
685
685
|
[[package]]
|
686
686
|
name = "syn"
|
687
|
-
version = "2.0.
|
687
|
+
version = "2.0.89"
|
688
688
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
689
|
-
checksum = "
|
689
|
+
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
|
690
690
|
dependencies = [
|
691
691
|
"proc-macro2",
|
692
692
|
"quote",
|
@@ -701,29 +701,29 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
|
|
701
701
|
|
702
702
|
[[package]]
|
703
703
|
name = "thiserror"
|
704
|
-
version = "1.0.
|
704
|
+
version = "1.0.69"
|
705
705
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
706
|
-
checksum = "
|
706
|
+
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
707
707
|
dependencies = [
|
708
708
|
"thiserror-impl",
|
709
709
|
]
|
710
710
|
|
711
711
|
[[package]]
|
712
712
|
name = "thiserror-impl"
|
713
|
-
version = "1.0.
|
713
|
+
version = "1.0.69"
|
714
714
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
715
|
-
checksum = "
|
715
|
+
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
716
716
|
dependencies = [
|
717
717
|
"proc-macro2",
|
718
718
|
"quote",
|
719
|
-
"syn 2.0.
|
719
|
+
"syn 2.0.89",
|
720
720
|
]
|
721
721
|
|
722
722
|
[[package]]
|
723
723
|
name = "unicode-ident"
|
724
|
-
version = "1.0.
|
724
|
+
version = "1.0.14"
|
725
725
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
726
|
-
checksum = "
|
726
|
+
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
727
727
|
|
728
728
|
[[package]]
|
729
729
|
name = "version_check"
|
@@ -819,5 +819,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
|
819
819
|
dependencies = [
|
820
820
|
"proc-macro2",
|
821
821
|
"quote",
|
822
|
-
"syn 2.0.
|
822
|
+
"syn 2.0.89",
|
823
823
|
]
|
data/README.md
CHANGED
@@ -134,7 +134,6 @@ The `Selma::Selector` object has three possible kwargs:
|
|
134
134
|
Here's an example for `handle_text_chunk` which changes strings in various elements which are _not_ `pre` or `code`:
|
135
135
|
|
136
136
|
```ruby
|
137
|
-
|
138
137
|
class MatchText
|
139
138
|
SELECTOR = Selma::Selector.new(match_text_within: "*", ignore_text_within: ["pre", "code"])
|
140
139
|
|
@@ -189,6 +188,7 @@ Selma::Rewriter.new(options: { memory: { max_allowed_memory_usage: 1_000_000 } }
|
|
189
188
|
```
|
190
189
|
|
191
190
|
The structure of the `memory` options looks like this:
|
191
|
+
|
192
192
|
```ruby
|
193
193
|
{
|
194
194
|
memory: {
|
@@ -215,43 +215,44 @@ input size = 25309 bytes, 0.03 MB
|
|
215
215
|
|
216
216
|
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
217
217
|
Warming up --------------------------------------
|
218
|
-
|
219
|
-
|
218
|
+
sanitize-sm 15.000 i/100ms
|
219
|
+
selma-sm 127.000 i/100ms
|
220
220
|
Calculating -------------------------------------
|
221
|
-
|
222
|
-
|
221
|
+
sanitize-sm 157.643 (± 1.9%) i/s - 4.740k in 30.077172s
|
222
|
+
selma-sm 1.278k (± 1.5%) i/s - 38.354k in 30.019722s
|
223
223
|
|
224
224
|
Comparison:
|
225
|
-
|
226
|
-
|
225
|
+
selma-sm: 1277.9 i/s
|
226
|
+
sanitize-sm: 157.6 i/s - 8.11x slower
|
227
227
|
|
228
228
|
input size = 86686 bytes, 0.09 MB
|
229
229
|
|
230
230
|
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
231
231
|
Warming up --------------------------------------
|
232
|
-
|
233
|
-
|
232
|
+
sanitize-md 4.000 i/100ms
|
233
|
+
selma-md 33.000 i/100ms
|
234
234
|
Calculating -------------------------------------
|
235
|
-
|
236
|
-
|
235
|
+
sanitize-md 40.034 (± 5.0%) i/s - 1.200k in 30.043322s
|
236
|
+
selma-md 332.959 (± 2.1%) i/s - 9.999k in 30.045733s
|
237
237
|
|
238
238
|
Comparison:
|
239
|
-
|
240
|
-
|
239
|
+
selma-md: 333.0 i/s
|
240
|
+
sanitize-md: 40.0 i/s - 8.32x slower
|
241
241
|
|
242
242
|
input size = 7172510 bytes, 7.17 MB
|
243
243
|
|
244
244
|
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
245
245
|
Warming up --------------------------------------
|
246
|
-
|
247
|
-
|
246
|
+
sanitize-lg 1.000 i/100ms
|
247
|
+
selma-lg 1.000 i/100ms
|
248
248
|
Calculating -------------------------------------
|
249
|
-
|
250
|
-
|
249
|
+
sanitize-lg 0.141 (± 0.0%) i/s - 5.000 in 35.426127s
|
250
|
+
selma-lg 3.963 (± 0.0%) i/s - 119.000 in 30.037386s
|
251
251
|
|
252
252
|
Comparison:
|
253
|
-
|
254
|
-
|
253
|
+
selma-lg: 4.0 i/s
|
254
|
+
sanitize-lg: 0.1 i/s - 28.03x slower
|
255
|
+
|
255
256
|
</pre>
|
256
257
|
</details>
|
257
258
|
<!-- prettier-ignore-end -->
|
@@ -267,52 +268,53 @@ input size = 25309 bytes, 0.03 MB
|
|
267
268
|
|
268
269
|
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
269
270
|
Warming up --------------------------------------
|
270
|
-
|
271
|
-
|
272
|
-
|
271
|
+
nokogiri-sm 79.000 i/100ms
|
272
|
+
nokolexbor-sm 295.000 i/100ms
|
273
|
+
selma-sm 237.000 i/100ms
|
273
274
|
Calculating -------------------------------------
|
274
|
-
|
275
|
-
|
276
|
-
|
275
|
+
nokogiri-sm 800.531 (± 2.2%) i/s - 24.016k in 30.016056s
|
276
|
+
nokolexbor-sm 3.033k (± 3.6%) i/s - 91.155k in 30.094884s
|
277
|
+
selma-sm 2.386k (± 1.6%) i/s - 71.574k in 30.001701s
|
277
278
|
|
278
279
|
Comparison:
|
279
|
-
|
280
|
-
|
281
|
-
|
280
|
+
nokolexbor-sm: 3033.1 i/s
|
281
|
+
selma-sm: 2386.3 i/s - 1.27x slower
|
282
|
+
nokogiri-sm: 800.5 i/s - 3.79x slower
|
282
283
|
|
283
284
|
input size = 86686 bytes, 0.09 MB
|
284
285
|
|
285
286
|
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
286
287
|
Warming up --------------------------------------
|
287
|
-
|
288
|
-
|
289
|
-
|
288
|
+
nokogiri-md 8.000 i/100ms
|
289
|
+
nokolexbor-md 43.000 i/100ms
|
290
|
+
selma-md 38.000 i/100ms
|
290
291
|
Calculating -------------------------------------
|
291
|
-
|
292
|
-
|
293
|
-
|
292
|
+
nokogiri-md 85.013 (± 8.2%) i/s - 2.024k in 52.257472s
|
293
|
+
nokolexbor-md 416.074 (±11.1%) i/s - 12.341k in 30.111613s
|
294
|
+
selma-md 361.471 (± 4.7%) i/s - 10.830k in 30.033997s
|
294
295
|
|
295
296
|
Comparison:
|
296
|
-
|
297
|
-
|
298
|
-
|
297
|
+
nokolexbor-md: 416.1 i/s
|
298
|
+
selma-md: 361.5 i/s - same-ish: difference falls within error
|
299
|
+
nokogiri-md: 85.0 i/s - 4.89x slower
|
299
300
|
|
300
301
|
input size = 7172510 bytes, 7.17 MB
|
301
302
|
|
302
303
|
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
303
304
|
Warming up --------------------------------------
|
304
|
-
|
305
|
-
|
306
|
-
|
305
|
+
nokogiri-lg 1.000 i/100ms
|
306
|
+
nokolexbor-lg 1.000 i/100ms
|
307
|
+
selma-lg 1.000 i/100ms
|
307
308
|
Calculating -------------------------------------
|
308
|
-
|
309
|
-
|
310
|
-
|
309
|
+
nokogiri-lg 0.805 (± 0.0%) i/s - 25.000 in 31.148730s
|
310
|
+
nokolexbor-lg 2.194 (± 0.0%) i/s - 66.000 in 30.278108s
|
311
|
+
selma-lg 5.541 (± 0.0%) i/s - 166.000 in 30.037197s
|
311
312
|
|
312
313
|
Comparison:
|
313
|
-
|
314
|
-
|
315
|
-
|
314
|
+
selma-lg: 5.5 i/s
|
315
|
+
nokolexbor-lg: 2.2 i/s - 2.53x slower
|
316
|
+
nokogiri-lg: 0.8 i/s - 6.88x slower
|
317
|
+
|
316
318
|
</pre>
|
317
319
|
</details>
|
318
320
|
<!-- prettier-ignore-end -->
|
data/ext/selma/src/rewriter.rs
CHANGED
@@ -397,13 +397,13 @@ impl SelmaRewriter {
|
|
397
397
|
move |text| {
|
398
398
|
let element_stack = closure_element_stack.as_ref().borrow();
|
399
399
|
if selector.ignore_text_within().is_some() {
|
400
|
-
// check if current tag is a tag we should be ignoring text within
|
401
|
-
|
400
|
+
// check if current tag is a tag we should be ignoring text within;
|
401
|
+
// also checks if tag is within an ancestery of ignored tags
|
402
402
|
if selector
|
403
403
|
.ignore_text_within()
|
404
404
|
.unwrap()
|
405
405
|
.iter()
|
406
|
-
.any(|
|
406
|
+
.any(|t| element_stack.contains(t))
|
407
407
|
{
|
408
408
|
return Ok(());
|
409
409
|
}
|
data/lib/selma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rb_sys
|