Skip to content

Commit

Permalink
~ only analyse markdown files
Browse files Browse the repository at this point in the history
~ more markdown formatting removed
~ increase logging
  • Loading branch information
joethei committed Feb 1, 2022
1 parent 2f89630 commit 17a89fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "tag-word-cloud",
"name": "Tag & Word Cloud",
"version": "1.1.1",
"version": "1.1.2",
"minAppVersion": "0.12.0",
"description": "Show a cloud of your tags/words in a note",
"author": "Johannes Theiner",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-tag-cloud",
"version": "1.1.1",
"version": "1.1.2",
"description": "Show a cloud of your tags/words in a note",
"main": "main.js",
"scripts": {
Expand Down
20 changes: 17 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export default class TagCloudPlugin extends Plugin {
.replace(/\*|_|\[\[|\]\]|\||==|~~|---|#|> |`/g, "") // Markdown Syntax
.replace(/<!--.*?-->/sg, "") //HTML Comments
.replace(/%%.*?%%/sg, "")//Obsidian Comments
.replace(/^```.*\n([\s\S]*?)```$/gm, ''); //codeblocks
.replace(/^```.*\n([\s\S]*?)```$/gm, '') //codeblocks
.replace(/\[\^[[\s\S]]*\]/g, '') //footnotes
.replace(/\^\[([\s\S]*?)\]/g, '$1'); //inline footnotes
}

parseCodeblockOptions(source: string): CodeblockOptions | undefined {
Expand Down Expand Up @@ -122,19 +124,25 @@ export default class TagCloudPlugin extends Plugin {
if (this.calculatingWordDistribution) return;
this.calculatingWordDistribution = true;
console.log("Calculating word distribution");
const files = this.app.vault.getMarkdownFiles();
console.log("will analyze %i files", files.length);
new Notice("Calculating word distribution");
for (const file of this.app.vault.getFiles()) {

let fileCount = 0;
for (const file of files) {
if (file === undefined) continue;
if (file.extension !== "md") continue;

const fileContent = await this.app.vault.read(file);
const words = this.getWords(fileContent);
this.fileContentsWithStopwords = this.convertToMap(words);

const withoutStopWords = this.removeStopwords(words);
this.fileContentsWithoutStopwords = this.convertToMap(withoutStopWords);

fileCount++;
}
console.log("Finished calculating word distribution");
console.log("analyzed %i files", fileCount);
new Notice("Finished calculating word distribution");
this.calculatingWordDistribution = false;
}
Expand Down Expand Up @@ -178,6 +186,9 @@ export default class TagCloudPlugin extends Plugin {
return;
}

//TODO: remove after debugging issue on user side.
console.log(options);

let content: Map<string, number> = new Map<string, number>();

if (options.source === 'file') {
Expand Down Expand Up @@ -268,6 +279,9 @@ export default class TagCloudPlugin extends Plugin {
return;
}

//TODO: remove after debugging issue on user side.
console.log(options);

const tags: string[] = [];

if (options.source === 'file') {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"1.0.0": "0.12.0",
"1.0.1": "0.12.0",
"1.1.0": "0.12.0",
"1.1.1": "0.12.0"
"1.1.1": "0.12.0",
"1.1.2": "0.12.0"
}

0 comments on commit 17a89fa

Please sign in to comment.