1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-15 01:49:55 +00:00
TiddlyWiki5/core/modules/filters/encodings.js
cdruan 3b35411aba
Change css-escape-polyfill to a tw uitility method (#5552)
* Replace css-escape-polyfill.js with escapecss.js utility module

* Add $tw.utils.escapeCSS() method and invoke that function within the
  escapecss operator.

* Add test cases for the "escapecss" filter operator

* Fix $tw.boot.doesTaskMatchPlatform() so it works as expected if
  a module's export.platforms contains more than one values

* Add missed files to the last commit
2021-04-02 09:25:01 +01:00

111 lines
2.3 KiB
JavaScript

/*\
title: $:/core/modules/filters/decodeuricomponent.js
type: application/javascript
module-type: filteroperator
Filter operator for applying decodeURIComponent() to each item.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter functions
*/
exports.decodeuricomponent = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
var value = title;
try {
value = decodeURIComponent(title);
} catch(e) {
}
results.push(value);
});
return results;
};
exports.encodeuricomponent = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push(encodeURIComponent(title));
});
return results;
};
exports.decodeuri = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
var value = title;
try {
value = decodeURI(title);
} catch(e) {
}
results.push(value);
});
return results;
};
exports.encodeuri = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push(encodeURI(title));
});
return results;
};
exports.decodehtml = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push($tw.utils.htmlDecode(title));
});
return results;
};
exports.encodehtml = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push($tw.utils.htmlEncode(title));
});
return results;
};
exports.stringify = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push($tw.utils.stringify(title,(operator.suffix === "rawunicode")));
});
return results;
};
exports.jsonstringify = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push($tw.utils.jsonStringify(title,(operator.suffix === "rawunicode")));
});
return results;
};
exports.escaperegexp = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push($tw.utils.escapeRegExp(title));
});
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($tw.utils.escapeCSS(title));
});
return results;
};
})();