diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bed66b3..1cc39a66 120000 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -docs/changelog.md \ No newline at end of file +docs/changelog.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 651dc17d..9815d5bd 120000 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -docs/en/contributing.md \ No newline at end of file +docs/en/contributing.md diff --git a/docs/changelog.md b/docs/changelog.md index e7869b4c..9b3bc83f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [Unreleased] + +- [BUG] Plugin not picking up certain flashcards https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/915 + #### [1.12.1](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.12.0...1.12.1) - [Overhaul] Implementation of a more consistent & modern UI [`#899`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/899) diff --git a/src/SRFile.ts b/src/SRFile.ts index f180c782..bc18b10a 100644 --- a/src/SRFile.ts +++ b/src/SRFile.ts @@ -1,4 +1,5 @@ import { MetadataCache, TFile, Vault, HeadingCache, TagCache, FrontMatterCache } from "obsidian"; +import { parseObsidianFrontmatterTag } from "./util/utils"; export interface ISRFile { get path(): string; @@ -52,11 +53,11 @@ export class SrTFile implements ISRFile { // in the file) const line: number = 1; - // Frontmatter tags are comma separated and don't include the "#", so we need to add that in - const tagStrList: string[] = frontmatterTags.split(","); + // Parse the frontmatter tag string into a list, each entry including the leading "#" + const tagStrList: string[] = parseObsidianFrontmatterTag(frontmatterTags); for (const str of tagStrList) { const tag: TagCache = { - tag: "#" + str, + tag: str, position: { start: { line: line, col: null, offset: null }, end: { line: line, col: null, offset: null }, diff --git a/src/util/utils.ts b/src/util/utils.ts index 6407fb20..ee7974b3 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -146,3 +146,65 @@ export function findLineIndexOfSearchStringIgnoringWs( } return result; } + +/* +Prompted by flashcards being missed, here are some "experiments" with different frontmatter, +showing the difference in the value of CachedMetadata.frontmatter["tags"] + +----------------- EXPERIMENT 1 + +--- +tags: + - flashcards/philosophy/philosophers + - flashcards/toes +--- + +CachedMetadata.frontmatter["tags"]: flashcards/philosophy/philosophers,flashcards/toes + + +----------------- EXPERIMENT 2 + +--- +tags: + - "#flashcards/philosophy/philosophers" +--- + +CachedMetadata.frontmatter["tags"]: #flashcards/philosophy/philosophers + + +----------------- EXPERIMENT 3 + +--- +tags: + - "#flashcards/philosophy/philosophers" + - "#flashcards/toes" +--- + +CachedMetadata.frontmatter["tags"]: #flashcardsX/philosophy/philosophers,#flashcardsX/toes + + +----------------- EXPERIMENT 4 + +--- +tags: + - #flashcards/philosophy/philosophers +--- + +Obsidian does not recognize that the frontmatter has any tags +(i.e. if the frontmatter includes the "#" it must be enclosed in quotes) + +----------------- CONCLUSION + +CachedMetadata.frontmatter["tags"]: tags are comma separated. They may or may not include the "#". +Any double quotes in the frontmatter are stripped by Obsidian and not present in this variable. + +*/ + +export function parseObsidianFrontmatterTag(tagStr: string): string[] { + const result: string[] = [] as string[]; + const tagStrList: string[] = tagStr.split(","); + for (const tag of tagStrList) { + result.push(tag.startsWith("#") ? tag : "#" + tag); + } + return result; +}