lukeleppan / better-word-count

Counts the words of selected text in the editor.
MIT License
256 stars 40 forks source link

[Feature Request] Custom word/[*]-counting algorithm #44

Open alt-jero opened 2 years ago

alt-jero commented 2 years ago

Custom counting algorithm

Intro

There is a whole world of word-counting algorithms! Particularly I'm interested in the one from 750Words because I import my ... words... words... from there into my dailies, and would like the word-count to match. I could, however, imagine that others have their own varied word-counting-wishes. To that end...

Suggestion

Create a settings page for the plugin with a blank text area. Allow a javascript function in that text area to serve as a customised algorithm for displaying word-counts. Possibly add a list of common variants to pre-fill.

Function Specification:

Inputs:

Output: Object containing any one or more of the following:

OR just a plain integer representing the word-count for super simple variants.

Conclusion

With this, the user can supply whatever count-information they want for the selected text, and have it show up in the status bar!

Also suggest adding an easter-egg where if someone outputs an object containing 'countDracula' it shows it with a bat or vampire emoji 😝

lukeleppan commented 1 year ago

Wow this is the best feature request I've received. I'm sorry to be nine months late to the party. Yes this is a good idea. However, I would like to keep the plugin user friendly. Please take a look at the latest update of the plug-in and let me know your opinions on how I set up the custom status bar, bare in mind that there will be more metrics available over time. I love the Easter egg idea. Brilliant.

lukeleppan commented 1 year ago

Actually upon a few more seconds of consideration. Maybe an advanced section may be necessary. Where a more dedicated person could get what they truly desire by adding there custom function.

ReaderGuy42 commented 1 year ago

Actually upon a few more seconds of consideration. Maybe an advanced section may be necessary. Where a more dedicated person could get what they truly desire by adding there custom function.

Hey, would it be possible to use this advanced section to count pages? That would just be "wordcount / custom number", so e.g. often about 300 words per page are used, so it could put out that a note with 700 words has 2.1 pages.

Would this be possible?

So far I've been using a cobbled together plugin, but it doesn't update the count very well.

Thanks :)

lukeleppan commented 1 year ago

This is actually a feature that will be normal users in which operations can be placed onto counts with other counts and constant numbers.

ReaderGuy42 commented 1 year ago

Awesome :) any idea when this might be ready? Thanks!

lukeleppan commented 1 year ago

I really don't want to put an ETA on anything right now. But it is a priority to get the metric system working well before implementing other things.

MalignantCarp commented 11 months ago

I second this request in as much as I would like to add my own regex for counting words. I have never been particularly enamoured by how many edge cases come up with how Obsidian by default counts words. Em-dashes are trouble because there is no white space on either side, so two words separated by an em-dash (as will typically happen with parenthetical statements) will count as one word. In a similar vein, a single hyphen with a space on either side counts as a word, but it is not.

In a similar vein, in terms of sanitizing text prior to sending it to one of these custom functions, my own plugin for word counts also has a function to sanitize some text and take the "visible" link for internal links and count those words instead of the entire link block including the visible text. I'm not sure if that is the case right now with this plugin, but it would definitely be a useful option.