Fix bug with tags with no latin characters #28 #31

This commit is contained in:
Alex Colucci 2021-04-19 12:18:11 +02:00
parent d1302edd87
commit 0114d4881e
3 changed files with 7 additions and 3 deletions

View File

@ -1,7 +1,7 @@
{ {
"id": "flashcards-obsidian", "id": "flashcards-obsidian",
"name": "Flashcards", "name": "Flashcards",
"version": "1.2.0", "version": "1.2.1",
"minAppVersion": "0.9.17", "minAppVersion": "0.9.17",
"description": "Anki integration", "description": "Anki integration",
"author": "Alex Colucci", "author": "Alex Colucci",

View File

@ -7,6 +7,7 @@ export class Regex {
codeBlock: RegExp codeBlock: RegExp
cardsDeckLine: RegExp cardsDeckLine: RegExp
cardsToDelete: RegExp cardsToDelete: RegExp
globalTagsSplitter: RegExp
flashscardsWithTag: RegExp flashscardsWithTag: RegExp
cardsInlineStyle: RegExp cardsInlineStyle: RegExp
cardsSpacedStyle: RegExp cardsSpacedStyle: RegExp
@ -24,9 +25,12 @@ export class Regex {
this.markdownImageLinks = /!\[\]\((.*\.(?:png|jpg|jpeg|gif|bmp|svg|tiff)).*?\)/gim this.markdownImageLinks = /!\[\]\((.*\.(?:png|jpg|jpeg|gif|bmp|svg|tiff)).*?\)/gim
this.codeBlock = /<code\b[^>]*>(.*?)<\/code>/gims this.codeBlock = /<code\b[^>]*>(.*?)<\/code>/gims
this.cardsDeckLine = /cards-deck: [\w\d]+/gi this.cardsDeckLine = /cards-deck: [\p{L}]+/giu
this.cardsToDelete = /^\s*(?:\n)(?:\^(\d{13}))(?:\n\s*?)?/gm this.cardsToDelete = /^\s*(?:\n)(?:\^(\d{13}))(?:\n\s*?)?/gm
// https://regex101.com/r/IS2gjL/1
this.globalTagsSplitter = /\[\[(.*?)\]\]|#([\p{L}:\/-]+)|([\p{L}:]+)/gmiu
// Cards // Cards
// https://regex101.com/r/p3yQwY/2 // https://regex101.com/r/p3yQwY/2
let str = "( {0,3}[#]*)((?:[^\\n]\\n?)+?)(#" + settings.flashcardsTag + "(?:-reverse)?)((?: *#[\\w-]+)*) *?\\n+((?:[^\\n]\\n?)*?(?=\\^\\d{13}|$))(?:\\^(\\d{13}))?" let str = "( {0,3}[#]*)((?:[^\\n]\\n?)+?)(#" + settings.flashcardsTag + "(?:-reverse)?)((?: *#[\\w-]+)*) *?\\n+((?:[^\\n]\\n?)*?(?=\\^\\d{13}|$))(?:\\^(\\d{13}))?"

View File

@ -318,7 +318,7 @@ export class CardsService {
let globalTags: string[] = [] let globalTags: string[] = []
let tags = file.match(/(?:cards-)?tags: ?(.*)/im) let tags = file.match(/(?:cards-)?tags: ?(.*)/im)
globalTags = tags ? tags[1].match(/\[\[(.*?)\]\]|#([\w:\/-]+)|([\w:]+)/gmi) : [] globalTags = tags ? tags[1].match(this.regex.globalTagsSplitter) : []
if (globalTags) { if (globalTags) {
for (let i = 0; i < globalTags.length; i++) { for (let i = 0; i < globalTags.length; i++) {