Word count as a number, not a link and while editing

Based on the discussion here, I have edited a view template to display a wordcount of a tiddler. Here is the relevant line:

Words: {{{ [all[current]get[text]splitregexp[\s+]count[]] }}}

The wordcount is displayed as a link! How do I get it to display just the number?

Also, can one display the wordcount while editing? That would be super useful. May be, next to the ‘Type’ at the bottom of the editor window, a counter is displayed?

<$text text={{{ [all[current]get[text]splitregexp[\s+]count[]] }}}/>
1 Like

@CodaCoder Perfect. Thanks.

Now, if only I could display it while editing :slight_smile:

1 Like

The wordcount is displayed as a link! How do I get it to display just the number?

Use the <$text> widget, like this:

Words: <$text text={{{ [all[current]get[text]splitregexp[\s+]count[]] }}}/>

Also, can one display the wordcount while editing? That would be super useful. May be, next to the ‘Type’ at the bottom of the editor window, a counter is displayed?

  1. Create a tiddler (e.g., “ShowEditorWordCount”), tagged with $:/tags/EditTemplate, containing:
@@float:right; Words: <$text text={{{ [all[current]get[text]splitregexp[\s+]count[]] }}}/>@@
  1. Then, while viewing this tiddler, click on the “$:/tags/EditTemplate” tag “pill” and drag-and-drop the “ShowEditorWordCount” title so it is above “$:/core/ui/EditTemplate/type”

enjoy,
-e

5 Likes

@EricShulman That worked like a charm. Thanks!

Worth to be moved to #how-to

Minor improvement!

To ignore empty output from splitregexp use

@@float:right; Words: <$text text={{{ [all[current]get[text]splitregexp[\s+]!is[blank]count[]] }}}/>@@

3 Likes

Just for the record: There is an older plugin called EditorCounter that does count words and characters – also for the title if desired. And it does some other tricks too:
https://tid.li/tw5/plugins.html

2 Likes

As usual, this forum conveys a sense of serendipity in sharp contrast with all the “instant” messaging community platforms. Just few moments ago I was “tiddlywikifying” a research proposal and just in moments I get the proper plugins to customize the writing experience I wanted to share with my co-researchers, just by adding @telmiger plugin and the words number preview derived from this conversation. Thank you all for making and answering this question and build upon each other participation :yellow_heart:

5 Likes