Skip to content

Commit 4c1dc85

Browse files
committed
Support $&$TITLE, $TITLE$&, and analogously with $NAME and $URL
2 parents 31f657d + 523e976 commit 4c1dc85

File tree

9 files changed

+55
-16
lines changed

9 files changed

+55
-16
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
Martin Väth <martin at mvath.de>:
55
- Remove support for stripping descriptions
66

7+
*bookmarkdupes-6.4:
8+
Martin Väth <mvath at mvath.de>:
9+
- Support $&$TITLE, $TITLE$&, and analogously with $NAME and $URL:
10+
https://github.com/vaeth/bookmarkdupes/issues/94
11+
712
*bookmarkdupes-6.3:
813
Martin Väth <mvath at mvath.de>:
914
- Fix strip bookmarks and moving to "Dupes" folder: Regression from 6.1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ several rules to work around that limitation if necessary.)
119119
5. `$TITLE` is the bookmark's title without the path; for instance, for the
120120
bookmark name “Bookmark Menu | Collection | Example” it is “Example”.
121121

122+
Cases 3-5 can be preceeded or followed by `$$&` to prepend or append the match.
123+
122124
## Examples for special tasks which can be done in Expert Mode
123125

124126
### Task

_locales/de/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"description": "Input field for the replacement text for the regular expression matches. The text should be short"
9797
},
9898
"titleRuleReplace": {
99-
"message": "Der Ersetzungstext für den passenden Teil des regulären Ausdrucks. Symbole wie $$& oder $$1 können benutzt werden, um auf Treffer oder Klammern zu verweisen. Die speziellen Texte \\L$$& und \\U$$& bedeuten eine klein- bzw. großgeschriebene Version der Treffer. Die speziellen Texte $URL, $NAME und $TITLE bedeuten die ursprüngliche (unmodifizierte) URL bzw. den Lesezeichennamen/-Titel (mit bzw. ohne vollen Pfad).",
99+
"message": "Der Ersetzungstext für den passenden Teil des regulären Ausdrucks. Symbole wie $$& oder $$1 können benutzt werden, um auf Treffer oder Klammern zu verweisen. Die speziellen Texte \\L$$& und \\U$$& bedeuten eine klein- bzw. großgeschriebene Version der Treffer. Die speziellen Texte $$URL, $$NAME und $$TITLE bedeuten die ursprüngliche (unmodifizierte) URL bzw. den Lesezeichennamen/-Titel (mit bzw. ohne vollen Pfad). Den letzten drei kann ein $$& vor- oder nachgestellt sein, um den Treffer vorne oder hinten anzuhängen.", // new
100100
"description": "Explain that the text will be used as replacement text for the regular expression matches"
101101
},
102102
"buttonRuleUp": {

_locales/en/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"description": "Input field for the replacement text for the regular expression matches. The text should be short"
9797
},
9898
"titleRuleReplace": {
99-
"message": "The replacement text for the regular expresssion matches. Symbols like $$& or $$1 can be used to refer to the match or a brace content. The special texts \\L$$& and \\U$$& mean a lower and upper case version of the matches, respectively. The special texts $URL, $NAME, and $TITLE mean the original (unmodified) URL and the bookmark full name/title (with/without path), respectively.",
99+
"message": "The replacement text for the regular expresssion matches. Symbols like $$& or $$1 can be used to refer to the match or a brace content. The special texts \\L$$& and \\U$$& mean a lower and upper case version of the matches, respectively. The special texts $$URL, $$NAME, and $$TITLE mean the original (unmodified) URL and the bookmark full name/title (with/without path), respectively. The latter three can be preceeded or followed by $$& to prepend or append the original match",
100100
"description": "Explain that the text will be used as replacement text for the regular expression matches"
101101
},
102102
"buttonRuleUp": {

_locales/es/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"description": "Input field for the replacement text for the regular expression matches. The text should be short"
9797
},
9898
"titleRuleReplace": {
99-
"message": "El texto de reemplazo para la expresión regular coincide. Se pueden usar símbolos como $$& o $$1 para referirse a la coincidencia o un contenido de corchete. Los textos especiales \\L$$& y \\U$$& significan una versión en mayúsculas y minúsculas de las coincidencias, respectivamente. Los textos especiales $URL, $NAME y $TITLE significan la URL original (sin modificar) y el nombre completo / título del marcador (con / sin ruta), respectivamente.",
99+
"message": "El texto de reemplazo para la expresión regular coincide. Se pueden usar símbolos como $$& o $$1 para referirse a la coincidencia o un contenido de corchete. Los textos especiales \\L$$& y \\U$$& significan una versión en mayúsculas y minúsculas de las coincidencias, respectivamente. Los textos especiales $$URL, $$NAME y $$TITLE significan la URL original (sin modificar) y el nombre completo / título del marcador (con / sin ruta), respectivamente. The latter three can be preceeded or followed by $$& to prepend or append the original match", // new
100100
"description": "Explain that the text will be used as replacement text for the regular expression matches"
101101
},
102102
"buttonRuleUp": {

_locales/ru/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"description": "Input field for the replacement text for the regular expression matches. The text should be short"
9797
},
9898
"titleRuleReplace": {
99-
"message": "Текст замены по соответствию регулярному выражению. Символы типа $$& или $$1 могут использоваться для обозначения соответствий или содержимого скобок (). Специальные тексты \\L$$& и \\U$$& означают нижний и верхний регистр соответствий. Специальные тексты $URL, $NAME, $TITLE означают начальные (немодифицированные) URL-ы и полные названия/заголовки закладок (с/без пути) соответственно.",
99+
"message": "Текст замены по соответствию регулярному выражению. Символы типа $$& или $$1 могут использоваться для обозначения соответствий или содержимого скобок (). Специальные тексты \\L$$& и \\U$$& означают нижний и верхний регистр соответствий. Специальные тексты $$URL, $$NAME, $$TITLE означают начальные (немодифицированные) URL-ы и полные названия/заголовки закладок (с/без пути) соответственно. The latter three can be preceeded or followed by $$& to prepend or append the original match", // new
100100
"description": "Explain that the text will be used as replacement text for the regular expression matches"
101101
},
102102
"buttonRuleUp": {

_locales/uk/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"description": "Input field for the replacement text for the regular expression matches. The text should be short"
9797
},
9898
"titleRuleReplace": {
99-
"message": "Текст заміни по відповідності регулярному виразу. Символи типу $$& чи $$1 можуть використовуватися для позначення відповідностей чи вмісту дужок (). Спеціальні тексти \\L$$& та \\U$$& означають нижній та верхній регістр відповідно. Спеціальні тексти $URL, $NAME, $TITLE означають початкові (немодифіковані) URL-и і повні назви/заголовки закладок (з/без шляху) відповідно.",
99+
"message": "Текст заміни по відповідності регулярному виразу. Символи типу $$& чи $$1 можуть використовуватися для позначення відповідностей чи вмісту дужок (). Спеціальні тексти \\L$$& та \\U$$& означають нижній та верхній регістр відповідно. Спеціальні тексти $$URL, $$NAME, $$TITLE означають початкові (немодифіковані) URL-и і повні назви/заголовки закладок (з/без шляху) відповідно. The latter three can be preceeded or followed by $$& to prepend or append the original match", // new
100100
"description": "Explain that the text will be used as replacement text for the regular expression matches"
101101
},
102102
"buttonRuleUp": {

_locales/zh_CN/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"description": "Input field for the replacement text for the regular expression matches. The text should be short"
9797
},
9898
"titleRuleReplace": {
99-
"message": "The replacement text for the regular expresssion matches. Symbols like $$& or $$1 can be used to refer to the match or a brace content. The special texts \\L$$& and \\U$$& mean a lower and upper case version of the matches, respectively. The special texts $URL, $NAME, and $TITLE mean the original (unmodified) URL and the bookmark full name/title (with/without path), respectively.", // new
99+
"message": "The replacement text for the regular expresssion matches. Symbols like $$& or $$1 can be used to refer to the match or a brace content. The special texts \\L$$& and \\U$$& mean a lower and upper case version of the matches, respectively. The special texts $$URL, $$NAME, and $$TITLE mean the original (unmodified) URL and the bookmark full name/title (with/without path), respectively. The latter three can be preceeded or followed by $$& to prepend or append the original match", // new
100100
"description": "Explain that the text will be used as replacement text for the regular expression matches"
101101
},
102102
"buttonRuleUp": {

data/tab/dupes.js

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,12 +1565,36 @@ function compileRules(mode) {
15651565
compiledRule.replace = 0;
15661566
compiledRules.needSpecials = true;
15671567
break;
1568-
case "\$NAME":
1568+
case "\$\&\$URL":
15691569
compiledRule.replace = 1;
1570+
compiledRules.needSpecials = true;
1571+
break;
1572+
case "\$URL\$\&":
1573+
compiledRule.replace = 2;
1574+
compiledRules.needSpecials = true;
1575+
break;
1576+
case "\$NAME":
1577+
compiledRule.replace = 3;
1578+
compiledRules.needSpecials = compiledRules.needName = true;
1579+
break;
1580+
case "\$\&\$NAME":
1581+
compiledRule.replace = 4;
1582+
compiledRules.needSpecials = compiledRules.needName = true;
1583+
break;
1584+
case "\$NAME\$\&":
1585+
compiledRule.replace = 5;
15701586
compiledRules.needSpecials = compiledRules.needName = true;
15711587
break;
15721588
case "\$TITLE":
1573-
compiledRule.replace = 2;
1589+
compiledRule.replace = 6;
1590+
compiledRules.needSpecials = true;
1591+
break;
1592+
case "\$\&\$TITLE":
1593+
compiledRule.replace = 7;
1594+
compiledRules.needSpecials = true;
1595+
break;
1596+
case "\$TITLE\$\&":
1597+
compiledRule.replace = 8;
15741598
compiledRules.needSpecials = true;
15751599
break;
15761600
default:
@@ -1611,8 +1635,14 @@ function rulesFilter(compiledRules, folders, parent, title, url, processed) {
16111635
const originalUrl = url;
16121636
specials = [
16131637
function () { return originalUrl; },
1638+
function (found) { return found.concat(originalUrl); },
1639+
function (found) { return originalUrl.concat(found); },
16141640
function () { return name; },
1615-
function () { return title; }
1641+
function (found) { return found.concat(name); },
1642+
function (found) { return name.concat(found); },
1643+
function () { return title; },
1644+
function (found) { return found.concat(title); },
1645+
function (found) { return title.concat(found); }
16161646
];
16171647
}
16181648
let extra;
@@ -2244,17 +2274,19 @@ function initMain() {
22442274
let state = {};
22452275
let rules;
22462276
const rulesDefault = [
2247-
{ radio: "url", search: "^\\w+://[^\/]*/", replace: "\\L$&" },
2277+
{ radio: "url", search: "^\\w\+://\[\^\/\]*/", replace: "\\L\$\&" },
22482278
{ radio: "filter", name:
2249-
"^[^\\0]+\\0" + compatible.getMessage("regExpTrashFolder") + "\\0" },
2279+
"^[^\\0]\+\\0" + compatible.getMessage("regExpTrashFolder") + "\\0" },
22502280
{ radio: "off", nameNegation: "\\0.*\\0" },
2251-
{ radio: "off", urlNegation: "\\b(e?mail|bugs|youtube|translat)\\b",
2281+
{ radio: "off", urlNegation: "\\b\(e?mail|bugs|youtube|translat\)\\b",
22522282
search: "\\?.*" },
2253-
{ radio: "off", search: "/[^/]*$" },
2254-
{ radio: "url", search: "/+(index\\.html)?$" },
2283+
{ radio: "off", search: "/[^/]*\$" },
2284+
{ radio: "url", search: "/\+\(index\\.html\)?\$" },
22552285
{ radio: "url", search: "^http:", replace: "https:" },
2256-
{ radio: "url", search: "^([^:]*://)www?\\d*\\.", replace: "$1" },
2257-
{ radio: "url", search: "\\.htm$", replace: ".html" }
2286+
{ radio: "url", search: "^([^:]*://)www?\\d*\\.", replace: "\$1" },
2287+
{ radio: "url", search: "\\.htm\$", replace: ".html" },
2288+
{ radio: "off", search: ".\+", replace: "\$\&\$TITLE" },
2289+
{ radio: "off", search: ".\+", replace: "DEBUG: \$\&" }
22582290
];
22592291
let mutationObserver;
22602292

0 commit comments

Comments
 (0)