Add escapecss filter (#3546)

* add escapecss filter

this filter would allow creating valid css classes from titles containing special characters

we assign a class to an element using `encodeuricomponent[]` so that the class name is encoded

in a stylesheet we create the classname by `<title>escapecss[]` which applies the uri encoding and escapes characters that need to be escaped

* Update encodings.js

* refactor tagToCssSelector, add escapeCssSelector

* use escapeCssSelector

* escape using CSS.escape if it's available

* Update encodings.js

* revert factoring out escapeCssSelector
fix-syncer
Simon Huber 2019-06-26 13:32:01 +02:00 zatwierdzone przez Jeremy Ruston
rodzic e313b0b7ca
commit 69d3a47073
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -98,4 +98,13 @@ exports.escaperegexp = function(source,operator,options) {
return results;
};
exports.escapecss = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
// escape any character with a special meaning in CSS using CSS.escape()
results.push(CSS.escape(title));
});
return results;
};
})();