isaaclyman / novel-word-count-obsidian

Obsidian plugin. Displays a word count or other statistic for each file, folder and vault in the File Explorer pane.
https://obsidian.md/plugins?id=novel-word-count
MIT License
82 stars 8 forks source link

Display canvas word counts #80

Closed LiamSwayne closed 7 months ago

LiamSwayne commented 7 months ago

Problem

Canvas word counts are not displayed.

Idea

Sum the word counts of the text-block nodes in canvas, excluding embedded notes and embedded canvases. These text blocks can then be parsed like regular notes. This would give an accurate count of the words exclusive to the canvas and would avoid counting embedded notes' word counts multiple times.

isaaclyman commented 7 months ago

Canvas files are stored in JSON format as follows:

{
    "nodes":[
        {"id":"beba9a4110250da2","x":46,"y":-118,"width":400,"height":400,"type":"file","file":"Languages/Japanese (325w).md"},
        {"id":"1376822f2272ea36","x":-280,"y":-240,"width":250,"height":60,"type":"text","text":"Custom text has five words"}
    ],
    "edges":[]
}

It should be possible to parse them and get a word count from the text nodes, but I'll have to do some research.

isaaclyman commented 7 months ago

Fixed in v3.7.0.

LiamSwayne commented 7 months ago

Thanks so much for implementing this, it's really nice to have!