mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-14 10:13:52 -04:00
CssXPath: Implement ~ subsequent-sibling (#8154)
* CssXPath: Implement ~ Subsequent-sibling fix https://github.com/FreshRSS/FreshRSS/issues/8143 Upstream PR https://github.com/phpgt/CssXPath/pull/231 * Use CssXPath release v1.4.0 https://github.com/phpgt/CssXPath/releases/tag/v1.4.0
This commit is contained in:
committed by
GitHub
parent
f1c91c84dd
commit
1abb261cea
2
lib/.gitignore
vendored
2
lib/.gitignore
vendored
@@ -12,6 +12,8 @@ marienfressinaud/lib_opml/tests/
|
||||
phpgt/cssxpath/.*
|
||||
phpgt/cssxpath/composer.json
|
||||
phpgt/cssxpath/CONTRIBUTING.md
|
||||
phpgt/cssxpath/phpunit.xml
|
||||
phpgt/cssxpath/SECURITY*
|
||||
phpgt/cssxpath/test/
|
||||
phpmailer/phpmailer/*oauth*
|
||||
phpmailer/phpmailer/COMMITMENT*
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
],
|
||||
"require": {
|
||||
"marienfressinaud/lib_opml": "0.5.1",
|
||||
"phpgt/cssxpath": "v1.3.0",
|
||||
"phpgt/cssxpath": "v1.4.0",
|
||||
"phpmailer/phpmailer": "6.11.1",
|
||||
"simplepie/simplepie": "dev-freshrss#24cfb0c6d81f81ef110c8257d3464b2649476c77"
|
||||
},
|
||||
@@ -21,6 +21,9 @@
|
||||
"vendor-dir": "./"
|
||||
},
|
||||
"scripts": {
|
||||
"post-update-cmd": "git clean -d -f -X ."
|
||||
"post-update-cmd": [
|
||||
"git clean -d -ff -X .",
|
||||
"find . -name '.git' -type d -exec rm -rf {} + || true"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Translate CSS selectors to XPath queries
|
||||
========================================
|
||||
Translate CSS selectors to XPath queries.
|
||||
=========================================
|
||||
|
||||
A lightweight and dependency free CSS to XPath translator. This repository is used to bring modern DOM functionality like [`querySelectorAll()`][qsa] to PHP in the [PHP.Gt/Dom][gt-dom] project.
|
||||
|
||||
@@ -61,3 +61,9 @@ It's perhaps worth noting that for XML-style matching to work, you must load the
|
||||
|
||||
[qsa]: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
|
||||
[gt-dom]: https://www.php.gt/dom
|
||||
|
||||
# Proudly sponsored by
|
||||
|
||||
[JetBrains Open Source sponsorship program](https://www.jetbrains.com/community/opensource/)
|
||||
|
||||
[](https://www.jetbrains.com/community/opensource/)
|
||||
|
||||
@@ -12,6 +12,7 @@ class Translator {
|
||||
. '|(#(?P<id>[\w-]*))'
|
||||
. '|(\.(?P<class>[\w-]*))'
|
||||
. '|(?P<sibling>\s*\+\s*)'
|
||||
. '|(?P<subsequentsibling>\s*~\s*)'
|
||||
. "|(\[(?P<attribute>[\w-]*)((?P<attribute_equals>[=~$|^*]+)(?P<attribute_value>(.+\[\]'?)|[^\]]+))*\])+"
|
||||
. '|(?P<descendant>\s+)'
|
||||
. '/';
|
||||
@@ -24,8 +25,8 @@ class Translator {
|
||||
const EQUALS_STARTS_WITH = "^=";
|
||||
|
||||
public function __construct(
|
||||
protected string $cssSelector,
|
||||
protected string $prefix = ".//",
|
||||
protected string $cssSelector,
|
||||
protected string $prefix = ".//",
|
||||
protected bool $htmlMode = true
|
||||
) {
|
||||
}
|
||||
@@ -198,7 +199,7 @@ class Translator {
|
||||
"[last()]"
|
||||
);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -235,6 +236,14 @@ class Translator {
|
||||
$hasElement = false;
|
||||
break;
|
||||
|
||||
case "subsequentsibling":
|
||||
array_push(
|
||||
$xpath,
|
||||
"/following-sibling::"
|
||||
);
|
||||
$hasElement = false;
|
||||
break;
|
||||
|
||||
case "attribute":
|
||||
if(!$hasElement) {
|
||||
array_push($xpath, "*");
|
||||
|
||||
Reference in New Issue
Block a user