diff --git a/ext/css/visibility-modifiers.css b/ext/css/visibility-modifiers.css
index f461b9c11..f469bd052 100644
--- a/ext/css/visibility-modifiers.css
+++ b/ext/css/visibility-modifiers.css
@@ -10,6 +10,9 @@
:root:not([data-language=ja]):not([data-language=zh]):not([data-language=yue]) .jpzhyue-only {
display: none;
}
+:root:not([data-language=ja]):not([data-language=zh]):not([data-language=yue]):not([data-language=ko]) .jpzhyueko-only {
+ display: none;
+}
:root:is([data-language=ja], [data-language=zh], [data-language=yue], [data-language=ko]) .not-jpzhyueko {
display: none;
}
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index a85ccc4a9..9a5751f91 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -20,7 +20,7 @@ import {EventDispatcher} from '../core/event-dispatcher.js';
import {log} from '../core/log.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
import {convertHiraganaToKatakana, convertKatakanaToHiragana, isStringEntirelyKana} from '../language/ja/japanese.js';
-import {TextScanner} from '../language/text-scanner.js';
+import {NO_SPACES_LANGUAGES, TextScanner} from '../language/text-scanner.js';
/**
* @augments EventDispatcher
@@ -43,6 +43,8 @@ export class QueryParser extends EventDispatcher {
this._setTextToken = null;
/** @type {?string} */
this._selectedParser = null;
+ /** @type {boolean} */
+ this._shouldInsertSpacesBetweenTerms = false;
/** @type {import('settings').ParsingReadingMode} */
this._readingMode = 'none';
/** @type {number} */
@@ -100,6 +102,9 @@ export class QueryParser extends EventDispatcher {
}
if (typeof termSpacing === 'boolean') {
this._queryParser.dataset.termSpacing = `${termSpacing}`;
+ if (!NO_SPACES_LANGUAGES.has(language)) {
+ this._shouldInsertSpacesBetweenTerms = true;
+ }
}
if (typeof readingMode === 'string') {
this._setReadingMode(readingMode);
@@ -305,6 +310,7 @@ export class QueryParser extends EventDispatcher {
termNode.dataset.offset = `${offset}`;
for (const {text, reading} of term) {
const trimmedText = text.trim();
+ if (trimmedText.length === 0) { continue; }
if (reading.length === 0) {
termNode.appendChild(document.createTextNode(trimmedText));
} else {
@@ -312,8 +318,14 @@ export class QueryParser extends EventDispatcher {
termNode.appendChild(this._createSegment(trimmedText, reading2, offset));
}
offset += trimmedText.length;
+ if (this._shouldInsertSpacesBetweenTerms) {
+ termNode.appendChild(document.createTextNode(' '));
+ offset += 1;
+ }
+ }
+ if (termNode.childNodes.length > 0) {
+ fragment.appendChild(termNode);
}
- fragment.appendChild(termNode);
}
return fragment;
}
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js
index c1bccad13..62f9f697b 100644
--- a/ext/js/language/text-scanner.js
+++ b/ext/js/language/text-scanner.js
@@ -24,7 +24,7 @@ import {clone} from '../core/utilities.js';
import {anyNodeMatchesSelector, everyNodeMatchesSelector, getActiveModifiers, getActiveModifiersAndButtons, isPointInSelection} from '../dom/document-util.js';
import {TextSourceElement} from '../dom/text-source-element.js';
-const SCAN_RESOLUTION_EXCLUDED_LANGUAGES = new Set(['ja', 'zh', 'yue', 'ko']);
+export const NO_SPACES_LANGUAGES = new Set(['ja', 'zh', 'yue', 'ko']);
/**
* @augments EventDispatcher
@@ -478,7 +478,7 @@ export class TextScanner extends EventDispatcher {
);
if (this._scanResolution === 'word' && !disallowExpandStartOffset &&
- (this._language === null || !SCAN_RESOLUTION_EXCLUDED_LANGUAGES.has(this._language))) {
+ (this._language === null || !NO_SPACES_LANGUAGES.has(this._language))) {
// Move the start offset to the beginning of the word
textSource.setStartOffset(this._scanLength, this._layoutAwareScan, true);
}
diff --git a/ext/settings.html b/ext/settings.html
index 27fefef7f..03bf23220 100644
--- a/ext/settings.html
+++ b/ext/settings.html
@@ -1555,7 +1555,7 @@ Yomitan Settings
-
+
Show space between parsed words