Omit the sound tag if it's empty (#525)

This commit is contained in:
toasted-nutbread 2020-05-09 12:29:41 -04:00 committed by GitHub
parent 9900291b07
commit bdbe680f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -14,9 +14,11 @@
{{~/if~}}
{{/inline}}
{{#*inline "audio"~}}
[sound:{{definition.audioFileName}}]
{{~/inline}}
{{#*inline "audio"}}
{{~#if definition.audioFileName~}}
[sound:{{definition.audioFileName}}]
{{~/if~}}
{{/inline}}
{{#*inline "character"}}
{{~definition.character~}}

View File

@ -115,7 +115,7 @@ const profileOptionsVersionUpdates = [
let fieldTemplates = options.anki.fieldTemplates;
if (typeof fieldTemplates !== 'string') { return; }
const replacement = '{{#*inline "audio"~}}\n [sound:{{definition.audioFileName}}]\n{{~/inline}}';
const replacement = '{{#*inline "audio"}}\n {{~#if definition.audioFileName~}}\n [sound:{{definition.audioFileName}}]\n {{~/if~}}\n{{/inline}}';
let replaced = false;
fieldTemplates = fieldTemplates.replace(/\{\{#\*inline "audio"\}\}\{\{\/inline\}\}/g, () => {
replaced = true;