Skip to content

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
macrojd committed Jun 11, 2022
1 parent 2b67c6f commit efbddcb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export default class SummaryPlugin extends Plugin {
}
});
}

// Show empty summary when the tags are not found
createEmptySummary(element: HTMLElement) {
const container = createEl("div");
Expand All @@ -117,6 +118,7 @@ export default class SummaryPlugin extends Plugin {
});
element.replaceWith(container);
}

// Load the blocks and create the summary
async createSummary(element: HTMLElement, tags: string[], include: string[], exclude: string[], filePath: string) {
const validTags = tags.concat(include); // All the tags selected by the user
Expand Down Expand Up @@ -163,9 +165,14 @@ export default class SummaryPlugin extends Plugin {
// Get process each block of text
const block = item[1].split(/\n\s*\n/).filter((row) => row.trim().length > 0);
block.forEach((paragraph) => {
// Check if the paragraph is valid
let valid = false;
const listTags = paragraph.match(/#[a-zA-Z0-9_\-/#]+/g);
const valid = this.isValid(listTags, tags, include, exclude);
if (listTags != null && listTags.length > 0) {
valid = this.isValidText(listTags, tags, include, exclude);
}

// If valid, include the paragraph in the summary
if (valid) {
// Restore newline at the end
paragraph += "\n";
Expand Down Expand Up @@ -222,7 +229,7 @@ export default class SummaryPlugin extends Plugin {
}

// Check if tags are valid
isValid(listTags: string[], tags: string[], include: string[], exclude: string[]): boolean {
isValidText(listTags: string[], tags: string[], include: string[], exclude: string[]): boolean {
let valid = true;

// Check OR (tags)
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "tag-summary-plugin",
"name": "Tag Summary",
"version": "1.0.2",
"version": "1.1.0",
"minAppVersion": "0.12.0",
"description": "This plugin creates summaries with paragraphs or blocks of text that share the same tag(s).",
"author": "J.D Gauchat",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tag-summary-plugin",
"version": "1.0.2",
"version": "1.1.0",
"description": "This plugin creates summaries with paragraphs or blocks of text that share the same tag(s).",
"main": "main.js",
"scripts": {
Expand All @@ -22,3 +22,4 @@
"typescript": "4.4.4"
}
}

0 comments on commit efbddcb

Please sign in to comment.