Skip to content

Is there a reverse operator to "stringify[]" or "jsonstringify[]"? #6095

Answered by pimgeek
pimgeek asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it by creating 2 customized String Filter operators. Is there any non-intrusive way to achieve this?

exports['js-escape'] = function(source,operator,options) {
    var results = [];
    source(function(tiddler,title) {
        results.push(escape(title));
    });
    return results;
};

exports['js-unescape'] = function(source,operator,options) {
    var results = [];
    source(function(tiddler,title) {
        results.push(unescape(title));
    });
    return results;
};

Then I use them to escape and unescape:

\define ascii-regex() ([\u0000-\u007f])
{{{ 'abc一二三' +[search-replace:g:regexp<ascii-regex>,[$1..]js-escape[]split[]first[15]join[]search-replace:g:regexp[\.\.],[]js-un…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by pimgeek
Comment options

You must be logged in to vote
2 replies
@pimgeek
Comment options

@saqimtiaz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants