2020-09-20 15:33:12 +00:00
|
|
|
|
/*
|
2021-01-01 19:50:41 +00:00
|
|
|
|
* Copyright (C) 2020-2021 Yomichan Authors
|
2020-09-20 15:33:12 +00:00
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
const url = require('url');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const assert = require('assert');
|
2020-11-07 16:34:14 +00:00
|
|
|
|
const {testMain} = require('../dev/util');
|
2020-09-20 15:33:12 +00:00
|
|
|
|
const {VM} = require('../dev/vm');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createVM(extDir) {
|
|
|
|
|
const chrome = {
|
|
|
|
|
runtime: {
|
|
|
|
|
getURL(path2) {
|
|
|
|
|
return url.pathToFileURL(path.join(extDir, path2.replace(/^\//, ''))).href;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function fetch(url2) {
|
|
|
|
|
const filePath = url.fileURLToPath(url2);
|
|
|
|
|
await Promise.resolve();
|
|
|
|
|
const content = fs.readFileSync(filePath, {encoding: null});
|
|
|
|
|
return {
|
|
|
|
|
ok: true,
|
|
|
|
|
status: 200,
|
|
|
|
|
statusText: 'OK',
|
|
|
|
|
text: async () => Promise.resolve(content.toString('utf8')),
|
|
|
|
|
json: async () => Promise.resolve(JSON.parse(content.toString('utf8')))
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const vm = new VM({chrome, fetch});
|
|
|
|
|
vm.execute([
|
2021-02-14 03:52:28 +00:00
|
|
|
|
'js/core.js',
|
|
|
|
|
'js/general/cache-map.js',
|
2021-02-14 16:19:54 +00:00
|
|
|
|
'js/data/json-schema.js',
|
|
|
|
|
'js/templates/template-patcher.js',
|
|
|
|
|
'js/data/options-util.js'
|
2020-09-20 15:33:12 +00:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return vm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function clone(value) {
|
|
|
|
|
return JSON.parse(JSON.stringify(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createProfileOptionsTestData1() {
|
|
|
|
|
return {
|
2020-10-27 23:26:30 +00:00
|
|
|
|
version: 14,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
general: {
|
|
|
|
|
enable: true,
|
|
|
|
|
enableClipboardPopups: false,
|
|
|
|
|
resultOutputMode: 'group',
|
|
|
|
|
debugInfo: false,
|
|
|
|
|
maxResults: 32,
|
|
|
|
|
showAdvanced: false,
|
|
|
|
|
popupDisplayMode: 'default',
|
|
|
|
|
popupWidth: 400,
|
|
|
|
|
popupHeight: 250,
|
|
|
|
|
popupHorizontalOffset: 0,
|
|
|
|
|
popupVerticalOffset: 10,
|
|
|
|
|
popupHorizontalOffset2: 10,
|
|
|
|
|
popupVerticalOffset2: 0,
|
|
|
|
|
popupHorizontalTextPosition: 'below',
|
|
|
|
|
popupVerticalTextPosition: 'before',
|
|
|
|
|
popupScalingFactor: 1,
|
|
|
|
|
popupScaleRelativeToPageZoom: false,
|
|
|
|
|
popupScaleRelativeToVisualViewport: true,
|
|
|
|
|
showGuide: true,
|
|
|
|
|
compactTags: false,
|
|
|
|
|
compactGlossaries: false,
|
|
|
|
|
mainDictionary: '',
|
|
|
|
|
popupTheme: 'default',
|
|
|
|
|
popupOuterTheme: 'default',
|
|
|
|
|
customPopupCss: '',
|
|
|
|
|
customPopupOuterCss: '',
|
|
|
|
|
enableWanakana: true,
|
|
|
|
|
enableClipboardMonitor: false,
|
|
|
|
|
showPitchAccentDownstepNotation: true,
|
|
|
|
|
showPitchAccentPositionNotation: true,
|
|
|
|
|
showPitchAccentGraph: false,
|
|
|
|
|
showIframePopupsInRootFrame: false,
|
|
|
|
|
useSecurePopupFrameUrl: true,
|
|
|
|
|
usePopupShadowDom: true
|
|
|
|
|
},
|
|
|
|
|
audio: {
|
|
|
|
|
enabled: true,
|
2021-05-30 16:41:19 +00:00
|
|
|
|
sources: ['jpod101', 'text-to-speech', 'custom'],
|
2020-09-20 15:33:12 +00:00
|
|
|
|
volume: 100,
|
|
|
|
|
autoPlay: false,
|
2021-04-04 20:22:35 +00:00
|
|
|
|
customSourceUrl: 'http://localhost/audio.mp3?term={expression}&reading={reading}',
|
2021-05-30 16:41:19 +00:00
|
|
|
|
textToSpeechVoice: 'example-voice'
|
2020-09-20 15:33:12 +00:00
|
|
|
|
},
|
|
|
|
|
scanning: {
|
|
|
|
|
middleMouse: true,
|
|
|
|
|
touchInputEnabled: true,
|
|
|
|
|
selectText: true,
|
|
|
|
|
alphanumeric: true,
|
|
|
|
|
autoHideResults: false,
|
|
|
|
|
delay: 20,
|
|
|
|
|
length: 10,
|
|
|
|
|
modifier: 'shift',
|
|
|
|
|
deepDomScan: false,
|
|
|
|
|
popupNestingMaxDepth: 0,
|
|
|
|
|
enablePopupSearch: false,
|
|
|
|
|
enableOnPopupExpressions: false,
|
|
|
|
|
enableOnSearchPage: true,
|
|
|
|
|
enableSearchTags: false,
|
|
|
|
|
layoutAwareScan: false
|
|
|
|
|
},
|
|
|
|
|
translation: {
|
|
|
|
|
convertHalfWidthCharacters: 'false',
|
|
|
|
|
convertNumericCharacters: 'false',
|
|
|
|
|
convertAlphabeticCharacters: 'false',
|
|
|
|
|
convertHiraganaToKatakana: 'false',
|
|
|
|
|
convertKatakanaToHiragana: 'variant',
|
|
|
|
|
collapseEmphaticSequences: 'false'
|
|
|
|
|
},
|
2021-03-31 22:17:28 +00:00
|
|
|
|
dictionaries: {
|
|
|
|
|
'Test Dictionary': {
|
|
|
|
|
priority: 0,
|
|
|
|
|
enabled: true,
|
|
|
|
|
allowSecondarySearches: false
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-09-20 15:33:12 +00:00
|
|
|
|
parsing: {
|
|
|
|
|
enableScanningParser: true,
|
|
|
|
|
enableMecabParser: false,
|
|
|
|
|
selectedParser: null,
|
|
|
|
|
termSpacing: true,
|
|
|
|
|
readingMode: 'hiragana'
|
|
|
|
|
},
|
|
|
|
|
anki: {
|
|
|
|
|
enable: false,
|
|
|
|
|
server: 'http://127.0.0.1:8765',
|
|
|
|
|
tags: ['yomichan'],
|
|
|
|
|
sentenceExt: 200,
|
|
|
|
|
screenshot: {format: 'png', quality: 92},
|
|
|
|
|
terms: {deck: '', model: '', fields: {}},
|
|
|
|
|
kanji: {deck: '', model: '', fields: {}},
|
|
|
|
|
duplicateScope: 'collection',
|
|
|
|
|
fieldTemplates: null
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createOptionsTestData1() {
|
|
|
|
|
return {
|
|
|
|
|
profiles: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Default',
|
|
|
|
|
options: createProfileOptionsTestData1(),
|
|
|
|
|
conditionGroups: [
|
|
|
|
|
{
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'equal',
|
|
|
|
|
value: 1
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'notEqual',
|
|
|
|
|
value: 0
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'lessThan',
|
|
|
|
|
value: 3
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'greaterThan',
|
|
|
|
|
value: 0
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'lessThanOrEqual',
|
|
|
|
|
value: 2
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'greaterThanOrEqual',
|
|
|
|
|
value: 1
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
type: 'url',
|
|
|
|
|
operator: 'matchDomain',
|
|
|
|
|
value: 'example.com'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'url',
|
|
|
|
|
operator: 'matchRegExp',
|
|
|
|
|
value: 'example\\.com'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'are',
|
|
|
|
|
value: [
|
|
|
|
|
'ctrl',
|
|
|
|
|
'shift'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'areNot',
|
|
|
|
|
value: [
|
|
|
|
|
'alt',
|
|
|
|
|
'shift'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'include',
|
|
|
|
|
value: 'alt'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'notInclude',
|
|
|
|
|
value: 'ctrl'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
profileCurrent: 0,
|
|
|
|
|
version: 2,
|
|
|
|
|
global: {
|
|
|
|
|
database: {
|
|
|
|
|
prefixWildcardsSupported: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createProfileOptionsUpdatedTestData1() {
|
|
|
|
|
return {
|
|
|
|
|
general: {
|
|
|
|
|
enable: true,
|
|
|
|
|
resultOutputMode: 'group',
|
|
|
|
|
debugInfo: false,
|
|
|
|
|
maxResults: 32,
|
|
|
|
|
showAdvanced: false,
|
|
|
|
|
popupDisplayMode: 'default',
|
|
|
|
|
popupWidth: 400,
|
|
|
|
|
popupHeight: 250,
|
|
|
|
|
popupHorizontalOffset: 0,
|
|
|
|
|
popupVerticalOffset: 10,
|
|
|
|
|
popupHorizontalOffset2: 10,
|
|
|
|
|
popupVerticalOffset2: 0,
|
|
|
|
|
popupHorizontalTextPosition: 'below',
|
|
|
|
|
popupVerticalTextPosition: 'before',
|
|
|
|
|
popupScalingFactor: 1,
|
|
|
|
|
popupScaleRelativeToPageZoom: false,
|
|
|
|
|
popupScaleRelativeToVisualViewport: true,
|
|
|
|
|
showGuide: true,
|
|
|
|
|
compactTags: false,
|
2020-11-26 04:22:05 +00:00
|
|
|
|
glossaryLayoutMode: 'default',
|
2020-09-20 15:33:12 +00:00
|
|
|
|
mainDictionary: '',
|
|
|
|
|
popupTheme: 'default',
|
|
|
|
|
popupOuterTheme: 'default',
|
|
|
|
|
customPopupCss: '',
|
|
|
|
|
customPopupOuterCss: '',
|
|
|
|
|
enableWanakana: true,
|
|
|
|
|
showPitchAccentDownstepNotation: true,
|
|
|
|
|
showPitchAccentPositionNotation: true,
|
|
|
|
|
showPitchAccentGraph: false,
|
|
|
|
|
showIframePopupsInRootFrame: false,
|
|
|
|
|
useSecurePopupFrameUrl: true,
|
|
|
|
|
usePopupShadowDom: true,
|
2020-12-18 16:24:43 +00:00
|
|
|
|
usePopupWindow: false,
|
2020-12-22 23:22:14 +00:00
|
|
|
|
popupCurrentIndicatorMode: 'triangle',
|
2020-12-20 01:07:55 +00:00
|
|
|
|
popupActionBarVisibility: 'auto',
|
2021-02-25 22:48:39 +00:00
|
|
|
|
popupActionBarLocation: 'top',
|
2021-02-27 19:04:52 +00:00
|
|
|
|
frequencyDisplayMode: 'split-tags-grouped',
|
2021-09-26 15:08:16 +00:00
|
|
|
|
termDisplayMode: 'ruby',
|
|
|
|
|
sortFrequencyDictionary: null,
|
|
|
|
|
sortFrequencyDictionaryOrder: 'descending'
|
2020-09-20 15:33:12 +00:00
|
|
|
|
},
|
|
|
|
|
audio: {
|
|
|
|
|
enabled: true,
|
2021-05-30 16:41:19 +00:00
|
|
|
|
sources: [
|
|
|
|
|
{
|
|
|
|
|
type: 'jpod101',
|
|
|
|
|
url: '',
|
|
|
|
|
voice: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'text-to-speech',
|
|
|
|
|
url: '',
|
|
|
|
|
voice: 'example-voice'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'custom',
|
|
|
|
|
url: 'http://localhost/audio.mp3?term={term}&reading={reading}',
|
|
|
|
|
voice: ''
|
|
|
|
|
}
|
|
|
|
|
],
|
2020-09-20 15:33:12 +00:00
|
|
|
|
volume: 100,
|
2021-05-30 16:41:19 +00:00
|
|
|
|
autoPlay: false
|
2020-09-20 15:33:12 +00:00
|
|
|
|
},
|
|
|
|
|
scanning: {
|
|
|
|
|
touchInputEnabled: true,
|
|
|
|
|
selectText: true,
|
|
|
|
|
alphanumeric: true,
|
|
|
|
|
autoHideResults: false,
|
|
|
|
|
delay: 20,
|
|
|
|
|
length: 10,
|
|
|
|
|
deepDomScan: false,
|
|
|
|
|
popupNestingMaxDepth: 0,
|
|
|
|
|
enablePopupSearch: false,
|
|
|
|
|
enableOnPopupExpressions: false,
|
|
|
|
|
enableOnSearchPage: true,
|
|
|
|
|
enableSearchTags: false,
|
|
|
|
|
layoutAwareScan: false,
|
|
|
|
|
hideDelay: 0,
|
|
|
|
|
pointerEventsEnabled: false,
|
2020-09-26 23:24:21 +00:00
|
|
|
|
preventMiddleMouse: {
|
|
|
|
|
onWebPages: false,
|
|
|
|
|
onPopupPages: false,
|
|
|
|
|
onSearchPages: false,
|
|
|
|
|
onSearchQuery: false
|
|
|
|
|
},
|
2020-09-20 15:33:12 +00:00
|
|
|
|
inputs: [
|
|
|
|
|
{
|
|
|
|
|
include: 'shift',
|
2020-09-26 21:51:52 +00:00
|
|
|
|
exclude: 'mouse0',
|
2020-09-20 15:33:12 +00:00
|
|
|
|
types: {
|
|
|
|
|
mouse: true,
|
|
|
|
|
touch: false,
|
|
|
|
|
pen: false
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
showAdvanced: false,
|
2020-09-27 15:53:07 +00:00
|
|
|
|
searchTerms: true,
|
|
|
|
|
searchKanji: true,
|
2020-09-27 15:46:37 +00:00
|
|
|
|
scanOnTouchMove: true,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
scanOnPenHover: true,
|
|
|
|
|
scanOnPenPress: true,
|
|
|
|
|
scanOnPenRelease: false,
|
2020-09-27 15:46:37 +00:00
|
|
|
|
preventTouchScrolling: true
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
include: 'mouse2',
|
|
|
|
|
exclude: '',
|
|
|
|
|
types: {
|
|
|
|
|
mouse: true,
|
|
|
|
|
touch: false,
|
|
|
|
|
pen: false
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
showAdvanced: false,
|
2020-09-27 15:53:07 +00:00
|
|
|
|
searchTerms: true,
|
|
|
|
|
searchKanji: true,
|
2020-09-27 15:46:37 +00:00
|
|
|
|
scanOnTouchMove: true,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
scanOnPenHover: true,
|
|
|
|
|
scanOnPenPress: true,
|
|
|
|
|
scanOnPenRelease: false,
|
2020-09-27 15:46:37 +00:00
|
|
|
|
preventTouchScrolling: true
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
include: '',
|
|
|
|
|
exclude: '',
|
|
|
|
|
types: {
|
|
|
|
|
mouse: false,
|
|
|
|
|
touch: true,
|
|
|
|
|
pen: true
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
showAdvanced: false,
|
2020-09-27 15:53:07 +00:00
|
|
|
|
searchTerms: true,
|
|
|
|
|
searchKanji: true,
|
2020-09-27 15:46:37 +00:00
|
|
|
|
scanOnTouchMove: true,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
scanOnPenHover: true,
|
|
|
|
|
scanOnPenPress: true,
|
|
|
|
|
scanOnPenRelease: false,
|
2020-09-27 15:46:37 +00:00
|
|
|
|
preventTouchScrolling: true
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
translation: {
|
|
|
|
|
convertHalfWidthCharacters: 'false',
|
|
|
|
|
convertNumericCharacters: 'false',
|
|
|
|
|
convertAlphabeticCharacters: 'false',
|
|
|
|
|
convertHiraganaToKatakana: 'false',
|
|
|
|
|
convertKatakanaToHiragana: 'variant',
|
2021-01-03 17:12:55 +00:00
|
|
|
|
collapseEmphaticSequences: 'false',
|
|
|
|
|
textReplacements: {
|
|
|
|
|
searchOriginal: true,
|
|
|
|
|
groups: []
|
|
|
|
|
}
|
2020-09-20 15:33:12 +00:00
|
|
|
|
},
|
2021-04-03 17:02:49 +00:00
|
|
|
|
dictionaries: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Test Dictionary',
|
2021-03-31 22:17:28 +00:00
|
|
|
|
priority: 0,
|
|
|
|
|
enabled: true,
|
|
|
|
|
allowSecondarySearches: false,
|
|
|
|
|
definitionsCollapsible: 'not-collapsible'
|
|
|
|
|
}
|
2021-04-03 17:02:49 +00:00
|
|
|
|
],
|
2020-09-20 15:33:12 +00:00
|
|
|
|
parsing: {
|
|
|
|
|
enableScanningParser: true,
|
|
|
|
|
enableMecabParser: false,
|
|
|
|
|
selectedParser: null,
|
|
|
|
|
termSpacing: true,
|
|
|
|
|
readingMode: 'hiragana'
|
|
|
|
|
},
|
|
|
|
|
anki: {
|
|
|
|
|
enable: false,
|
|
|
|
|
server: 'http://127.0.0.1:8765',
|
|
|
|
|
tags: ['yomichan'],
|
|
|
|
|
screenshot: {format: 'png', quality: 92},
|
|
|
|
|
terms: {deck: '', model: '', fields: {}},
|
|
|
|
|
kanji: {deck: '', model: '', fields: {}},
|
|
|
|
|
duplicateScope: 'collection',
|
2021-07-14 00:29:53 +00:00
|
|
|
|
duplicateScopeCheckAllModels: false,
|
2021-04-30 21:57:53 +00:00
|
|
|
|
displayTags: 'never',
|
2020-11-08 21:25:07 +00:00
|
|
|
|
checkForDuplicates: true,
|
2021-01-15 03:42:11 +00:00
|
|
|
|
fieldTemplates: null,
|
|
|
|
|
suspendNewCards: false
|
2021-01-10 02:25:04 +00:00
|
|
|
|
},
|
|
|
|
|
sentenceParsing: {
|
2021-01-10 19:43:06 +00:00
|
|
|
|
scanExtent: 200,
|
2021-05-16 19:24:38 +00:00
|
|
|
|
terminationCharacterMode: 'custom',
|
2021-01-10 19:43:06 +00:00
|
|
|
|
terminationCharacters: [
|
|
|
|
|
{enabled: true, character1: '「', character2: '」', includeCharacterAtStart: false, includeCharacterAtEnd: false},
|
|
|
|
|
{enabled: true, character1: '『', character2: '』', includeCharacterAtStart: false, includeCharacterAtEnd: false},
|
|
|
|
|
{enabled: true, character1: '"', character2: '"', includeCharacterAtStart: false, includeCharacterAtEnd: false},
|
|
|
|
|
{enabled: true, character1: '\'', character2: '\'', includeCharacterAtStart: false, includeCharacterAtEnd: false},
|
|
|
|
|
{enabled: true, character1: '.', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '!', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '?', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '.', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '。', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '!', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '?', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true},
|
|
|
|
|
{enabled: true, character1: '…', character2: null, includeCharacterAtStart: false, includeCharacterAtEnd: true}
|
|
|
|
|
]
|
2021-01-15 01:56:18 +00:00
|
|
|
|
},
|
|
|
|
|
inputs: {
|
|
|
|
|
hotkeys: [
|
2021-03-28 02:30:45 +00:00
|
|
|
|
{action: 'close', argument: '', key: 'Escape', modifiers: [], scopes: ['popup'], enabled: true},
|
|
|
|
|
{action: 'focusSearchBox', argument: '', key: 'Escape', modifiers: [], scopes: ['search'], enabled: true},
|
|
|
|
|
{action: 'previousEntry', argument: '3', key: 'PageUp', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'nextEntry', argument: '3', key: 'PageDown', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'lastEntry', argument: '', key: 'End', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'firstEntry', argument: '', key: 'Home', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'previousEntry', argument: '1', key: 'ArrowUp', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'nextEntry', argument: '1', key: 'ArrowDown', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'historyBackward', argument: '', key: 'KeyB', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'historyForward', argument: '', key: 'KeyF', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'addNoteKanji', argument: '', key: 'KeyK', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'addNoteTermKanji', argument: '', key: 'KeyE', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'addNoteTermKana', argument: '', key: 'KeyR', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'playAudio', argument: '', key: 'KeyP', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'viewNote', argument: '', key: 'KeyV', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
|
|
|
|
|
{action: 'copyHostSelection', argument: '', key: 'KeyC', modifiers: ['ctrl'], scopes: ['popup'], enabled: true}
|
2021-01-15 01:56:18 +00:00
|
|
|
|
]
|
2021-01-16 15:22:24 +00:00
|
|
|
|
},
|
|
|
|
|
popupWindow: {
|
|
|
|
|
width: 400,
|
|
|
|
|
height: 250,
|
|
|
|
|
left: 0,
|
|
|
|
|
top: 0,
|
|
|
|
|
useLeft: false,
|
|
|
|
|
useTop: false,
|
|
|
|
|
windowType: 'popup',
|
|
|
|
|
windowState: 'normal'
|
2021-01-26 23:30:01 +00:00
|
|
|
|
},
|
|
|
|
|
clipboard: {
|
|
|
|
|
enableBackgroundMonitor: false,
|
|
|
|
|
enableSearchPageMonitor: false,
|
|
|
|
|
autoSearchContent: true,
|
|
|
|
|
maximumSearchLength: 1000
|
2021-08-07 16:40:51 +00:00
|
|
|
|
},
|
|
|
|
|
accessibility: {
|
|
|
|
|
forceGoogleDocsHtmlRendering: false
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createOptionsUpdatedTestData1() {
|
|
|
|
|
return {
|
|
|
|
|
profiles: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Default',
|
|
|
|
|
options: createProfileOptionsUpdatedTestData1(),
|
|
|
|
|
conditionGroups: [
|
|
|
|
|
{
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'equal',
|
|
|
|
|
value: '1'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'notEqual',
|
|
|
|
|
value: '0'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'lessThan',
|
|
|
|
|
value: '3'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'greaterThan',
|
|
|
|
|
value: '0'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'lessThanOrEqual',
|
|
|
|
|
value: '2'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'popupLevel',
|
|
|
|
|
operator: 'greaterThanOrEqual',
|
|
|
|
|
value: '1'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
type: 'url',
|
|
|
|
|
operator: 'matchDomain',
|
|
|
|
|
value: 'example.com'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'url',
|
|
|
|
|
operator: 'matchRegExp',
|
|
|
|
|
value: 'example\\.com'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'are',
|
|
|
|
|
value: 'ctrl, shift'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'areNot',
|
|
|
|
|
value: 'alt, shift'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'include',
|
|
|
|
|
value: 'alt'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'modifierKeys',
|
|
|
|
|
operator: 'notInclude',
|
|
|
|
|
value: 'ctrl'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
profileCurrent: 0,
|
2021-09-26 15:08:16 +00:00
|
|
|
|
version: 15,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
global: {
|
|
|
|
|
database: {
|
|
|
|
|
prefixWildcardsSupported: false
|
2021-03-15 02:51:48 +00:00
|
|
|
|
}
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function testUpdate(extDir) {
|
|
|
|
|
const vm = createVM(extDir);
|
|
|
|
|
const [OptionsUtil] = vm.get(['OptionsUtil']);
|
|
|
|
|
const optionsUtil = new OptionsUtil();
|
|
|
|
|
await optionsUtil.prepare();
|
|
|
|
|
|
|
|
|
|
const options = createOptionsTestData1();
|
|
|
|
|
const optionsUpdated = clone(await optionsUtil.update(options));
|
|
|
|
|
const optionsExpected = createOptionsUpdatedTestData1();
|
|
|
|
|
assert.deepStrictEqual(optionsUpdated, optionsExpected);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 23:26:30 +00:00
|
|
|
|
async function testDefault(extDir) {
|
|
|
|
|
const data = [
|
|
|
|
|
(options) => options,
|
|
|
|
|
(options) => {
|
|
|
|
|
delete options.profiles[0].options.audio.autoPlay;
|
|
|
|
|
},
|
|
|
|
|
(options) => {
|
|
|
|
|
options.profiles[0].options.audio.autoPlay = void 0;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const vm = createVM(extDir);
|
|
|
|
|
const [OptionsUtil] = vm.get(['OptionsUtil']);
|
|
|
|
|
const optionsUtil = new OptionsUtil();
|
|
|
|
|
await optionsUtil.prepare();
|
|
|
|
|
|
|
|
|
|
for (const modify of data) {
|
|
|
|
|
const options = optionsUtil.getDefault();
|
|
|
|
|
|
|
|
|
|
const optionsModified = clone(options);
|
|
|
|
|
modify(optionsModified);
|
|
|
|
|
|
|
|
|
|
const optionsUpdated = await optionsUtil.update(clone(optionsModified));
|
|
|
|
|
assert.deepStrictEqual(clone(optionsUpdated), clone(options));
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-20 15:33:12 +00:00
|
|
|
|
|
|
|
|
|
async function testFieldTemplatesUpdate(extDir) {
|
|
|
|
|
const vm = createVM(extDir);
|
2021-01-29 02:17:10 +00:00
|
|
|
|
const [OptionsUtil, TemplatePatcher] = vm.get(['OptionsUtil', 'TemplatePatcher']);
|
2020-09-20 15:33:12 +00:00
|
|
|
|
const optionsUtil = new OptionsUtil();
|
|
|
|
|
await optionsUtil.prepare();
|
|
|
|
|
|
2021-01-29 02:17:10 +00:00
|
|
|
|
const templatePatcher = new TemplatePatcher();
|
|
|
|
|
const loadDataFile = (fileName) => {
|
|
|
|
|
const content = fs.readFileSync(path.join(extDir, fileName), {encoding: 'utf8'});
|
|
|
|
|
return templatePatcher.parsePatch(content).addition;
|
|
|
|
|
};
|
2021-06-27 03:55:06 +00:00
|
|
|
|
const updates = [
|
|
|
|
|
{version: 2, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v2.handlebars')},
|
|
|
|
|
{version: 4, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v4.handlebars')},
|
|
|
|
|
{version: 6, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v6.handlebars')},
|
|
|
|
|
{version: 8, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v8.handlebars')},
|
|
|
|
|
{version: 10, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v10.handlebars')},
|
2021-07-03 02:46:38 +00:00
|
|
|
|
{version: 12, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v12.handlebars')},
|
|
|
|
|
{version: 13, changes: loadDataFile('data/templates/anki-field-templates-upgrade-v13.handlebars')}
|
2021-06-27 03:55:06 +00:00
|
|
|
|
];
|
2021-07-06 03:24:06 +00:00
|
|
|
|
const getUpdateAdditions = (startVersion, targetVersion) => {
|
2021-06-27 03:55:06 +00:00
|
|
|
|
let value = '';
|
|
|
|
|
for (const {version, changes} of updates) {
|
2021-07-07 02:59:24 +00:00
|
|
|
|
if (version <= startVersion || version > targetVersion || changes.length === 0) { continue; }
|
2021-06-27 03:55:06 +00:00
|
|
|
|
if (value.length > 0) { value += '\n'; }
|
|
|
|
|
value += changes;
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
};
|
2020-09-20 15:33:12 +00:00
|
|
|
|
|
|
|
|
|
const data = [
|
|
|
|
|
// Standard format
|
|
|
|
|
{
|
2021-07-06 03:24:06 +00:00
|
|
|
|
oldVersion: 0,
|
|
|
|
|
newVersion: 12,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
old: `
|
|
|
|
|
{{#*inline "character"}}
|
|
|
|
|
{{~definition.character~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart(),
|
|
|
|
|
|
|
|
|
|
expected: `
|
|
|
|
|
{{#*inline "character"}}
|
|
|
|
|
{{~definition.character~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
2021-07-06 03:24:06 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
2020-09-20 15:33:12 +00:00
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart()
|
|
|
|
|
},
|
|
|
|
|
// Non-standard marker format
|
|
|
|
|
{
|
2021-07-06 03:24:06 +00:00
|
|
|
|
oldVersion: 0,
|
|
|
|
|
newVersion: 12,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
old: `
|
|
|
|
|
{{#*inline "character"}}
|
|
|
|
|
{{~definition.character~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker2") ~}}`.trimStart(),
|
|
|
|
|
|
|
|
|
|
expected: `
|
|
|
|
|
{{#*inline "character"}}
|
|
|
|
|
{{~definition.character~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker2") ~}}
|
2021-07-06 03:24:06 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>`.trimStart()
|
2020-09-20 15:33:12 +00:00
|
|
|
|
},
|
|
|
|
|
// Empty test
|
|
|
|
|
{
|
2021-07-06 03:24:06 +00:00
|
|
|
|
oldVersion: 0,
|
|
|
|
|
newVersion: 12,
|
2020-09-20 15:33:12 +00:00
|
|
|
|
old: `
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart(),
|
|
|
|
|
|
|
|
|
|
expected: `
|
2021-07-06 03:24:06 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
2020-09-20 15:33:12 +00:00
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart()
|
2020-11-13 01:34:11 +00:00
|
|
|
|
},
|
|
|
|
|
// Definition tags update
|
|
|
|
|
{
|
2021-07-06 03:24:06 +00:00
|
|
|
|
oldVersion: 0,
|
|
|
|
|
newVersion: 12,
|
2020-11-13 01:34:11 +00:00
|
|
|
|
old: `
|
|
|
|
|
{{#*inline "glossary-single"}}
|
|
|
|
|
{{~#unless brief~}}
|
|
|
|
|
{{~#if definitionTags~}}<i>({{#each definitionTags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}})</i> {{/if~}}
|
|
|
|
|
{{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
|
|
|
{{~/unless~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "glossary-single2"}}
|
|
|
|
|
{{~#unless brief~}}
|
|
|
|
|
{{~#if definitionTags~}}<i>({{#each definitionTags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}})</i> {{/if~}}
|
|
|
|
|
{{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
|
|
|
{{~/unless~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "glossary"}}
|
|
|
|
|
{{~> glossary-single definition brief=brief compactGlossaries=compactGlossaries~}}
|
|
|
|
|
{{~> glossary-single definition brief=brief compactGlossaries=../compactGlossaries~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker") ~}}
|
|
|
|
|
`.trimStart(),
|
|
|
|
|
|
|
|
|
|
expected: `
|
|
|
|
|
{{#*inline "glossary-single"}}
|
|
|
|
|
{{~#unless brief~}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "any" false}}{{/set~}}
|
|
|
|
|
{{~#if definitionTags~}}{{#each definitionTags~}}
|
|
|
|
|
{{~#if (op "||" (op "!" ../data.compactTags) (op "!" redundant))~}}
|
|
|
|
|
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
|
|
|
{{name}}
|
|
|
|
|
{{~#set "any" true}}{{/set~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~#if (get "any")}})</i> {{/if~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
|
|
|
{{~/unless~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "glossary-single2"}}
|
|
|
|
|
{{~#unless brief~}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "any" false}}{{/set~}}
|
|
|
|
|
{{~#if definitionTags~}}{{#each definitionTags~}}
|
|
|
|
|
{{~#if (op "||" (op "!" ../data.compactTags) (op "!" redundant))~}}
|
|
|
|
|
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
|
|
|
{{name}}
|
|
|
|
|
{{~#set "any" true}}{{/set~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~#if (get "any")}})</i> {{/if~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
|
|
|
{{~/unless~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "glossary"}}
|
|
|
|
|
{{~> glossary-single definition brief=brief compactGlossaries=compactGlossaries data=.~}}
|
|
|
|
|
{{~> glossary-single definition brief=brief compactGlossaries=../compactGlossaries data=../.~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
2021-07-06 03:24:06 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
2020-11-13 01:34:11 +00:00
|
|
|
|
{{~> (lookup . "marker") ~}}
|
|
|
|
|
`.trimStart()
|
2021-01-29 02:17:10 +00:00
|
|
|
|
},
|
|
|
|
|
// glossary and glossary-brief update
|
|
|
|
|
{
|
|
|
|
|
oldVersion: 7,
|
2021-07-06 03:24:06 +00:00
|
|
|
|
newVersion: 12,
|
2021-01-29 02:17:10 +00:00
|
|
|
|
old: `
|
|
|
|
|
{{#*inline "glossary-single"}}
|
|
|
|
|
{{~#unless brief~}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "any" false}}{{/set~}}
|
|
|
|
|
{{~#if definitionTags~}}{{#each definitionTags~}}
|
|
|
|
|
{{~#if (op "||" (op "!" ../data.compactTags) (op "!" redundant))~}}
|
|
|
|
|
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
|
|
|
{{name}}
|
|
|
|
|
{{~#set "any" true}}{{/set~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~#if (get "any")}})</i> {{/if~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{~#if only~}}({{#each only}}{{{.}}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
|
|
|
{{~/unless~}}
|
|
|
|
|
{{~#if glossary.[1]~}}
|
|
|
|
|
{{~#if compactGlossaries~}}
|
|
|
|
|
{{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
<ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{~#multiLine}}{{glossary.[0]}}{{/multiLine~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "character"}}
|
|
|
|
|
{{~definition.character~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "glossary"}}
|
|
|
|
|
<div style="text-align: left;">
|
|
|
|
|
{{~#if modeKanji~}}
|
|
|
|
|
{{~#if definition.glossary.[1]~}}
|
|
|
|
|
<ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{definition.glossary.[0]}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{~#if group~}}
|
|
|
|
|
{{~#if definition.definitions.[1]~}}
|
|
|
|
|
<ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief compactGlossaries=../compactGlossaries data=../.}}</li>{{/each}}</ol>
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{~> glossary-single definition.definitions.[0] brief=brief compactGlossaries=compactGlossaries data=.~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~else if merge~}}
|
|
|
|
|
{{~#if definition.definitions.[1]~}}
|
|
|
|
|
<ol>{{#each definition.definitions}}<li>{{> glossary-single brief=../brief compactGlossaries=../compactGlossaries data=../.}}</li>{{/each}}</ol>
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{~> glossary-single definition.definitions.[0] brief=brief compactGlossaries=compactGlossaries data=.~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{~> glossary-single definition brief=brief compactGlossaries=compactGlossaries data=.~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
</div>
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "glossary-brief"}}
|
|
|
|
|
{{~> glossary brief=true ~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart(),
|
|
|
|
|
|
|
|
|
|
expected: `
|
|
|
|
|
{{#*inline "glossary-single"}}
|
|
|
|
|
{{~#unless brief~}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "any" false}}{{/set~}}
|
|
|
|
|
{{~#each definitionTags~}}
|
|
|
|
|
{{~#if (op "||" (op "!" @root.compactTags) (op "!" redundant))~}}
|
|
|
|
|
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
|
|
|
{{name}}
|
|
|
|
|
{{~#set "any" true}}{{/set~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/each~}}
|
2021-01-29 02:33:30 +00:00
|
|
|
|
{{~#unless noDictionaryTag~}}
|
|
|
|
|
{{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
|
|
|
|
|
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
|
|
|
{{dictionary}}
|
|
|
|
|
{{~#set "any" true}}{{/set~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/unless~}}
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~#if (get "any")}})</i> {{/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
|
|
|
{{~/unless~}}
|
|
|
|
|
{{~#if (op "<=" glossary.length 1)~}}
|
2021-07-06 03:24:06 +00:00
|
|
|
|
{{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{/each}}
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~else if @root.compactGlossaries~}}
|
2021-07-06 03:24:06 +00:00
|
|
|
|
{{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}}
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~else~}}
|
2021-07-06 03:24:06 +00:00
|
|
|
|
<ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~/if~}}
|
2021-01-29 02:33:30 +00:00
|
|
|
|
{{~#set "previousDictionary" dictionary~}}{{~/set~}}
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "character"}}
|
|
|
|
|
{{~definition.character~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~#*inline "glossary"~}}
|
|
|
|
|
<div style="text-align: left;">
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#if (op "===" definition.type "term")~}}
|
2021-01-29 02:33:30 +00:00
|
|
|
|
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
|
|
|
|
|
{{~#if (op ">" definition.definitions.length 1)~}}
|
2021-01-29 02:33:30 +00:00
|
|
|
|
<ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}</li>{{~/each~}}</ol>
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~else~}}
|
2021-01-29 02:33:30 +00:00
|
|
|
|
{{~#each definition.definitions~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/each~}}
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~else if (op "===" definition.type "kanji")~}}
|
|
|
|
|
{{~#if (op ">" definition.glossary.length 1)~}}
|
|
|
|
|
<ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
|
|
|
|
|
{{~else~}}
|
|
|
|
|
{{~#each definition.glossary~}}{{.}}{{~/each~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
</div>
|
|
|
|
|
{{~/inline~}}
|
|
|
|
|
|
2021-01-29 02:33:30 +00:00
|
|
|
|
{{#*inline "glossary-no-dictionary"}}
|
|
|
|
|
{{~> glossary noDictionaryTag=true ~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{#*inline "glossary-brief"}}
|
|
|
|
|
{{~> glossary brief=true ~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
2021-07-06 03:24:06 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
2021-01-29 02:17:10 +00:00
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart()
|
2021-07-03 02:46:38 +00:00
|
|
|
|
},
|
|
|
|
|
// formatGlossary update
|
|
|
|
|
{
|
|
|
|
|
oldVersion: 12,
|
2021-07-06 03:24:06 +00:00
|
|
|
|
newVersion: 13,
|
2021-07-03 02:46:38 +00:00
|
|
|
|
old: `
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{#*inline "example"}}
|
2021-07-03 02:46:38 +00:00
|
|
|
|
{{~#if (op "<=" glossary.length 1)~}}
|
|
|
|
|
{{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{/each}}
|
|
|
|
|
{{~else if @root.compactGlossaries~}}
|
|
|
|
|
{{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
<ul>{{#each glossary}}<li>{{#multiLine}}{{.}}{{/multiLine}}</li>{{/each}}</ul>
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart(),
|
2021-07-03 02:46:38 +00:00
|
|
|
|
|
|
|
|
|
expected: `
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{#*inline "example"}}
|
2021-07-03 02:46:38 +00:00
|
|
|
|
{{~#if (op "<=" glossary.length 1)~}}
|
|
|
|
|
{{#each glossary}}{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{/each}}
|
|
|
|
|
{{~else if @root.compactGlossaries~}}
|
|
|
|
|
{{#each glossary}}{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{#unless @last}} | {{/unless}}{{/each}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
<ul>{{#each glossary}}<li>{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}</li>{{/each}}</ul>
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
2021-07-08 00:00:30 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart()
|
2021-07-06 23:43:53 +00:00
|
|
|
|
},
|
|
|
|
|
// hasMedia/getMedia update
|
|
|
|
|
{
|
|
|
|
|
oldVersion: 12,
|
|
|
|
|
newVersion: 13,
|
|
|
|
|
old: `
|
|
|
|
|
{{#*inline "audio"}}
|
|
|
|
|
{{~#if definition.audioFileName~}}
|
|
|
|
|
[sound:{{definition.audioFileName}}]
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "screenshot"}}
|
|
|
|
|
<img src="{{definition.screenshotFileName}}" />
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "clipboard-image"}}
|
|
|
|
|
{{~#if definition.clipboardImageFileName~}}
|
|
|
|
|
<img src="{{definition.clipboardImageFileName}}" />
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "clipboard-text"}}
|
|
|
|
|
{{~#if definition.clipboardText~}}{{definition.clipboardText}}{{~/if~}}
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart(),
|
2021-07-06 23:43:53 +00:00
|
|
|
|
|
|
|
|
|
expected: `
|
|
|
|
|
{{#*inline "audio"}}
|
|
|
|
|
{{~#if (hasMedia "audio")~}}
|
2021-07-10 00:14:05 +00:00
|
|
|
|
[sound:{{#getMedia "audio"}}{{/getMedia}}]
|
2021-07-06 23:43:53 +00:00
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "screenshot"}}
|
|
|
|
|
{{~#if (hasMedia "screenshot")~}}
|
2021-07-10 00:14:05 +00:00
|
|
|
|
<img src="{{#getMedia "screenshot"}}{{/getMedia}}" />
|
2021-07-06 23:43:53 +00:00
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "clipboard-image"}}
|
|
|
|
|
{{~#if (hasMedia "clipboardImage")~}}
|
2021-07-10 00:14:05 +00:00
|
|
|
|
<img src="{{#getMedia "clipboardImage"}}{{/getMedia}}" />
|
2021-07-06 23:43:53 +00:00
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "clipboard-text"}}
|
2021-07-10 00:14:05 +00:00
|
|
|
|
{{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText"}}{{/getMedia}}{{/if~}}
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{/inline}}
|
|
|
|
|
|
2021-07-18 20:01:42 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart()
|
|
|
|
|
},
|
|
|
|
|
// hasMedia/getMedia update
|
|
|
|
|
{
|
|
|
|
|
oldVersion: 12,
|
|
|
|
|
newVersion: 13,
|
|
|
|
|
old: `
|
|
|
|
|
{{! Pitch Accents }}
|
|
|
|
|
{{#*inline "pitch-accent-item-downstep-notation"}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
<span>
|
|
|
|
|
{{~#set "style1a"~}}display:inline-block;position:relative;{{~/set~}}
|
|
|
|
|
{{~#set "style1b"~}}padding-right:0.1em;margin-right:0.1em;{{~/set~}}
|
|
|
|
|
{{~#set "style2a"~}}display:block;user-select:none;pointer-events:none;position:absolute;top:0.1em;left:0;right:0;height:0;border-top:0.1em solid;{{~/set~}}
|
|
|
|
|
{{~#set "style2b"~}}right:-0.1em;height:0.4em;border-right:0.1em solid;{{~/set~}}
|
|
|
|
|
{{~#each (getKanaMorae reading)~}}
|
|
|
|
|
{{~#set "style1"}}{{#get "style1a"}}{{/get}}{{/set~}}
|
|
|
|
|
{{~#set "style2"}}{{/set~}}
|
|
|
|
|
{{~#if (isMoraPitchHigh @index ../position)}}
|
|
|
|
|
{{~#set "style2"}}{{#get "style2a"}}{{/get}}{{/set~}}
|
|
|
|
|
{{~#if (op "!" (isMoraPitchHigh (op "+" @index 1) ../position))~}}
|
|
|
|
|
{{~#set "style1" (op "+" (get "style1") (get "style1b"))}}{{/set~}}
|
|
|
|
|
{{~#set "style2" (op "+" (get "style2") (get "style2b"))}}{{/set~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
<span style="{{#get "style1"}}{{/get}}">{{{.}}}<span style="{{#get "style2"}}{{/get}}"></span></span>
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
</span>
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-item-graph-position-x"}}{{#op "+" 25 (op "*" index 50)}}{{/op}}{{/inline}}
|
|
|
|
|
{{#*inline "pitch-accent-item-graph-position-y"}}{{#op "+" 25 (op "?:" (isMoraPitchHigh index position) 0 50)}}{{/op}}{{/inline}}
|
|
|
|
|
{{#*inline "pitch-accent-item-graph-position"}}{{> pitch-accent-item-graph-position-x index=index position=position}} {{> pitch-accent-item-graph-position-y index=index position=position}}{{/inline}}
|
|
|
|
|
{{#*inline "pitch-accent-item-graph"}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "morae" (getKanaMorae reading)}}{{/set~}}
|
|
|
|
|
{{~#set "morae-count" (property (get "morae") "length")}}{{/set~}}
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {{#op "+" 50 (op "*" 50 (get "morae-count"))}}{{/op}} 100" style="display:inline-block;height:2em;">
|
|
|
|
|
<defs>
|
|
|
|
|
<g id="term-pitch-accent-graph-dot"><circle cx="0" cy="0" r="15" style="fill:#000;stroke:#000;stroke-width:5;" /></g>
|
|
|
|
|
<g id="term-pitch-accent-graph-dot-downstep"><circle cx="0" cy="0" r="15" style="fill:none;stroke:#000;stroke-width:5;" /><circle cx="0" cy="0" r="5" style="fill:none;stroke:#000;stroke-width:5;" /></g>
|
|
|
|
|
<g id="term-pitch-accent-graph-triangle"><path d="M0 13 L15 -13 L-15 -13 Z" style="fill:none;stroke:#000;stroke-width:5;" /></g>
|
|
|
|
|
</defs>
|
|
|
|
|
<path style="fill:none;stroke:#000;stroke-width:5;" d="
|
|
|
|
|
{{~#set "cmd" "M"}}{{/set~}}
|
|
|
|
|
{{~#each (get "morae")~}}
|
|
|
|
|
{{~#get "cmd"}}{{/get~}}
|
|
|
|
|
{{~> pitch-accent-item-graph-position index=@index position=../position~}}
|
|
|
|
|
{{~#set "cmd" "L"}}{{/set~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
"></path>
|
|
|
|
|
<path style="fill:none;stroke:#000;stroke-width:5;stroke-dasharray:5 5;" d="M{{> pitch-accent-item-graph-position index=(op "-" (get "morae-count") 1) position=position}} L{{> pitch-accent-item-graph-position index=(get "morae-count") position=position}}"></path>
|
|
|
|
|
{{#each (get "morae")}}
|
|
|
|
|
<use href="{{#if (op "&&" (isMoraPitchHigh @index ../position) (op "!" (isMoraPitchHigh (op "+" @index 1) ../position)))}}#term-pitch-accent-graph-dot-downstep{{else}}#term-pitch-accent-graph-dot{{/if}}" x="{{> pitch-accent-item-graph-position-x index=@index position=../position}}" y="{{> pitch-accent-item-graph-position-y index=@index position=../position}}"></use>
|
|
|
|
|
{{/each}}
|
|
|
|
|
<use href="#term-pitch-accent-graph-triangle" x="{{> pitch-accent-item-graph-position-x index=(get "morae-count") position=position}}" y="{{> pitch-accent-item-graph-position-y index=(get "morae-count") position=position}}"></use>
|
|
|
|
|
</svg>
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-item-position"~}}
|
|
|
|
|
<span>[{{position}}]</span>
|
|
|
|
|
{{~/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-item"}}
|
|
|
|
|
{{~#if (op "==" format "downstep-notation")~}}
|
|
|
|
|
{{~> pitch-accent-item-downstep-notation~}}
|
|
|
|
|
{{~else if (op "==" format "graph")~}}
|
|
|
|
|
{{~> pitch-accent-item-graph~}}
|
|
|
|
|
{{~else if (op "==" format "position")~}}
|
|
|
|
|
{{~> pitch-accent-item-position~}}
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-item-disambiguation"}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "exclusive" (spread exclusiveExpressions exclusiveReadings)}}{{/set~}}
|
|
|
|
|
{{~#if (op ">" (property (get "exclusive") "length") 0)~}}
|
|
|
|
|
{{~#set "separator" ""~}}{{/set~}}
|
|
|
|
|
<em>({{#each (get "exclusive")~}}
|
|
|
|
|
{{~#get "separator"}}{{/get~}}{{{.}}}
|
|
|
|
|
{{~/each}} only) </em>
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-list"}}
|
|
|
|
|
{{~#if (op ">" pitchCount 0)~}}
|
|
|
|
|
{{~#if (op ">" pitchCount 1)~}}<ol>{{~/if~}}
|
|
|
|
|
{{~#each pitches~}}
|
|
|
|
|
{{~#each pitches~}}
|
|
|
|
|
{{~#if (op ">" ../../pitchCount 1)~}}<li>{{~/if~}}
|
|
|
|
|
{{~> pitch-accent-item-disambiguation~}}
|
|
|
|
|
{{~> pitch-accent-item format=../../format~}}
|
|
|
|
|
{{~#if (op ">" ../../pitchCount 1)~}}</li>{{~/if~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~#if (op ">" pitchCount 1)~}}</ol>{{~/if~}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
No pitch accent data
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accents"}}
|
|
|
|
|
{{~> pitch-accent-list format='downstep-notation'~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-graphs"}}
|
|
|
|
|
{{~> pitch-accent-list format='graph'~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-positions"}}
|
|
|
|
|
{{~> pitch-accent-list format='position'~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
{{! End Pitch Accents }}
|
|
|
|
|
|
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart(),
|
|
|
|
|
|
|
|
|
|
expected: `
|
|
|
|
|
{{! Pitch Accents }}
|
|
|
|
|
{{#*inline "pitch-accent-item"}}
|
|
|
|
|
{{~#pronunciation format=format reading=reading downstepPosition=position nasalPositions=nasalPositions devoicePositions=devoicePositions~}}{{~/pronunciation~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-item-disambiguation"}}
|
|
|
|
|
{{~#scope~}}
|
|
|
|
|
{{~#set "exclusive" (spread exclusiveExpressions exclusiveReadings)}}{{/set~}}
|
|
|
|
|
{{~#if (op ">" (property (get "exclusive") "length") 0)~}}
|
|
|
|
|
{{~#set "separator" ""~}}{{/set~}}
|
|
|
|
|
<em>({{#each (get "exclusive")~}}
|
|
|
|
|
{{~#get "separator"}}{{/get~}}{{{.}}}
|
|
|
|
|
{{~/each}} only) </em>
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{~/scope~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-list"}}
|
|
|
|
|
{{~#if (op ">" pitchCount 0)~}}
|
|
|
|
|
{{~#if (op ">" pitchCount 1)~}}<ol>{{~/if~}}
|
|
|
|
|
{{~#each pitches~}}
|
|
|
|
|
{{~#each pitches~}}
|
|
|
|
|
{{~#if (op ">" ../../pitchCount 1)~}}<li>{{~/if~}}
|
|
|
|
|
{{~> pitch-accent-item-disambiguation~}}
|
|
|
|
|
{{~> pitch-accent-item format=../../format~}}
|
|
|
|
|
{{~#if (op ">" ../../pitchCount 1)~}}</li>{{~/if~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~/each~}}
|
|
|
|
|
{{~#if (op ">" pitchCount 1)~}}</ol>{{~/if~}}
|
|
|
|
|
{{~else~}}
|
|
|
|
|
No pitch accent data
|
|
|
|
|
{{~/if~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accents"}}
|
|
|
|
|
{{~> pitch-accent-list format='text'~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-graphs"}}
|
|
|
|
|
{{~> pitch-accent-list format='graph'~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
|
|
|
|
|
{{#*inline "pitch-accent-positions"}}
|
|
|
|
|
{{~> pitch-accent-list format='position'~}}
|
|
|
|
|
{{/inline}}
|
|
|
|
|
{{! End Pitch Accents }}
|
|
|
|
|
|
2021-07-08 00:00:30 +00:00
|
|
|
|
<<<UPDATE-ADDITIONS>>>
|
2021-07-07 02:59:24 +00:00
|
|
|
|
{{~> (lookup . "marker") ~}}`.trimStart()
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2021-07-06 03:24:06 +00:00
|
|
|
|
const updatesPattern = /<<<UPDATE-ADDITIONS>>>/g;
|
|
|
|
|
for (const {old, expected, oldVersion, newVersion} of data) {
|
2020-09-20 15:33:12 +00:00
|
|
|
|
const options = createOptionsTestData1();
|
|
|
|
|
options.profiles[0].options.anki.fieldTemplates = old;
|
2021-07-06 03:24:06 +00:00
|
|
|
|
options.version = oldVersion;
|
|
|
|
|
|
|
|
|
|
const expected2 = expected.replace(updatesPattern, getUpdateAdditions(oldVersion, newVersion));
|
2021-01-29 02:17:10 +00:00
|
|
|
|
|
2021-07-06 03:24:06 +00:00
|
|
|
|
const optionsUpdated = clone(await optionsUtil.update(options, newVersion));
|
2020-09-20 15:33:12 +00:00
|
|
|
|
const fieldTemplatesActual = optionsUpdated.profiles[0].options.anki.fieldTemplates;
|
2021-07-06 03:24:06 +00:00
|
|
|
|
assert.deepStrictEqual(fieldTemplatesActual, expected2);
|
2020-09-20 15:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
|
const extDir = path.join(__dirname, '..', 'ext');
|
|
|
|
|
await testUpdate(extDir);
|
2020-10-27 23:26:30 +00:00
|
|
|
|
await testDefault(extDir);
|
2020-09-20 15:33:12 +00:00
|
|
|
|
await testFieldTemplatesUpdate(extDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-07 16:34:14 +00:00
|
|
|
|
if (require.main === module) { testMain(main); }
|