Am Mittwoch, 10. Dezember 2014 11:15:12 UTC+1 schrieb AlexHough:
>
> Is there an update for TW 5 for this [1]
>
> ALex
>
> [1] http://wordcountmacro.tiddlyspot.com/
>
Is this sufficient?
/*\
title: $:/macros/skeeve/wordcount.js
type: application/javascript
module-type: macro
<<wordcount text>>
Examples:
<<wordcount "sometext">>
<<wordcount tiddler:"tiddlertitle">>
<$macrocall $name="wordcount" text="sometext"/>
<$macrocall $name="wordcount" tiddler={{!!title}}/>
Inspired by: http://wordcountmacro.tiddlyspot.com/
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
This is a macro to get the number of "words" of a string/text or a tiddler.
*/
exports.name = "wordcount";
exports.params = [
{ name: "text" },
{ name: "tiddler" },
];
/*
Run the macro
*/
exports.run = function(text, tiddler) {
if(!text) {
if(!tiddler) {
return "0";
}
text = tiddler + " " + ($tw.wiki.getTiddlerText(tiddler) || "");
}
return text.match(/\w+/g).length.toString() || "0";
};
})();
--
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 http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.