Fix template updates for multiple declarations (#918)

* Update pattern to be multi-match

* Remove unnecessary async
This commit is contained in:
toasted-nutbread 2020-10-14 19:35:13 -04:00 committed by GitHub
parent 4ca6101273
commit a72c3d7719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -380,13 +380,13 @@ class OptionsUtil {
if (addition === null) { if (addition === null) {
addition = await this._fetchAsset(additionSourceUrl); addition = await this._fetchAsset(additionSourceUrl);
} }
profileOptions.anki.fieldTemplates = await this._addFieldTemplatesBeforeEnd(fieldTemplates, addition); profileOptions.anki.fieldTemplates = this._addFieldTemplatesBeforeEnd(fieldTemplates, addition);
} }
} }
} }
async _addFieldTemplatesBeforeEnd(fieldTemplates, addition) { _addFieldTemplatesBeforeEnd(fieldTemplates, addition) {
const pattern = /[ \t]*\{\{~?>\s*\(\s*lookup\s*\.\s*"marker"\s*\)\s*~?\}\}/; const pattern = /[ \t]*\{\{~?>\s*\(\s*lookup\s*\.\s*"marker"\s*\)\s*~?\}\}/g;
const newline = '\n'; const newline = '\n';
let replaced = false; let replaced = false;
fieldTemplates = fieldTemplates.replace(pattern, (g0) => { fieldTemplates = fieldTemplates.replace(pattern, (g0) => {