mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-25 06:44:47 +00:00
Add macro operator (#9520)
* Add macro operator * Replace unnecessary usage of wikify widget * Simplify multiple let widget * fixup! Replace unnecessary usage of wikify widget * Update tests * Update change note * fixup! Replace unnecessary usage of wikify widget * Update docs * fixup! Update tests
This commit is contained in:
@@ -1088,6 +1088,10 @@ Tests the filtering mechanism.
|
||||
expect(wiki.filterTiddlers("[[representation]makepatches[misreprehensionisation]]").join(" ")).toBe("@@ -1,13 +1,21 @@\n+mis\n repre\n-sent\n+hensionis\n atio\n");
|
||||
expect(wiki.filterTiddlers("[[the cat sat on the mat]makepatches[the hat saw in every category]]").join(" ")).toBe("@@ -1,22 +1,29 @@\n the \n-c\n+h\n at sa\n-t on the mat\n+w in every category\n");
|
||||
});
|
||||
|
||||
it("should handle the macro operator", () => {
|
||||
expect(wiki.filterTiddlers("[macro[makedatauri],[some example text],[text/plain]]").join("")).toBe("data:text/plain,some%20example%20text");
|
||||
});
|
||||
|
||||
it("should parse filter variable parameters", function(){
|
||||
expect($tw.utils.parseFilterVariable("currentTiddler")).toEqual(
|
||||
|
||||
7
editions/tw5.com/tiddlers/macro Operator (Examples).tid
Normal file
7
editions/tw5.com/tiddlers/macro Operator (Examples).tid
Normal file
@@ -0,0 +1,7 @@
|
||||
created: 20260104045032090
|
||||
modified: 20260104045240842
|
||||
tags: [[macro Operator]]
|
||||
title: macro Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[macro[now],{$:/config/NewJournal/Title}]">>
|
||||
14
editions/tw5.com/tiddlers/macro Operator.tid
Normal file
14
editions/tw5.com/tiddlers/macro Operator.tid
Normal file
@@ -0,0 +1,14 @@
|
||||
caption: macro
|
||||
created: 20260104043647022
|
||||
modified: 20260104045136808
|
||||
op-input: ignored
|
||||
op-output: the result of the javascript macro
|
||||
op-parameter: first parameter is the javascript macro, subsequent parameters are passed to the macro by position
|
||||
op-purpose: return the result from a javascript macro (with indirect parameters support)
|
||||
tags: [[Filter Operators]]
|
||||
title: macro Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.4.0">> The <<.op macro>> operator applies a javascript macro to the input titles, and returns the result from the macro. The function is invoked once with all of the input titles.
|
||||
|
||||
<<.operator-examples "macro">>
|
||||
@@ -0,0 +1,10 @@
|
||||
title: $:/changenotes/5.4.0/#9520
|
||||
description: Add macro operator
|
||||
release: 5.4.0
|
||||
tags: $:/tags/ChangeNote
|
||||
change-type: feature
|
||||
change-category: filters
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9520
|
||||
github-contributors: Leilei332
|
||||
|
||||
Added [[macro Operator]] for evaluating javascript macros in filters.
|
||||
Reference in New Issue
Block a user