I tried to follow https://tiddlywiki.com/dev/ in order to create a new
filter module plugin, but I cannot even see (with console.log) that it is
actually use :(
What did I do wrong?
$:/plugins/skeeve/filter-pick
{
"tiddlers": {
"$:/plugins/skeeve/filter-pick/pick.js": {
"created": "20180212142125038",
"text": "/*\\\ntitle:
$:/plugins/skeeve/filter-pick/pick.js\ntype:
application/javascript\nmodule-type: filteroperator\n\nFilter operator for
regexp matching and picking out capturing
groups\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true
*/\n/*global $tw: false */\n\"use strict\";\n\n/*\nExport our filter
function\n*/\nexports.pick = function(source,operator,options) {\n\tvar
results = [],\n\t\tfieldname = (operator.suffix ||
\"title\").toLowerCase(),\n\t\tregexpString, regexp, flags = \"\",
match,\n\t\tgetFieldString = function(tiddler,title) {\n\t\t\tif(tiddler)
{\n\t\t\t\treturn tiddler.getFieldString(fieldname);\n\t\t\t} else
if(fieldname === \"title\") {\n\t\t\t\treturn title;\n\t\t\t} else
{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t};\n\t// Process flags and construct
regexp\n\tregexpString = operator.operand;\n\tmatch =
/^\\(\\?([gim]+)\\)/.exec(regexpString);\n\tif(match) {\n\t\tflags =
match[1];\n\t\tregexpString = regexpString.substr(match[0].length);\n\t}
else {\n\t\tmatch = /\\(\\?([gim]+)\\)$/.exec(regexpString);\n\t\tif(match)
{\n\t\t\tflags = match[1];\n\t\t\tregexpString =
regexpString.substr(0,regexpString.length -
match[0].length);\n\t\t}\n\t}\n\tvar global= flags.indexOf('g') >
-1;\n\ttry {\n\t\tregexp = new RegExp(regexpString,flags);\n\t} catch(e)
{\n\t\treturn [\"\" + e];\n\t}\n\t// Process the incoming
tiddlers\n\tif(operator.prefix === \"!\")
{\n\t\tsource(function(tiddler,title) {\n\t\t\tvar text =
getFieldString(tiddler,title);\n\t\t\tif(text !== null)
{\n\t\t\t\tif(!regexp.exec(text))
{\n\t\t\t\t\tresults.push(title);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t} else
{\n\t\tsource(function(tiddler,title) {\n\t\t\tvar text =
getFieldString(tiddler,title);\n\t\t\tif(text !== null) {\n\t\t\t\tvar
m;\n\t\t\t\twhile (m = regexp.exec(text)) {\n\t\t\t\t\tif (m.length == 1)
{\n\t\t\t\t\t\tresults.push(title);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(m);\n\t\t\t\t\tfor
(var i=1; i<m.length;++i)
{\n\t\t\t\t\t\tresults.push(m[i]);\n\t\t\t\t\t}\n\t\t\t\t\tif ( ! global )
{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\treturn
results;\n};\n\n})();",
"title": "$:/plugins/skeeve/filter-pick/pick.js",
"tags": "",
"modified": "20180212142631802",
"type": "application/javascript"
}
}
}
type: application/json
description: a filter to pick out text using regular expressions
plugin-type: plugin
version: 0.02
There is a console.log in but when I use the filter
<$list filter="pick:text[(?gi)auf der (\w+)]]">
</$list>
nothing is logged at all.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/b18eda88-b96a-4a72-9c58-18552e19105b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.