Compare commits

...

34 commits

Author SHA1 Message Date
Luke Leppan
3f7ec6561e
bump: version 0.9.6 2023-03-30 01:15:51 +02:00
Luke Leppan
8e7860d510
add: should be able to remove those comments 2023-03-30 01:14:00 +02:00
Luke Leppan
141c39dbb7
bump: version 0.9.5 2023-03-30 00:58:33 +02:00
Luke Leppan
0a208ea8ef
Merge pull request #79 from chrisgrieser/master
Feat: Option to add Citations / Footnote Counts
2023-03-30 00:52:31 +02:00
Luke Leppan
d2f99e548a
fix: issue from merge conflict 2023-03-30 00:50:06 +02:00
Luke Leppan
66c00b24c2
Merge branch 'master' into master 2023-03-30 00:38:07 +02:00
Luke Leppan
437547f02e
Merge pull request #76 from minermaniac447/master 2023-03-30 00:03:09 +02:00
Luke Leppan
0712d9f61a
fix: calculating with currentSentences instead of page 2023-03-30 00:01:11 +02:00
Luke Leppan
d3b6938e48
Merge pull request #74 from bakuzan/master
Allow better word count to correctly reflect selection count when using shift+home
2023-03-29 23:36:11 +02:00
Luke Leppan
b2a43d9ca3
update readme 2023-03-28 21:20:01 +02:00
Luke Leppan
9bbeeff386
update readme 2023-03-28 21:06:34 +02:00
pseudometa
4a7ed4730c fix: citation and footnote actually displaying 2023-02-17 13:56:18 +01:00
pseudometa
3412745204 fix: settings for footnotes and citations 2023-02-17 11:52:47 +01:00
pseudometa
fee3421508 docs: fix typos 2023-02-17 11:41:36 +01:00
pseudometa
b2ef959464 feat: add footnote & pandoc citation count 2023-02-17 11:40:51 +01:00
minermaniac447
86ca1199cc
Fix TS Build Mistakes 2023-02-08 18:25:43 -05:00
minermaniac447
d865d61e23
Fix TS Build Mistakes 2023-02-08 18:16:09 -05:00
minermaniac447
ec21413d55
Fix TS Build Mistakes 2023-02-08 18:15:04 -05:00
minermaniac447
fbf7977188
Fix TS Build Mistakes 2023-02-08 17:31:07 -05:00
minermaniac447
2b847ddcc9
Fix TS Build Mistakes 2023-02-08 17:18:49 -05:00
minermaniac447
aabd175d5d
Fix TS Build Mistakes 2023-02-08 17:18:06 -05:00
minermaniac447
f43895645f
Update StatsManager Initialization 2023-02-08 16:45:38 -05:00
minermaniac447
5e970cad74
Add getPageCount 2023-02-08 16:44:23 -05:00
minermaniac447
de3172ee95
Add Page Display Options 2023-02-08 16:42:00 -05:00
minermaniac447
759b4d949c
Add Page Calculations 2023-02-08 16:39:28 -05:00
minermaniac447
9885035ac8
Add Pages 2023-02-08 16:12:36 -05:00
minermaniac447
2cc592c13e
Add "Pages" as an Option 2023-02-08 16:11:23 -05:00
minermaniac447
88a3bd1a2a
Add Page Word Count Setting 2023-02-08 16:03:24 -05:00
minermaniac447
547fb32f95
Add Page-Related Settings 2023-02-08 15:59:10 -05:00
bakuzan
9cdab1d1d7 Remove log 2023-01-30 11:14:14 +00:00
bakuzan
44dfcb9fe3 Work around for undefined user event type. Fixes #69. 2023-01-30 11:12:39 +00:00
Luke Leppan
566f8531b5
bump 0.9.4 2023-01-27 10:27:04 +02:00
Luke Leppan
496d708117
Merge pull request #72 from Noxellar/patch-1 2023-01-27 10:24:06 +02:00
Noxellar
3871f71aae
Adding a space to the default suffix for the alt status bar 2023-01-27 19:20:17 +11:00
12 changed files with 365 additions and 23 deletions

View file

@ -1,34 +1,36 @@
# Better Word Count
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lukeleppan/better-word-count/Build%20Release?logo=github&style=for-the-badge) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/lukeleppan/better-word-count?style=for-the-badge) ![Obsidian Downloads](https://img.shields.io/badge/dynamic/json?logo=obsidian&color=%23483699&label=downloads&query=%24%5B%22better-word-count%22%5D.downloads&url=https%3A%2F%2Fraw.githubusercontent.com%2Fobsidianmd%2Fobsidian-releases%2Fmaster%2Fcommunity-plugin-stats.json&style=for-the-badge)
**IMPORTANT NOTICE:** Due to the introduction of the new Live Preview feature, this plugin needed to be almost entirely rewritten. It will be unstable for a while so please report bugs on github.
This plugin is the same as the built-in **Word Count** plugin, except when you select text, it will count the selected word instead of the whole document. I recommend turning off the built-in **Word Count** because this plugin is designed to replace that. This plugin also has the ability to store statistics about your vault.
![GitHub manifest version](https://img.shields.io/github/manifest-json/v/lukeleppan/better-word-count?color=magenta&label=version&style=for-the-badge) ![GitHub Release Date](https://img.shields.io/github/release-date/lukeleppan/better-word-count?style=for-the-badge) ![Lines of code](https://img.shields.io/tokei/lines/github/lukeleppan/better-word-count?style=for-the-badge) ![Obsidian Downloads](https://img.shields.io/badge/dynamic/json?logo=obsidian&color=%23483699&label=downloads&query=%24%5B%22better-word-count%22%5D.downloads&url=https%3A%2F%2Fraw.githubusercontent.com%2Fobsidianmd%2Fobsidian-releases%2Fmaster%2Fcommunity-plugin-stats.json&style=for-the-badge)
![Better Count Word](https://raw.githubusercontent.com/lukeleppan/better-word-count/master/assets/better-word-count.gif)
This plugin is the same as the built-in **Word Count** plugin, except when you select text, it will count the selected word instead of the whole document. I recommend turning off the built-in **Word Count** because this plugin is designed to replace that. This plugin also has the ability to store statistics about your vault.
## Features
- Allows you to store statistics about your vault.
- Works with all languages.
- Can display a variety of different stats. Including:
- Words, Characters and Sentences in current file.
- Total Words, Characters and Sentences in vault.
- Words, Characters and Sentences typed today.
- Total Files in vault.
- Words, Characters, Sentences, Footnotes, and Pandoc Citations in current file.
- Total Words, Characters, Sentences, Footnotes, Pandoc Citations, and Files in vault.
- Words, Characters, Sentences, Footnotes, and Pandoc Citations typed today.
- Highly Customizable status bar that can be adapted to your needs.
## Contributors
- @leoccyao
- Added all word, char, sentence count when not viewing a markdown file.
- @lishid
- Helped solve the performace issue.
- @THeK3nger
- Fixed issue that occured when renaming files.
- @chrisgrieser
- Added Footnotes and Citation Counting.
- @bakuzan
- Added page counts.
- Fixed issue that caused errors at start up.
- @THeK3nger
- Fixed issue that occurred when renaming files.
- @lishid
- Helped solve the performance issue.
- @Noxellar
- Fixed alt bar spacing issue.
### Special Thanks

View file

@ -1,7 +1,7 @@
{
"id": "better-word-count",
"name": "Better Word Count",
"version": "0.9.3",
"version": "0.9.6",
"description": "Counts the words of selected text in the editor.",
"author": "Luke Leppan",
"authorUrl": "https://lukeleppan.com",

View file

@ -1,6 +1,6 @@
{
"name": "better-word-count",
"version": "0.9.3",
"version": "0.9.6",
"description": "Counts the words of selected text in the editor.",
"main": "main.js",
"scripts": {

View file

@ -1,3 +1,4 @@
import { Transaction } from "@codemirror/state";
import {
ViewUpdate,
PluginValue,
@ -22,9 +23,19 @@ class EditorPlugin implements PluginValue {
}
const tr = update.transactions[0];
if (!tr) return;
if (!tr) {
return;
}
// When selecting text with Shift+Home the userEventType is undefined.
// This is probably a bug in codemirror, for the time being doing an explict check
// for the type allows us to update the stats for the selection.
const userEventTypeUndefined =
tr.annotation(Transaction.userEvent) === undefined;
if (
tr.isUserEvent("select") &&
(tr.isUserEvent("select") || userEventTypeUndefined) &&
tr.newSelection.ranges[0].from !== tr.newSelection.ranges[0].to
) {
let text = "";

View file

@ -33,7 +33,7 @@ export default class BetterWordCount extends Plugin {
// Handle Statistics
if (this.settings.collectStats) {
this.statsManager = new StatsManager(this.app.vault, this.app.workspace);
this.statsManager = new StatsManager(this.app.vault, this.app.workspace, this);
}
// Handle Status Bar

View file

@ -2,6 +2,9 @@ export enum MetricCounter {
words,
characters,
sentences,
footnotes,
citations,
pages,
files,
}
@ -38,6 +41,7 @@ export interface BetterWordCountSettings {
altBar: StatusBarItem[];
countComments: boolean;
collectStats: boolean;
pageWords: number;
}
export const DEFAULT_SETTINGS: BetterWordCountSettings = {
@ -62,7 +66,7 @@ export const DEFAULT_SETTINGS: BetterWordCountSettings = {
altBar: [
{
prefix: "",
suffix: "files",
suffix: " files",
metric: {
type: MetricType.total,
counter: MetricCounter.files,
@ -71,4 +75,5 @@ export const DEFAULT_SETTINGS: BetterWordCountSettings = {
],
countComments: false,
collectStats: false,
pageWords: 300,
};

View file

@ -1,4 +1,4 @@
import { App, PluginSettingTab, Setting, ToggleComponent } from "obsidian";
import { App, PluginSettingTab, Setting, ToggleComponent, TextComponent } from "obsidian";
import type BetterWordCount from "src/main";
import { addStatusBarSettings } from "./StatusBarSettings";
@ -37,6 +37,18 @@ export default class BetterWordCountSettingsTab extends PluginSettingTab {
await this.plugin.saveSettings();
});
});
new Setting(containerEl)
.setName("Page Word Count")
.setDesc("Set how many words count as one \"page\"")
.addText((text: TextComponent) => {
text.inputEl.type = "number";
text.setPlaceholder("300");
text.setValue(this.plugin.settings.pageWords.toString());
text.onChange(async (value: string) => {
this.plugin.settings.pageWords = parseInt(value);
await this.plugin.saveSettings();
});
});
// Status Bar Settings
addStatusBarSettings(this.plugin, containerEl);

View file

@ -18,6 +18,12 @@
return "Chars in Note"
case MetricCounter.sentences:
return "Sentences in Note"
case MetricCounter.footnotes:
return "Footnotes in Note"
case MetricCounter.citations:
return "Citations in Note"
case MetricCounter.pages:
return "Pages in Note"
case MetricCounter.files:
return "Total Notes"
}
@ -29,6 +35,12 @@
return "Daily Chars"
case MetricCounter.sentences:
return "Daily Sentences"
case MetricCounter.footnotes:
return "Daily Footnotes"
case MetricCounter.citations:
return "Daily Citations"
case MetricCounter.pages:
return "Daily Pages"
case MetricCounter.files:
return "Total Notes"
}
@ -40,6 +52,12 @@
return "Total Chars"
case MetricCounter.sentences:
return "Total Sentences"
case MetricCounter.footnotes:
return "Total Footnotes"
case MetricCounter.citations:
return "Total Citations"
case MetricCounter.pages:
return "Total Pages"
case MetricCounter.files:
return "Total Notes"
}
@ -181,6 +199,9 @@
<option value={MetricCounter.words}>Words</option>
<option value={MetricCounter.characters}>Characters</option>
<option value={MetricCounter.sentences}>Sentences</option>
<option value={MetricCounter.footnotes}>Footnotes</option>
<option value={MetricCounter.citations}>Citations</option>
<option value={MetricCounter.pages}>Pages</option>
<option value={MetricCounter.files}>Files</option>
</select>
</div>
@ -348,6 +369,9 @@
<option value={MetricCounter.words}>Words</option>
<option value={MetricCounter.characters}>Characters</option>
<option value={MetricCounter.sentences}>Sentences</option>
<option value={MetricCounter.footnotes}>Footnotes</option>
<option value={MetricCounter.citations}>Citations</option>
<option value={MetricCounter.pages}>Pages</option>
<option value={MetricCounter.files}>Files</option>
</select>
</div>

View file

@ -9,18 +9,27 @@ export interface Day {
words: number;
characters: number;
sentences: number;
pages: number;
files: number;
footnotes: number;
citations: number;
totalWords: number;
totalCharacters: number;
totalSentences: number;
totalFootnotes: number;
totalCitations: number;
totalPages: number;
}
export type ModifiedFiles = Record<string, FileStat>;
export interface FileStat {
footnotes: CountDiff;
citations: CountDiff;
words: CountDiff;
characters: CountDiff;
sentences: CountDiff;
pages: CountDiff;
}
export interface CountDiff {

View file

@ -1,23 +1,30 @@
import { debounce, Debouncer, TFile, Vault, Workspace } from "obsidian";
import type BetterWordCount from "../main";
import { STATS_FILE } from "../constants";
import type { Day, VaultStatistics } from "./Stats";
import moment from "moment";
import {
getCharacterCount,
getSentenceCount,
getPageCount,
getWordCount,
getCitationCount,
getFootnoteCount,
cleanComments,
} from "../utils/StatUtils";
export default class StatsManager {
private vault: Vault;
private workspace: Workspace;
private plugin: BetterWordCount;
private vaultStats: VaultStatistics;
private today: string;
public debounceChange;
constructor(vault: Vault, workspace: Workspace) {
constructor(vault: Vault, workspace: Workspace, plugin: BetterWordCount) {
this.vault = vault;
this.workspace = workspace;
this.plugin = plugin;
this.debounceChange = debounce(
(text: string) => this.change(text),
50,
@ -76,15 +83,24 @@ export default class StatsManager {
const totalWords = await this.calcTotalWords();
const totalCharacters = await this.calcTotalCharacters();
const totalSentences = await this.calcTotalSentences();
const totalFootnotes = await this.calcTotalFootnotes();
const totalCitations = await this.calcTotalCitations();
const totalPages = await this.calcTotalPages();
const newDay: Day = {
words: 0,
characters: 0,
sentences: 0,
pages: 0,
files: 0,
footnotes: 0,
citations: 0,
totalWords: totalWords,
totalCharacters: totalCharacters,
totalSentences: totalSentences,
totalFootnotes: totalFootnotes,
totalCitations: totalCitations,
totalPages: totalPages,
};
this.vaultStats.modifiedFiles = {};
@ -93,10 +109,17 @@ export default class StatsManager {
}
public async change(text: string) {
if (this.plugin.settings.countComments) {
text = cleanComments(text);
}
const fileName = this.workspace.getActiveFile().path;
const currentWords = getWordCount(text);
const currentCharacters = getCharacterCount(text);
const currentSentences = getSentenceCount(text);
const currentCitations = getCitationCount(text);
const currentFootnotes = getFootnoteCount(text);
const currentPages = getPageCount(text, this.plugin.settings.pageWords);
if (
this.vaultStats.history.hasOwnProperty(this.today) &&
this.today === moment().format("YYYY-MM-DD")
@ -110,9 +133,19 @@ export default class StatsManager {
currentCharacters - modFiles[fileName].characters.current;
this.vaultStats.history[this.today].totalSentences +=
currentSentences - modFiles[fileName].sentences.current;
this.vaultStats.history[this.today].totalFootnotes +=
currentSentences - modFiles[fileName].footnotes.current;
this.vaultStats.history[this.today].totalCitations +=
currentSentences - modFiles[fileName].citations.current;
this.vaultStats.history[this.today].totalPages +=
currentPages - modFiles[fileName].pages.current;
modFiles[fileName].words.current = currentWords;
modFiles[fileName].characters.current = currentCharacters;
modFiles[fileName].sentences.current = currentSentences;
modFiles[fileName].footnotes.current = currentFootnotes;
modFiles[fileName].citations.current = currentCitations;
modFiles[fileName].pages.current = currentPages;
} else {
modFiles[fileName] = {
words: {
@ -127,6 +160,18 @@ export default class StatsManager {
initial: currentSentences,
current: currentSentences,
},
footnotes: {
initial: currentFootnotes,
current: currentFootnotes,
},
citations: {
initial: currentCitations,
current: currentCitations,
},
pages: {
initial: currentPages,
current: currentPages,
},
};
}
@ -146,9 +191,27 @@ export default class StatsManager {
)
.reduce((a, b) => a + b, 0);
const footnotes = Object.values(modFiles)
.map((counts) =>
Math.max(0, counts.footnotes.current - counts.footnotes.initial)
)
.reduce((a, b) => a + b, 0);
const citations = Object.values(modFiles)
.map((counts) =>
Math.max(0, counts.citations.current - counts.citations.initial)
).reduce((a, b) => a + b, 0);
const pages = Object.values(modFiles)
.map((counts) =>
Math.max(0, counts.pages.current - counts.pages.initial)
)
.reduce((a, b) => a + b, 0);
this.vaultStats.history[this.today].words = words;
this.vaultStats.history[this.today].characters = characters;
this.vaultStats.history[this.today].sentences = sentences;
this.vaultStats.history[this.today].footnotes = footnotes;
this.vaultStats.history[this.today].citations = citations;
this.vaultStats.history[this.today].pages = pages;
this.vaultStats.history[this.today].files = this.getTotalFiles();
await this.update();
@ -167,6 +230,9 @@ export default class StatsManager {
todayHist.totalWords = await this.calcTotalWords();
todayHist.totalCharacters = await this.calcTotalCharacters();
todayHist.totalSentences = await this.calcTotalSentences();
todayHist.totalFootnotes = await this.calcTotalFootnotes();
todayHist.totalCitations = await this.calcTotalCitations();
todayHist.totalPages = await this.calcTotalPages();
this.update();
} else {
this.updateToday();
@ -208,9 +274,46 @@ export default class StatsManager {
sentence += getSentenceCount(await this.vault.cachedRead(file));
}
}
return sentence;
}
private async calcTotalPages(): Promise<number> {
let pages = 0;
const files = this.vault.getFiles();
for (const i in files) {
const file = files[i];
if (file.extension === "md") {
pages += getPageCount(await this.vault.cachedRead(file), this.plugin.settings.pageWords);
}
}
return pages;
}
private async calcTotalFootnotes(): Promise<number> {
let footnotes = 0;
const files = this.vault.getFiles();
for (const i in files) {
const file = files[i];
if (file.extension === "md") {
footnotes += getFootnoteCount(await this.vault.cachedRead(file));
}
}
return footnotes;
}
private async calcTotalCitations(): Promise<number> {
let citations = 0;
const files = this.vault.getFiles();
for (const i in files) {
const file = files[i];
if (file.extension === "md") {
citations += getCitationCount(await this.vault.cachedRead(file));
}
}
return citations;
}
public getDailyWords(): number {
return this.vaultStats.history[this.today].words;
@ -224,6 +327,18 @@ export default class StatsManager {
return this.vaultStats.history[this.today].sentences;
}
public getDailyFootnotes(): number {
return this.vaultStats.history[this.today].footnotes;
}
public getDailyCitations(): number {
return this.vaultStats.history[this.today].citations;
}
public getDailyPages(): number {
return this.vaultStats.history[this.today].pages;
}
public getTotalFiles(): number {
return this.vault.getMarkdownFiles().length;
}
@ -242,4 +357,19 @@ export default class StatsManager {
if (!this.vaultStats) return await this.calcTotalSentences();
return this.vaultStats.history[this.today].totalSentences;
}
public async getTotalFootnotes(): Promise<number> {
if (!this.vaultStats) return await this.calcTotalFootnotes();
return this.vaultStats.history[this.today].totalFootnotes;
}
public async getTotalCitations(): Promise<number> {
if (!this.vaultStats) return await this.calcTotalCitations();
return this.vaultStats.history[this.today].totalCitations;
}
public async getTotalPages(): Promise<number> {
if (!this.vaultStats) return await this.calcTotalPages();
return this.vaultStats.history[this.today].totalPages;
}
}

View file

@ -4,6 +4,10 @@ import {
getWordCount,
getCharacterCount,
getSentenceCount,
getCitationCount,
getFootnoteCount,
getPageCount,
cleanComments,
} from "src/utils/StatUtils";
import { debounce } from "obsidian";
@ -22,7 +26,7 @@ export default class StatusBar {
);
this.statusBarEl.classList.add("mod-clickable");
this.statusBarEl.setAttribute("aria-label", "Coming Soon");
this.statusBarEl.setAttribute("aria-label", "!!!");
this.statusBarEl.setAttribute("aria-label-position", "top");
this.statusBarEl.addEventListener("click", (ev: MouseEvent) =>
this.onClick(ev)
@ -41,6 +45,10 @@ export default class StatusBar {
const sb = this.plugin.settings.statusBar;
let display = "";
if (!this.plugin.settings.countComments) {
text = cleanComments(text);
}
for (let i = 0; i < sb.length; i++) {
const sbItem = sb[i];
@ -107,6 +115,66 @@ export default class StatusBar {
: 0));
break;
}
} else if (metric.counter === MetricCounter.footnotes) {
switch (metric.type) {
case MetricType.file:
display = display + getFootnoteCount(text);
break;
case MetricType.daily:
display =
display +
(this.plugin.settings.collectStats
? this.plugin.statsManager.getDailyFootnotes()
: 0);
break;
case MetricType.total:
display =
display +
(await (this.plugin.settings.collectStats
? this.plugin.statsManager.getTotalFootnotes()
: 0));
break;
}
} else if (metric.counter === MetricCounter.citations) {
switch (metric.type) {
case MetricType.file:
display = display + getCitationCount(text);
break;
case MetricType.daily:
display =
display +
(this.plugin.settings.collectStats
? this.plugin.statsManager.getDailyCitations()
: 0);
break;
case MetricType.total:
display =
display +
(await (this.plugin.settings.collectStats
? this.plugin.statsManager.getTotalCitations()
: 0));
break;
}
} else if (metric.counter === MetricCounter.pages) {
switch (metric.type) {
case MetricType.file:
display = display + getPageCount(text, this.plugin.settings.pageWords);
break;
case MetricType.daily:
display =
display +
(this.plugin.settings.collectStats
? this.plugin.statsManager.getDailyPages()
: 0);
break;
case MetricType.total:
display =
display +
(await (this.plugin.settings.collectStats
? this.plugin.statsManager.getTotalPages()
: 0));
break;
}
} else if (metric.counter === MetricCounter.files) {
switch (metric.type) {
case MetricType.file:
@ -209,6 +277,66 @@ export default class StatusBar {
: 0));
break;
}
} else if (metric.counter === MetricCounter.footnotes) {
switch (metric.type) {
case MetricType.file:
display = display + 0;
break;
case MetricType.daily:
display =
display +
(this.plugin.settings.collectStats
? this.plugin.statsManager.getDailyFootnotes()
: 0);
break;
case MetricType.total:
display =
display +
(await (this.plugin.settings.collectStats
? this.plugin.statsManager.getTotalFootnotes()
: 0));
break;
}
} else if (metric.counter === MetricCounter.citations) {
switch (metric.type) {
case MetricType.file:
display = display + 0;
break;
case MetricType.daily:
display =
display +
(this.plugin.settings.collectStats
? this.plugin.statsManager.getDailyCitations()
: 0);
break;
case MetricType.total:
display =
display +
(await (this.plugin.settings.collectStats
? this.plugin.statsManager.getTotalCitations()
: 0));
break;
}
} else if (metric.counter === MetricCounter.pages) {
switch (metric.type) {
case MetricType.file:
display = display + 0;
break;
case MetricType.daily:
display =
display +
(this.plugin.settings.collectStats
? this.plugin.statsManager.getDailyPages()
: 0);
break;
case MetricType.total:
display =
display +
(await (this.plugin.settings.collectStats
? this.plugin.statsManager.getTotalPages()
: 0));
break;
}
} else if (metric.counter === MetricCounter.files) {
switch (metric.type) {
case MetricType.file:

View file

@ -27,6 +27,23 @@ export function getCharacterCount(text: string): number {
return text.length;
}
export function getFootnoteCount(text: string): number {
const regularFn = text.match(/\[\^\S+](?!:)/g);
const inlineFn = text.match(/\^\[[^^].+?]/g);
let overallFn = 0;
if (regularFn) overallFn += regularFn.length;
if (inlineFn) overallFn += inlineFn.length;
return overallFn;
}
export function getCitationCount(text: string): number {
const pandocCitations = text.match(/@[A-Za-z0-9-]+[,;\]](?!\()/gi);
if (!pandocCitations) return 0;
const uniqueCitations = [...new Set(pandocCitations)].length;
return uniqueCitations;
}
export function getSentenceCount(text: string): number {
const sentences: number = (
(text || "").match(
@ -37,6 +54,10 @@ export function getSentenceCount(text: string): number {
return sentences;
}
export function getPageCount(text: string, pageWords: number): number {
return parseFloat((getWordCount(text) / pageWords).toFixed(1));
}
export function getTotalFileCount(vault: Vault): number {
return vault.getMarkdownFiles().length;
}