From 5ec2344df95da39cda4ad07cfe5181b05fa24830 Mon Sep 17 00:00:00 2001 From: StefanVukovic99 Date: Sun, 3 Mar 2024 05:48:57 +0100 Subject: fix whitespace (#755) --- ext/data/templates/anki-field-templates-upgrade-v27.handlebars | 2 +- ext/data/templates/anki-field-templates-upgrade-v28.handlebars | 9 +++++++++ ext/data/templates/default-anki-field-templates.handlebars | 4 ++-- ext/js/data/options-util.js | 10 +++++++++- ext/js/templates/sandbox/template-renderer.js | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 ext/data/templates/anki-field-templates-upgrade-v28.handlebars (limited to 'ext') diff --git a/ext/data/templates/anki-field-templates-upgrade-v27.handlebars b/ext/data/templates/anki-field-templates-upgrade-v27.handlebars index 67dca143..48060415 100644 --- a/ext/data/templates/anki-field-templates-upgrade-v27.handlebars +++ b/ext/data/templates/anki-field-templates-upgrade-v27.handlebars @@ -18,4 +18,4 @@ {{~/if~}} {{~/if~}} {{/inline}} -{{>>>>>>>}} +{{>>>>>>>}} \ No newline at end of file diff --git a/ext/data/templates/anki-field-templates-upgrade-v28.handlebars b/ext/data/templates/anki-field-templates-upgrade-v28.handlebars new file mode 100644 index 00000000..8279e5e9 --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v28.handlebars @@ -0,0 +1,9 @@ +{{<<<<<<<}} +{{#*inline "url"}} + {{definition.url}} +{{/inline}} +{{=======}} +{{~#*inline "url"~}} + {{definition.url}} +{{~/inline~}} +{{>>>>>>>}} \ No newline at end of file diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 049cd56d..0495af34 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -172,9 +172,9 @@ {{~#mergeTags definition group merge}}{{this}}{{/mergeTags~}} {{/inline}} -{{#*inline "url"}} +{{~#*inline "url"~}} {{definition.url}} -{{/inline}} +{{~/inline~}} {{#*inline "screenshot"}} {{~#if (hasMedia "screenshot")~}} diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index cac2f82d..d89b3370 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -533,7 +533,8 @@ export class OptionsUtil { this._updateVersion24, this._updateVersion25, this._updateVersion26, - this._updateVersion27 + this._updateVersion27, + this._updateVersion28 ]; /* eslint-enable @typescript-eslint/unbound-method */ if (typeof targetVersion === 'number' && targetVersion < result.length) { @@ -1199,6 +1200,13 @@ export class OptionsUtil { await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v27.handlebars'); } + /** + * - Removed whitespace in URL handlebars template. + * @type {import('options-util').UpdateFunction} + */ + async _updateVersion28(options) { + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v28.handlebars'); + } /** * @param {string} url diff --git a/ext/js/templates/sandbox/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js index 90fb63f3..84eb6a19 100644 --- a/ext/js/templates/sandbox/template-renderer.js +++ b/ext/js/templates/sandbox/template-renderer.js @@ -140,7 +140,7 @@ export class TemplateRenderer { let additions2; try { additions1 = (typeof renderSetup === 'function' ? renderSetup(data) : null); - result = instance(data).trim(); + result = instance(data).replace(/^\n+|\n+$/g, ''); } finally { additions2 = (typeof renderCleanup === 'function' ? renderCleanup(data) : null); } -- cgit v1.2.3