yomichan/test/data/dictionaries/valid-dictionary1/term_bank_1.json
toasted-nutbread 5dcc2315d2
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
2022-05-14 18:12:57 -04:00

311 lines
20 KiB
JSON

[
["打", "だ", "n", "n", 1, ["da definition 1", "da definition 2"], 1, "E1"],
["打", "ダース", "n abbr", "n", 1, ["daasu definition 1", "daasu definition 2"], 2, "E1"],
["打つ", "うつ", "vt", "v5", 10, ["utsu definition 1", "utsu definition 2"], 3, "P E1"],
["打つ", "うつ", "vt", "v5", 1, ["utsu definition 3", "utsu definition 4"], 3, "P E2"],
["打つ", "ぶつ", "vt", "v5", 10, ["butsu definition 1", "butsu definition 2"], 3, "P E1"],
["打つ", "ぶつ", "vt", "v5", 1, ["butsu definition 3", "butsu definition 4"], 3, "P E2"],
["打ち込む", "うちこむ", "vt", "v5", 10, ["uchikomu definition 1", "uchikomu definition 2"], 4, "P E1"],
["打ち込む", "うちこむ", "vt", "v5", 1, ["uchikomu definition 3", "uchikomu definition 4"], 4, "P E2"],
["打ち込む", "ぶちこむ", "vt", "v5", 10, ["buchikomu definition 1", "buchikomu definition 2"], 4, "P E1"],
["打ち込む", "ぶちこむ", "vt", "v5", 1, ["buchikomu definition 3", "buchikomu definition 4"], 4, "P E2"],
["画像", "がぞう", "n", "n", 1, ["gazou definition 1", {"type": "image", "path": "image.gif", "width": 350, "height": 350, "description": "gazou definition 2", "pixelated": true}], 5, "P E1"],
["読む", "よむ", "vt", "v5", 100, ["to read"], 6, "P E1"],
["強み", "つよみ", "n", "n", 90, ["strong point"], 7, "P E1"],
["テキスト", "テキスト", "n", "n", 1, ["text definition 1", {"type": "text", "text": "text definition 2"}], 8, "P E1"],
["お手前", "おてまえ", "n", "n", 1, ["otemae definition"], 9, ""],
["番号", "ばんごう", "n", "n", 1, ["bangou definition"], 10, ""],
["中腰", "ちゅうごし", "n", "n", 1, ["chuugoshi definition"], 11, ""],
["所業", "しょぎょう", "n", "n", 1, ["shogyouu definition"], 12, ""],
["土木工事", "どぼくこうじ", "n", "n", 1, ["dobokukouji definition"], 13, ""],
[
"内容", "ないよう", "n", "n", 35,
[
"naiyou definition 1",
{"type": "structured-content", "content": "naiyou definition 2"},
{"type": "structured-content", "content": ["naiyou definition 3"]},
{"type": "structured-content", "content": {"tag": "img", "path": "image.gif", "width": 35, "height": 35, "pixelated": true}},
{"type": "structured-content", "content": [
"naiyou definition 5: ",
{"tag": "img", "path": "image.gif", "width": 35, "height": 35, "pixelated": true, "collapsible": false},
"\nmore content 1: ",
{"tag": "img", "path": "image.gif", "width": 35, "height": 35, "pixelated": true, "collapsible": true},
"\nmore content 2: ",
{"tag": "img", "path": "image.gif", "width": 35, "height": 35, "pixelated": true, "collapsible": false, "collapsed": false, "verticalAlign": "middle"},
" and ",
{"tag": "img", "path": "image.gif", "width": 35, "height": 35, "pixelated": true, "collapsible": false, "collapsed": true},
" and ",
{"tag": "img", "path": "image.gif", "width": 1, "height": 1, "pixelated": true, "collapsible": false, "collapsed": false, "sizeUnits": "em"}
]},
{"type": "structured-content", "content": [
"naiyou definition 6: ",
{"tag": "ruby", "content": ["内", {"tag": "rp", "content": "("}, {"tag": "rt", "content": "ない"}, {"tag": "rp", "content": ")"}]},
{"tag": "ruby", "content": ["容", {"tag": "rp", "content": "("}, {"tag": "rt", "content": "よう"}, {"tag": "rp", "content": ")"}]}
]},
{"type": "structured-content", "content": [
"imageRendering=auto: ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "auto", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢 ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "auto", "background": false, "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢 ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "auto", "background": false, "appearance": "monochrome", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢\n",
"imageRendering=pixelated: ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "pixelated", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢 ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "pixelated", "background": false, "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢 ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "pixelated", "background": false, "appearance": "monochrome", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢\n",
"imageRendering=crisp-edges: ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "crisp-edges", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢 ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "crisp-edges", "background": false, "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢 ",
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "crisp-edges", "background": false, "appearance": "monochrome", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢\n"
]},
{"type": "structured-content", "content": [
"Imgae aspect ratio tests:\nあ",
{"tag": "img", "path": "character2.gif", "height": 1.1, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ\nあ",
{"tag": "img", "path": "character2.gif", "width": 0.4125, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ\nあ",
{"tag": "img", "path": "character3.gif", "width": 1.1, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ\nあ",
{"tag": "img", "path": "character3.gif", "height": 0.4125, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ"
]},
{"type": "structured-content", "content": [
{"tag": "div", "style": {"fontStyle": "normal"}, "content": "fontStyle:normal"},
{"tag": "div", "style": {"fontStyle": "italic"}, "content": "fontStyle:italic"},
{"tag": "div", "style": {"fontWeight": "normal"}, "content": "fontWeight:normal"},
{"tag": "div", "style": {"fontWeight": "bold"}, "content": "fontWeight:bold"},
{"tag": "div", "style": {"fontSize": "xx-small"}, "content": "fontSize:xx-small"},
{"tag": "div", "style": {"fontSize": "x-small"}, "content": "fontSize:x-small"},
{"tag": "div", "style": {"fontSize": "small"}, "content": "fontSize:small"},
{"tag": "div", "style": {"fontSize": "medium"}, "content": "fontSize:medium"},
{"tag": "div", "style": {"fontSize": "large"}, "content": "fontSize:large"},
{"tag": "div", "style": {"fontSize": "x-large"}, "content": "fontSize:x-large"},
{"tag": "div", "style": {"fontSize": "xx-large"}, "content": "fontSize:xx-large"},
{"tag": "div", "style": {"fontSize": "xxx-large"}, "content": "fontSize:xxx-large"},
{"tag": "div", "style": {"textDecorationLine": "none"}, "content": "textDecorationLine:none "},
{"tag": "div", "style": {"textDecorationLine": "underline"}, "content": "textDecorationLine:underline "},
{"tag": "div", "style": {"textDecorationLine": "overline"}, "content": "textDecorationLine:overline "},
{"tag": "div", "style": {"textDecorationLine": "line-through"}, "content": "textDecorationLine:line-through "},
{"tag": "div", "style": {"textDecorationLine": ["underline", "overline", "line-through"]}, "content": "textDecorationLine:[underline,overline,line-through] "},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "baseline"}, "content": "verticalAlign:baseline "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "sub"}, "content": "verticalAlign:sub "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "super"}, "content": "verticalAlign:super "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "text-top"}, "content": "verticalAlign:text-top "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "text-bottom"}, "content": "verticalAlign:text-bottom "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "middle"}, "content": "verticalAlign:middle "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "top"}, "content": "verticalAlign:top "}]},
{"tag": "div", "content": ["baseline ", {"tag": "span", "style": {"verticalAlign": "bottom"}, "content": "verticalAlign:bottom "}]}
]},
{"type": "structured-content", "content": [
"br",
{"tag": "br"},
"br"
]},
{"type": "structured-content", "content": [
{"tag": "table", "content": [
{"tag": "thead", "content": [
{"tag": "tr", "content": [
{"tag": "th", "content": "Header 1"},
{"tag": "th", "content": "Header 2"},
{"tag": "th", "content": "Header 3"},
{"tag": "th", "content": "Header 4"}
]}
]},
{"tag": "tbody", "content": [
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A1"},
{"tag": "td", "content": "Cell B1"},
{"tag": "td", "content": "Cell C1"},
{"tag": "td", "content": "Cell D1"}
]},
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A2"},
{"tag": "td", "content": "Cell B2"},
{"tag": "td", "content": "Cell C2:D2", "colSpan": 2}
]},
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A3"},
{"tag": "td", "content": "Cell B3\nCell B4", "rowSpan": 2},
{"tag": "td", "content": "Cell C3:D3\nCell C4:D4", "rowSpan": 2, "colSpan": 2}
]},
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A4"}
]}
]},
{"tag": "tfoot", "content": [
{"tag": "tr", "content": [
{"tag": "th", "content": "Footer 1"},
{"tag": "th", "content": "Footer 2"},
{"tag": "th", "content": "Footer 3"},
{"tag": "th", "content": "Footer 4"}
]}
]}
]}
]},
{"type": "structured-content", "content": [
"margin",
{
"tag": "div",
"style": {
"marginTop": 1,
"marginLeft": 1,
"marginRight": 1,
"marginBottom": 1
},
"content": [
"inner"
]
},
"margin"
]},
{"type": "structured-content", "content": [
"text 1 ",
{
"tag": "span",
"data": {
"": "empty",
"a": "b",
"c": "d"
},
"content": [
"text 2"
]
},
" text 3"
]},
{"type": "structured-content", "content": [
{
"tag": "a",
"href": "?",
"content": [
"internal link 1"
]
},
" ",
{
"tag": "a",
"href": "?query=よみ&wildcards=off",
"content": [
"internal link 2"
]
},
" ",
{
"tag": "a",
"href": "https://foosoft.net/projects/yomichan/",
"content": [
"external link"
]
}
]},
{"type": "structured-content", "content": [
{"tag": "ul", "content": [
{"tag": "li", "content": "Unordered list item 1"},
{"tag": "li", "content": "Unordered list item 2"},
{"tag": "li", "content": "Unordered list item 3"}
]}
]},
{"type": "structured-content", "content": [
{"tag": "ol", "content": [
{"tag": "li", "content": "Ordered list item 1"},
{"tag": "li", "content": "Ordered list item 2"},
{"tag": "li", "content": "Ordered list item 3"}
]}
]},
{"type": "structured-content", "content": [
{"tag": "ol", "style": {"listStyleType": "hiragana-iroha"}, "content": [
{"tag": "li", "content": "List item i"},
{"tag": "li", "content": "List item ro"},
{"tag": "li", "content": "List item ha"}
]}
]},
{"type": "structured-content", "content": [
{"tag": "ul", "content": [
{"tag": "li", "style": {"listStyleType": "'⇄'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["Antonym"]}, "】"]},
{"tag": "li", "style": {"listStyleType": "'🔄'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["References and is referenced by"]}, "】"]},
{"tag": "li", "style": {"listStyleType": "'➡'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["References"]}, "】"]},
{"tag": "li", "style": {"listStyleType": "'⬅'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["Referenced by"]}, "】"]}
]}
]},
{"type": "structured-content", "content": [
{"tag": "ol", "content": [
{"tag": "li", "style": {"listStyleType": "'①'"}, "content": "まるいち"},
{"tag": "li", "style": {"listStyleType": "'②'"}, "content": "まるに"},
{"tag": "li", "style": {"listStyleType": "'③'"}, "content": "まるさん"},
{"tag": "li", "style": {"listStyleType": "'④'"}, "content": "まるよん"}
]}
]},
{"type": "structured-content", "content": [
{"tag": "div", "style": {"fontSize": "xxx-large"}, "content": "直次茶冷 (auto lang)"},
{"tag": "div", "lang": "?????", "style": {"fontSize": "xxx-large"}, "content": "直次茶冷 (invalid lang)"},
{"tag": "div", "lang": "ja-JP", "style": {"fontSize": "xxx-large"}, "content": "直次茶冷 (lang=ja-JP)"},
{"tag": "div", "lang": "zh-CN", "style": {"fontSize": "xxx-large"}, "content": "直次茶冷 (lang=zh-CN)"},
{"tag": "div", "lang": "zh-TW", "style": {"fontSize": "xxx-large"}, "content": "直次茶冷 (lang=zh-TW)"}
]},
{"type": "structured-content", "content": [
{"tag": "ul", "style": {"listStyleType": "japanese-formal"}, "content": [
{"tag": "li", "content": ["【", {"tag": "a", "href": "?query=直次茶冷&wildcards=off", "content": "直次茶冷"}, "】(default)"]},
{"tag": "li", "content": ["【", {"tag": "a", "href": "?query=直次茶冷&wildcards=off", "content": "直次茶冷", "lang": "ja"}, "】(lang=ja)"]},
{"tag": "li", "content": ["【", {"tag": "a", "href": "?query=直次茶冷&wildcards=off", "content": "直次茶冷", "lang": "zh-CN"}, "】(lang=zh-CN)"]},
{"tag": "li", "content": ["【", {"tag": "a", "href": "?query=直次茶冷&wildcards=off", "content": "直次茶冷", "lang": "zh-TW"}, "】(lang=zh-TW)"]}
]}
]},
{"type": "structured-content", "content": [
{"tag": "table", "lang": "", "content": [
{"tag": "thead", "content": [
{"tag": "tr", "content": [
{"tag": "th", "content": "JP"},
{"tag": "th", "content": "SC"},
{"tag": "th", "content": "TC"},
{"tag": "th", "content": "??"}
]}
]},
{"tag": "tbody", "content": [
{"tag": "tr", "content": [
{"tag": "td", "lang": "ja-JP", "content": "直次茶冷"},
{"tag": "td", "lang": "zh-CN", "content": "直次茶冷"},
{"tag": "td", "lang": "zh-TW", "content": "直次茶冷"},
{"tag": "td", "content": "直次茶冷"}
]}
]}
]}
]},
{"type": "structured-content", "content": [
{"tag": "table", "lang": "ja", "content": [
{"tag": "thead", "content": [
{"tag": "tr", "content": [
{"tag": "th", "content": "lang=ja applied to whole table"}
]}
]},
{"tag": "tbody", "content": [
{"tag": "tr", "content": [
{"tag": "td", "content": "直次茶冷"}
]}
]}
]}
]},
{"type": "structured-content", "content": [
{"tag": "table", "lang": "zh-CN", "content": [
{"tag": "thead", "content": [
{"tag": "tr", "content": [
{"tag": "th", "content": "lang=zh-CN applied to whole table"}
]}
]},
{"tag": "tbody", "content": [
{"tag": "tr", "content": [
{"tag": "td", "content": "直次茶冷"}
]}
]}
]}
]}
],
100, "P E1"
]
]