summaryrefslogtreecommitdiff
path: root/ext/js/display/display-generator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-05-14 18:12:57 -0400
committerGitHub <noreply@github.com>2022-05-14 18:12:57 -0400
commit5dcc2315d242bcec29cc478618d448c941f73ab1 (patch)
tree9d36e666cc71bb1c1a89c725eaa9fdaa5c938626 /ext/js/display/display-generator.js
parent6a74746113c724e750620d10b58ad6bac94060c9 (diff)
Structured content auto language (#2131)
* Pass JapaneseUtil instance to StructuredContentGenerator * Move body of createStructuredContent to an internal function * Create _createStructuredContentGenericElement * Wrap structured content in a <span> * Change _createStructuredContent to _appendStructuredContent * Add public appendStructuredContent function * Add missing return * Remove unused _createDocumentFragment * Automatically assign lang=ja for content with Japanese characters without an explicit language * Add test
Diffstat (limited to 'ext/js/display/display-generator.js')
-rw-r--r--ext/js/display/display-generator.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index 1f485a4f..3fabdbb0 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -28,7 +28,7 @@ class DisplayGenerator {
this._contentManager = contentManager;
this._hotkeyHelpController = hotkeyHelpController;
this._templates = null;
- this._structuredContentGenerator = new StructuredContentGenerator(this._contentManager, document);
+ this._structuredContentGenerator = new StructuredContentGenerator(this._contentManager, japaneseUtil, document);
this._pronunciationGenerator = new PronunciationGenerator(japaneseUtil);
}
@@ -347,11 +347,8 @@ class DisplayGenerator {
_createTermDefinitionEntryStructuredContent(content, dictionary) {
const node = this._templates.instantiate('gloss-item');
- const child = this._structuredContentGenerator.createStructuredContent(content, dictionary);
- if (child !== null) {
- const contentContainer = node.querySelector('.gloss-content');
- contentContainer.appendChild(child);
- }
+ const contentContainer = node.querySelector('.gloss-content');
+ this._structuredContentGenerator.appendStructuredContent(contentContainer, content, dictionary);
return node;
}