Add support for inline reverse style

This commit is contained in:
Alex Colucci 2021-04-19 11:18:30 +02:00
parent aabed8d48e
commit 4d19a7f279
4 changed files with 9 additions and 9 deletions

View File

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

View File

@ -3,8 +3,8 @@ import { Card } from "src/entities/card";
export class Inlinecard extends Card {
constructor(id: number = -1, deckName: string, initialContent: string, fields: Record<string, string>, reversed: boolean, endOffset: number, tags: string[] = [], inserted: boolean = false, mediaNames: string[], containsCode: boolean) {
super(id, deckName, initialContent, fields, reversed, endOffset, tags, inserted, mediaNames, containsCode)
this.modelName = `Obsidian-basic`
super(id, deckName, initialContent, fields, reversed, endOffset, tags, inserted, mediaNames, [], containsCode) // ! CHANGE []
this.modelName = this.reversed ? `Obsidian-basic-reversed` : `Obsidian-basic`
if (fields["Source"]) {
this.modelName += sourceDeckExtension
}

View File

@ -33,7 +33,7 @@ export class Regex {
this.flashscardsWithTag = new RegExp(str, "gim")
// https://regex101.com/r/DEVfyh/2
str = "( {0,3}[#]{0,6})?(?:(?:[\\t ]*)(?:\\d.|[-+*]|#{1,6}))?(.+) ?:{2} ?(.+?)((?: *#[\\w-]+)+|$)(?:\\n\\^(\\d{13}))?"
str = "( {0,3}[#]{0,6})?(?:(?:[\\t ]*)(?:\\d.|[-+*]|#{1,6}))?(.+?) ?(:{2,3}) ?(.+?)((?: *#[\\w-]+)+|$)(?:\\n\\^(\\d{13}))?"
this.cardsInlineStyle = new RegExp(str, "gim")
// https://regex101.com/r/HOXF5E/1

View File

@ -133,7 +133,7 @@ export class Parser {
continue
}
let reversed: boolean = false
let reversed: boolean = match[3].trim().toLowerCase() === ':::'
let headingLevel = -1
if (match[1]) {
headingLevel = match[1].trim().length !== 0 ? match[1].trim().length : -1
@ -143,16 +143,16 @@ export class Parser {
let originalQuestion = match[2].trim()
let question = contextAware ? [...context, match[2].trim()].join(`${this.settings.contextSeparator}`) : match[2].trim()
let answer = match[3].trim()
let answer = match[4].trim()
let imagesMedia: string[] = this.getImageLinks(question)
imagesMedia = imagesMedia.concat(this.getImageLinks(answer))
question = this.parseLine(question, vault)
answer = this.parseLine(answer, vault)
let endingLine = match.index + match[0].length
let tags: string[] = this.parseTags(match[4], globalTags)
let id: number = match[5] ? Number(match[5]) : -1
let inserted: boolean = match[5] ? true : false
let tags: string[] = this.parseTags(match[5], globalTags)
let id: number = match[6] ? Number(match[6]) : -1
let inserted: boolean = match[6] ? true : false
let fields: any = { "Front": question, "Back": answer }
if (this.settings.sourceSupport) {
fields["Source"] = note