Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this work on iOS/iPad OS? #30

Open
vishae opened this issue Nov 20, 2021 · 3 comments
Open

Does this work on iOS/iPad OS? #30

vishae opened this issue Nov 20, 2021 · 3 comments

Comments

@vishae
Copy link

@vishae vishae commented Nov 20, 2021

I don’t know where to find the word count on the iOS/iPad OS version of Obsidian. There doesn't seem to be a status bar and better word count doesn't show up in the right slidebar (where the core word count plugin shows up).
Is there some settings I need to change?

@colintedford
Copy link

@colintedford colintedford commented Jan 1, 2022

Same problem. I don't see a setting, so I assume it's a bug.

@lukeleppan
Copy link
Owner

@lukeleppan lukeleppan commented Jan 16, 2022

Hi thanks for raising the issue. Mobile versions don't have a status bar. So displaying the word count in that way is not possible. However, the statistic collection function is still functional and will detect writing stats over all your devices. In the future you will be able to view your statistics on mobile too.

@colintedford
Copy link

@colintedford colintedford commented Jan 30, 2022

Until this feature is officially supported, here is a workaround for iOS/iPadOS 15 (should also work on MacOS Monterey but I haven't tested that yet).

This is my setup, which assumes you want to exclude comments from the count, but only excludes HTML-style comments (which I use for wider compatibility, along with text replacement to make typing them easier). Adjust as needed.

In the Shortcut Launcher community plugin, create a new launcher:
- Command Name: Word count minus comments

  • Shortcut name: Obsidian Word Count Minus Comments
  • Input Type: Multiple
    • Input Type #1: Selected Text
    • Input Type #2: Entire Document
    • Separator: %%OSL%%

Install my Obsidian Word Count Minus Comments shortcut or make a similar one. Obsidian Word Count Minus Comments does the following:

Split Shortcut Input by Custom %%OSL%%
// The “_” here stands for a blank field in Shortcuts.
Replace (?=<!--)([\s\S]*?)--> with _ in Split Text
Get First Item from Updated Text
Set variable SelectionText to Item from List
Get Last Item from Updated Text
Set variable DocumentText to Item from List
Count Words in SelectionText
Set variable SelectionCount to Count
Count Words in DocumentText
Set variable DocumentCount to Count
// The space between “SelectionCount” and “Document” here stands for a newline in Shortcuts.
Show Selection: SelectionCount Document: DocumentCount

The comment exclusion in my shortcut isn't perfect. If you have malformed comments like

<!--Comment 1, which I forgot to close
<!--
Comment 2
-->

it will count all of those words.

On mobile you can’t pull down to summon the command palette when text is selected, but you can add the command palette button or your new “Word count minus comments” command to the mobile toolbar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants