Jollywatt / typst-wordometer

A small Typst package for quick and easy in-document word counts.
MIT License
18 stars 1 forks source link

Exclude after a certain point? #4

Open dantechguy opened 6 months ago

dantechguy commented 6 months ago

Hi! Thanks for the lovely package :)

Just wondering if it's possible to turn off the word count later on in the document after the initial show rule? E.g. I'd like to include the first few chapters, but would like to exclude the bibliography and appendices. I'd rather not wrap those whole sections in a giant content block and tag and exclude those! ;)

Many thanks, Dan

Jollywatt commented 6 months ago

Just a note, the bibliography is never included in the word count (because word-count-of sees the bibliography element before it is populated), so you don't have to do anything to exclude it.

But for excluding appendices, I'm afraid you will have to group everything you want to exclude in a block (and exclude it by label) because selectors like selector(<appendix>).after() aren't supported…

It's conceivable that we could add a feature where user could insert

#suspend-wordcount

somewhere to tell wordometer to ignore everything after that point. That might be easier than dealing with blocks?

dantechguy commented 6 months ago

Thanks for the quick reply -- yeah! Something like #suspend-wordcount would be amazing! This is a tall ask so I fully understand a "no", but is there any chance this will be added within the next few days? My dissertation is due on Friday! ;) I'd be happy to download a specific branch and use a local version if needed. Thank you!

Jollywatt commented 6 months ago

Does the solution to enclose the appendices in #[ ... ] <no-wc> and exclude <no-wc> work in the meantime?

I really like the suspend/resume word count idea, but I'm not exactly sure how it could be implemented yet… so I wouldn't count on that happening!

dantechguy commented 6 months ago

Ah okay! Thanks for letting me know :) I'll use the workaround in that case 👍

1dancook commented 3 months ago

I was able to do this with a secondary show rule. My document is set up in a more complicated way, but I think it boils down to this:


#let appendix(body) = {
    [#body <no-wc>]
}

#show: word-count.with(exclude: <no-wc>)
main body

#show: appendix
appendices

Perhaps that idea could be adapted/extended to the 'suspend-word-count' idea:

#show: word-count
text

#show: suspend-word-count
text

#show: continue-word-count
text