egatari 0.6.17 → 0.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -1
- package/README.ja.md +14 -13
- package/README.md +2 -1
- package/components.lock.json +153 -54
- package/components2.lock.json +1001 -1
- package/kit/build.mjs +1 -1
- package/kit/check-messages.mjs +9 -0
- package/kit/check.mjs +8 -0
- package/kit/core/bookmark.mjs +28 -0
- package/kit/core/build-core.mjs +5 -3
- package/kit/core/check-parity.mjs +6 -0
- package/kit/core/check-rules.mjs +4 -3
- package/kit/core/check-source.mjs +10 -1
- package/kit/core/checks.mjs +79 -0
- package/kit/core/find-replace.mjs +170 -0
- package/kit/core/format.mjs +4 -1
- package/kit/core/image-insert.mjs +197 -0
- package/kit/core/image-size.mjs +1 -1
- package/kit/core/layout-scan.mjs +1 -1
- package/kit/core/llm-fix.mjs +1 -1
- package/kit/core/llm-pack-assemble.mjs +40 -67
- package/kit/core/llm-pack-data.mjs +882 -52
- package/kit/core/llm-pack.mjs +6 -4
- package/kit/core/llm-request.mjs +2 -2
- package/kit/core/new-deck-pack.mjs +38 -44
- package/kit/core/new-deck.mjs +82 -74
- package/kit/core/part-labels.mjs +3 -0
- package/kit/core/portable.mjs +5 -2
- package/kit/core/purposes.mjs +9 -3
- package/kit/core/sample-info.mjs +17 -3
- package/kit/core/scorm.mjs +30 -6
- package/kit/core/script-unclosed.mjs +49 -0
- package/kit/core/slide-ops.mjs +27 -1
- package/kit/core/tate-mix.mjs +25 -0
- package/kit/core/template-text.mjs +2 -0
- package/kit/core/theme-derive.mjs +56 -17
- package/kit/core/theme-shapes.mjs +15 -1
- package/kit/deck.js +124 -6
- package/kit/instruction-version.json +1 -1
- package/kit/layouts.css +8 -0
- package/kit/llm-pack.mjs +5 -7
- package/kit/panes.js +17 -1
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/kit/presenter.js +36 -4
- package/kit/tools.js +54 -2
- package/kit/track.js +46 -5
- package/package.json +1 -1
- package/server/editor-ui.js +21 -1
- package/vendor/components/CATALOG.md +25 -22
- package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
- package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
- package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
- package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
- package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
- package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
- package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
- package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
- package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
- package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
- package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
- package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
- package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/README.en.md +34 -0
- package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/index.js +398 -0
- package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
- package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
- package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
- package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
- package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
- package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
- package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/README.en.md +23 -0
- package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/index.js +294 -0
- package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
- package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
- package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
- package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
- package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
- package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
- package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
- package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
- package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/README.en.md +47 -0
- package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/index.js +223 -0
- package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
- package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
- package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
- package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
- package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
- package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
- package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
- package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
- package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
- package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
- package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
- package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
- package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
- package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
- package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
- package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
- package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
- package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
- package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
- package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
- package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
- package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
- package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
- package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
- package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/README.en.md +44 -0
- package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/index.js +306 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
- package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
- package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
- package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
- package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
- package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
- package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
- package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
- package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/README.en.md +34 -0
- package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/index.js +397 -0
- package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/README.en.md +44 -0
- package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/index.js +551 -0
- package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
- package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/README.en.md +18 -0
- package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/index.js +382 -0
- package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
- package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
- package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
- package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
- package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
- package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
- package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
- package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
- package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
- package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
- package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
- package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
- package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
- package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
- package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
- package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
- package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
- package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
- package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
- package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
- package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
- package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
- package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
- package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
- package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
- package/vendor/components-2/manifest-2.16.0.json +2919 -0
- package/vendor/components-2/manifest-2.17.0.json +2852 -0
- package/vendor/components-2/manifest-2.18.0.json +3182 -0
- package/vendor/components-2/manifest-2.20.0.json +3217 -0
- package/vendor/components-2/manifest-2.21.0.json +3220 -0
- package/vendor/egatari-spec/SOURCE.json +2 -2
- package/vendor/egatari-spec/schema/deck-meta.schema.json +3 -0
- package/vendor/egatari-spec/schema/egatari-metadata.schema.json +6 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// kanbun-core 1.0.0: reading kanbun (classical Chinese with kunten) for Egatari components 2.0 (a library part, Egatari spec §6.1).
|
|
2
|
+
// m-kanbun requires it ({"kanbun-core": "1.0.0"}) and receives what this factory returns:
|
|
3
|
+
// {parse, order, charEvents, kakikudashi, stepGroups, hira, yomi}
|
|
4
|
+
// parse(文字列) → {chars, cols, warnings} 白文・返り点・送り仮名・振り仮名の読み取り
|
|
5
|
+
// order(chars) → {units, events, warnings} 訓読の順(返り点・再読文字・置き字)
|
|
6
|
+
// charEvents(o) → [{c, kind, ev}] 読んだ順の字ごとの事柄
|
|
7
|
+
// kakikudashi(chars, o) → [[{t, rb}]] 書き下し文の行
|
|
8
|
+
// stepGroups(chars, ce, by) → [{a, b}] 読む順の段階の分け方(by = "col" | "all")
|
|
9
|
+
// hira(s) 片仮名を平仮名に
|
|
10
|
+
// yomi(文字列) → 書き下し文の文字列(行は改行でつなぐ)
|
|
11
|
+
// Pure functions on strings and arrays: no DOM, no import, no network and no global of the player (spec §6.1).
|
|
12
|
+
// The code is m-kanbun 1.13.0's (components/kanbun/index.js, where it was DECK.kanbun), unchanged but for the wrapper;
|
|
13
|
+
// tools/test-kokugo.mjs tests it through the registry.
|
|
14
|
+
egatariParts.define({name: "kanbun-core", version: "1.0.0", requires: {}}, function(){
|
|
15
|
+
"use strict";
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------- 読み取り(文字列 → 字の並び)
|
|
18
|
+
// 返り点の字 → [系列, 順位]。順位 1(一・上・甲・天)を読んだら、同じ系列で順位の大きいものへ戻る
|
|
19
|
+
var SERIES = {"一": ["i", 1], "二": ["i", 2], "三": ["i", 3], "四": ["i", 4], "五": ["i", 5],
|
|
20
|
+
"上": ["j", 1], "中": ["j", 2], "下": ["j", 3], "甲": ["k", 1], "乙": ["k", 2], "丙": ["k", 3], "丁": ["k", 4],
|
|
21
|
+
"天": ["t", 1], "地": ["t", 2], "人": ["t", 3]};
|
|
22
|
+
var OPEN = {"(": ")", "(": ")", "[": "]", "[": "]", "{": "}", "{": "}"};
|
|
23
|
+
var PUNCT = "、。,.!?";
|
|
24
|
+
// parse(文字列) → {chars, cols, warnings}。chars[n] = {ch, col, okuri, second, ruby, kana, oki, re, series, rank, mark, join, punct}
|
|
25
|
+
function parse(src){
|
|
26
|
+
var chars = [], warnings = [], lines = String(src || "").split(/\r?\n/).map(function(l){ return l.trim(); }).filter(Boolean);
|
|
27
|
+
lines.forEach(function(line, col){
|
|
28
|
+
var A = Array.from(line), c = null;
|
|
29
|
+
var need = function(what){ if (!c){ warnings.push(what + " の前に字がない(" + (col + 1) + " 行目)"); return false; } return true; };
|
|
30
|
+
for (var j = 0; j < A.length; j++){
|
|
31
|
+
var ch = A[j];
|
|
32
|
+
if (/\s/.test(ch)) continue;
|
|
33
|
+
if (OPEN[ch]){
|
|
34
|
+
var close = OPEN[ch], body = "", k = j + 1;
|
|
35
|
+
// 閉じ括弧は半角・全角のどちらでもよい
|
|
36
|
+
var alt = {")": ")", ")": ")", "]": "]", "]": "]", "}": "}", "}": "}"}[close];
|
|
37
|
+
while (k < A.length && A[k] !== close && A[k] !== alt){ body += A[k]; k++; }
|
|
38
|
+
if (k >= A.length) warnings.push("「" + ch + "」が閉じていない(" + (col + 1) + " 行目)");
|
|
39
|
+
j = k;
|
|
40
|
+
if (!need(ch + body + close)) continue;
|
|
41
|
+
if (ch === "(" || ch === "("){
|
|
42
|
+
var sp = body.split(/[||]/);
|
|
43
|
+
c.okuri += sp[0];
|
|
44
|
+
if (sp.length > 1) c.second = sp.slice(1).join("");
|
|
45
|
+
} else if (ch === "[" || ch === "["){
|
|
46
|
+
Array.from(body).forEach(function(m){
|
|
47
|
+
if (m === "レ") c.re = true;
|
|
48
|
+
else if (SERIES[m]){ c.series = SERIES[m][0]; c.rank = SERIES[m][1]; c.mark = m; }
|
|
49
|
+
else if (!/\s/.test(m)) warnings.push("返り点ではない「" + m + "」(" + (col + 1) + " 行目「" + c.ch + "」)");
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
if (/^[-−‐ー]$/.test(body)) c.oki = true;
|
|
53
|
+
else if (/^[==]/.test(body)) c.kana = body.slice(1);
|
|
54
|
+
else c.ruby = body;
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (ch === "-" || ch === "‐" || ch === "-"){ if (need(ch)) c.join = true; continue; }
|
|
59
|
+
if (PUNCT.indexOf(ch) >= 0){ if (need(ch)) c.punct += ch; continue; }
|
|
60
|
+
if (ch === "レ"){ if (need(ch)) c.re = true; continue; }
|
|
61
|
+
c = {ch: ch, col: col, okuri: "", second: null, ruby: "", kana: null, oki: false, re: false, series: null, rank: 0, mark: "", join: false, punct: ""};
|
|
62
|
+
chars.push(c);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
chars.forEach(function(c){ if (c.ch === "不" && c.kana === null && !c.oki) warnings.push("「不」は書き下し文で平仮名にする:不{=ず}"); });
|
|
66
|
+
return {chars: chars, cols: lines.length, warnings: warnings};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------- 訓読の順
|
|
70
|
+
// まとまり(竪点でつないだ字)ごとに読む。返り点の規則:
|
|
71
|
+
// レ点:その字を飛ばし、次のまとまりを読んだら戻る(続くレ点は下から順に戻る)
|
|
72
|
+
// 一二点・上中下点・甲乙点・天地人点:順位 2 以上の字を飛ばし、同じ系列の順位 1 を読んだら、順位の小さい順に戻る
|
|
73
|
+
// 一レ・上レ:先にレ点として戻り、読んだら一(上)として二(下)へ戻る
|
|
74
|
+
// 再読文字:出てきたところで一度目を読み、返り点に従って戻ったところで二度目を読む(返り点がなければレ点と同じ)
|
|
75
|
+
// 置き字は読まない。戻るときは、レ点の戻りを先に、系列の戻りを後にする
|
|
76
|
+
// order(chars) → {units, events, warnings}。events[n] = {u(まとまりの番号), kind: "read" | "first" | "second"}
|
|
77
|
+
function order(chars){
|
|
78
|
+
var units = [], warnings = [];
|
|
79
|
+
chars.forEach(function(c, n){
|
|
80
|
+
var last = units[units.length - 1];
|
|
81
|
+
if (last && chars[last.chars[last.chars.length - 1]].join) last.chars.push(n);
|
|
82
|
+
else units.push({chars: [n]});
|
|
83
|
+
});
|
|
84
|
+
units.forEach(function(u){
|
|
85
|
+
var cs = u.chars.map(function(n){ return chars[n]; });
|
|
86
|
+
u.oki = cs.every(function(c){ return c.oki; });
|
|
87
|
+
u.re = cs.some(function(c){ return c.re; });
|
|
88
|
+
var s = cs.filter(function(c){ return c.series; })[0];
|
|
89
|
+
u.series = s ? s.series : null; u.rank = s ? s.rank : 0;
|
|
90
|
+
u.saidoku = cs.some(function(c){ return c.second !== null; });
|
|
91
|
+
});
|
|
92
|
+
var events = [], done = units.map(function(){ return false; }), pendRe = {}, stacks = {};
|
|
93
|
+
function prevOf(x){ for (var y = x - 1; y >= 0; y--) if (!units[y].oki) return y; return -1; }
|
|
94
|
+
function read(x){
|
|
95
|
+
events.push({u: x, kind: units[x].saidoku ? "second" : "read"});
|
|
96
|
+
done[x] = true;
|
|
97
|
+
// レ点:すぐ上のまとまりがレ点で待っていれば戻る
|
|
98
|
+
var p = prevOf(x);
|
|
99
|
+
if (p >= 0 && pendRe[p]){ delete pendRe[p]; read(p); }
|
|
100
|
+
// 一二点など:同じ系列で、待っている順位の大きいものへ戻る
|
|
101
|
+
var u = units[x];
|
|
102
|
+
if (u.series){
|
|
103
|
+
var st = stacks[u.series] || [];
|
|
104
|
+
if (st.length && units[st[st.length - 1]].rank > u.rank) read(st.pop());
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
units.forEach(function(u, x){
|
|
108
|
+
if (u.oki) return;
|
|
109
|
+
var bySeries = u.series && u.rank >= 2;
|
|
110
|
+
if (u.saidoku){
|
|
111
|
+
events.push({u: x, kind: "first"});
|
|
112
|
+
if (!u.re && !bySeries){ pendRe[x] = true; return; } // 返り点のない再読文字:次を読んでから二度目
|
|
113
|
+
}
|
|
114
|
+
if (u.re) pendRe[x] = true;
|
|
115
|
+
if (bySeries) (stacks[u.series] = stacks[u.series] || []).push(x);
|
|
116
|
+
if (!u.re && !bySeries) read(x);
|
|
117
|
+
});
|
|
118
|
+
// 戻り先のないもの:知らせて、下から順に読む
|
|
119
|
+
var left = Object.keys(pendRe).map(Number);
|
|
120
|
+
Object.keys(stacks).forEach(function(s){ left = left.concat(stacks[s]); });
|
|
121
|
+
left.sort(function(a, b){ return b - a; }).forEach(function(x){
|
|
122
|
+
if (done[x]) return;
|
|
123
|
+
warnings.push("返り点の戻り先がない「" + units[x].chars.map(function(n){ return chars[n].ch; }).join("") + "」");
|
|
124
|
+
events.push({u: x, kind: units[x].saidoku ? "second" : "read"}); done[x] = true;
|
|
125
|
+
});
|
|
126
|
+
return {units: units, events: events, warnings: warnings};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ---------------------------------------------------------------- 書き下し文
|
|
130
|
+
function hira(s){
|
|
131
|
+
return String(s || "").replace(/[ァ-ヶ]/g, function(c){ return String.fromCharCode(c.charCodeAt(0) - 0x60); }).replace(/ヽ/g, "ゝ").replace(/ヾ/g, "ゞ");
|
|
132
|
+
}
|
|
133
|
+
// 読んだ順の字ごとの事柄(まとまりは字に分ける):[{c(字の番号), kind}]
|
|
134
|
+
function charEvents(o){
|
|
135
|
+
var out = [];
|
|
136
|
+
o.events.forEach(function(e, n){ o.units[e.u].chars.forEach(function(c){ out.push({c: c, kind: e.kind, ev: n}); }); });
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
// kakikudashi(chars, o) → 行の配列。行 = [{t, rb}](rb は振り仮名)。句読点は、そこまでの字をみな読み終えたところに置き、
|
|
140
|
+
// 列の終わり(その列の字をみな読み終えたところ)で行を改める
|
|
141
|
+
function kakikudashi(chars, o){
|
|
142
|
+
var ce = charEvents(o), fin = chars.map(function(c){ return c.oki; }), lines = [[]], flushed = -1;
|
|
143
|
+
function flush(){
|
|
144
|
+
// 読み終えた字の続き(置き字を含む)の終わりまで、句読点と改行を出す
|
|
145
|
+
var upto = flushed;
|
|
146
|
+
while (upto + 1 < chars.length && fin[upto + 1]) upto++;
|
|
147
|
+
for (var n = flushed + 1; n <= upto; n++){
|
|
148
|
+
if (chars[n].punct) lines[lines.length - 1].push({t: chars[n].punct});
|
|
149
|
+
if (n + 1 < chars.length && chars[n + 1].col !== chars[n].col) lines.push([]);
|
|
150
|
+
}
|
|
151
|
+
flushed = upto;
|
|
152
|
+
}
|
|
153
|
+
flush();
|
|
154
|
+
ce.forEach(function(e){
|
|
155
|
+
var c = chars[e.c], L = lines[lines.length - 1];
|
|
156
|
+
if (e.kind === "second") L.push({t: hira(c.second)});
|
|
157
|
+
else if (c.kana !== null) L.push({t: hira(c.kana + c.okuri)});
|
|
158
|
+
else {
|
|
159
|
+
L.push({t: c.ch, rb: c.ruby || ""});
|
|
160
|
+
if (c.okuri) L.push({t: hira(c.okuri)});
|
|
161
|
+
}
|
|
162
|
+
if (e.kind !== "first"){ fin[e.c] = true; flush(); }
|
|
163
|
+
});
|
|
164
|
+
return lines.filter(function(l){ return l.length; });
|
|
165
|
+
}
|
|
166
|
+
// 読む順の段階の分け方:stepGroups(chars, ce, by) → [{a, b}](字の事柄 ce の範囲 [a, b))。by = "col"(既定)は、字の列が
|
|
167
|
+
// 変わるところで切る(続けて同じ列を読む間が 1 段階。返り点・再読文字で前の列へ戻れば、そこからまた別の段階)。"all" は全体で 1 つ
|
|
168
|
+
function stepGroups(chars, ce, by){
|
|
169
|
+
var groups = [];
|
|
170
|
+
if (String(by).trim() !== "all") ce.forEach(function(ev, m){
|
|
171
|
+
if (!groups.length || chars[ev.c].col !== chars[ce[m - 1].c].col) groups.push({a: m, b: m + 1});
|
|
172
|
+
else groups[groups.length - 1].b = m + 1;
|
|
173
|
+
});
|
|
174
|
+
return groups.length ? groups : [{a: 0, b: ce.length}];
|
|
175
|
+
}
|
|
176
|
+
var plain = function(line){ return line.map(function(s){ return s.t; }).join(""); };
|
|
177
|
+
return {parse: parse, order: order, kakikudashi: kakikudashi, charEvents: charEvents, hira: hira, stepGroups: stepGroups,
|
|
178
|
+
// 文字列から書き下し文の文字列(行は改行でつなぐ)
|
|
179
|
+
yomi: function(src){ var p = parse(src), o = order(p.chars); return kakikudashi(p.chars, o).map(plain).join("\n"); }};
|
|
180
|
+
});
|