diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-31 20:07:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 20:07:11 -0400 |
commit | 5d7309ed5474a9fb67b9cae1b1176bc10bde6115 (patch) | |
tree | 3dd2f58e8b365298d5a75a3a360899803b67e0b8 /ext/js/data | |
parent | da612bbdd7c5ac15ed64497666f6415c525c823f (diff) |
Log Anki data (#1579)
* Remove unused modifierPost
* Add _getModifier
* Add _getModifiedData
* Add getModifiedData
* Add getRenderingData
* Update logging to also log anki note data
* Fix dangling comma
Diffstat (limited to 'ext/js/data')
-rw-r--r-- | ext/js/data/anki-note-builder.js | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index f12846b1..dfd92493 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -51,15 +51,7 @@ class AnkiNoteBuilder { duplicateScopeCheckChildren = true; } - const data = { - definition, - mode, - context, - resultOutputMode, - glossaryLayoutMode, - compactTags, - injectedMedia - }; + const data = this._createData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia); const formattedFieldValuePromises = []; for (const [, fieldValue] of fields) { const formattedFieldValuePromise = this._formatField(fieldValue, data, templates, errors); @@ -90,8 +82,34 @@ class AnkiNoteBuilder { }; } + async getRenderingData({ + definition, + mode, + context, + resultOutputMode='split', + glossaryLayoutMode='default', + compactTags=false, + injectedMedia=null, + marker=null + }) { + const data = this._createData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia); + return await this._templateRenderer.getModifiedData({data, marker}, 'ankiNote'); + } + // Private + _createData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, injectedMedia) { + return { + definition, + mode, + context, + resultOutputMode, + glossaryLayoutMode, + compactTags, + injectedMedia + }; + } + async _formatField(field, data, templates, errors=null) { return await this._stringReplaceAsync(field, this._markerPattern, async (g0, marker) => { try { |