aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/data/templates/anki-field-templates-upgrade-v27.handlebars2
-rw-r--r--ext/data/templates/anki-field-templates-upgrade-v28.handlebars9
-rw-r--r--ext/data/templates/default-anki-field-templates.handlebars4
-rw-r--r--ext/js/data/options-util.js10
-rw-r--r--ext/js/templates/sandbox/template-renderer.js2
-rw-r--r--test/options-util.test.js2
6 files changed, 23 insertions, 6 deletions
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"}}
+ <a href="{{definition.url}}">{{definition.url}}</a>
+{{/inline}}
+{{=======}}
+{{~#*inline "url"~}}
+ <a href="{{definition.url}}">{{definition.url}}</a>
+{{~/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"~}}
<a href="{{definition.url}}">{{definition.url}}</a>
-{{/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);
}
diff --git a/test/options-util.test.js b/test/options-util.test.js
index 9ccbd8ad..be881d15 100644
--- a/test/options-util.test.js
+++ b/test/options-util.test.js
@@ -599,7 +599,7 @@ function createOptionsUpdatedTestData1() {
}
],
profileCurrent: 0,
- version: 27,
+ version: 28,
global: {
database: {
prefixWildcardsSupported: false