egatari 0.6.5-rc.1 → 0.6.5-rc.2
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/README.ja.md +3 -1
- package/README.md +3 -1
- package/SECURITY.md +18 -0
- package/kit/browser.mjs +14 -2
- package/kit/check.mjs +6 -2
- package/kit/core/article-messages.mjs +4 -0
- package/kit/core/article-text.mjs +62 -4
- package/kit/core/article.mjs +2 -1
- package/package.json +1 -1
- package/tools/ids.mjs +3 -0
package/README.ja.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- i18n: pair=README.md sha256=
|
|
1
|
+
<!-- i18n: pair=README.md sha256=cbaea18bc64491f1 -->
|
|
2
2
|
<p align="center">
|
|
3
3
|
<picture>
|
|
4
4
|
<source media="(prefers-color-scheme: dark)" srcset="assets/logo/egatari-dark.svg">
|
|
@@ -128,6 +128,8 @@ npx egatari check mytalk/deck.html # 最後の行が「エラー 0」にな
|
|
|
128
128
|
npx egatari doctor # Node・uv・ffmpeg・ブラウザがあるか、ないものの入れ方
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
+
Bun(`bunx egatari`)でも動きます。
|
|
132
|
+
|
|
131
133
|
ほかのコマンド(`ids`・`sheet`・`comment-shots`・`portable`・`video`・`tts`)は `npx egatari --help` に出る。`npx egatari video <作業フォルダ | .ega.html>` は組んでから、今ある音声のまま動画にする(ffmpeg が要る)。相対パスは今いるフォルダから解く。組み立てが埋め込む字は包みに入っている(`get-fonts` は要らない)。`egatari tts` は uv で `tts/synth.py` を動かし、Python の環境を利用者のキャッシュのフォルダに作る(別の場所にするには `UV_PROJECT_ENVIRONMENT`)。
|
|
132
134
|
|
|
133
135
|
## ブラウザで直す(開発サーバー)
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- i18n: pair=README.ja.md sha256=
|
|
1
|
+
<!-- i18n: pair=README.ja.md sha256=a16a3451d9082807 -->
|
|
2
2
|
<p align="center">
|
|
3
3
|
<picture>
|
|
4
4
|
<source media="(prefers-color-scheme: dark)" srcset="assets/logo/egatari-dark.svg">
|
|
@@ -128,6 +128,8 @@ npx egatari check mytalk/deck.html # the last line should read "エラー 0"
|
|
|
128
128
|
npx egatari doctor # Node, uv, ffmpeg and a browser: what is there and how to install what is missing
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
+
Also runs with Bun (`bunx egatari`).
|
|
132
|
+
|
|
131
133
|
`npx egatari --help` lists the other commands (`ids`, `sheet`, `comment-shots`, `portable`, `video`, `tts`). `npx egatari video <working folder | .ega.html>` builds and exports a lesson with its existing audio to video (needs ffmpeg). Relative paths are resolved from the current folder. The package carries the fonts the build embeds (no `get-fonts`). `egatari tts` runs `tts/synth.py` with uv and keeps its Python environment in your cache folder (set `UV_PROJECT_ENVIRONMENT` to put it elsewhere).
|
|
132
134
|
|
|
133
135
|
## Editing in the browser (dev server)
|
package/SECURITY.md
CHANGED
|
@@ -43,6 +43,24 @@ Use a Node.js release that includes the latest security fixes. The floor is the
|
|
|
43
43
|
- `package.json` `engines` is `^22.23.4 || ^24.22.1 || >=26.12.1` (npm warns on an older Node; it does not refuse).
|
|
44
44
|
- CI asks `actions/setup-node` for a range, not a bare major (`'>=22.23.4 <23'`, and `'>=24.22.1 <25'` for the Node 24 job). With a bare `22` the action takes whatever 22.x the runner image has cached, which lags behind: the Linux jobs of 2026-10-24 ran 22.23.3 and 24.21.0. With the range an older cached copy does not match, and the action downloads a patched one.
|
|
45
45
|
|
|
46
|
+
## Book text and markdown-it 13 (until v0.6.6)
|
|
47
|
+
|
|
48
|
+
The book text (`article.md`, `article/`; format spec §9C) of a lesson or Egatari file you open is untrusted input, in the CLI (`kit/build.mjs`, `kit/check.mjs`, `npm run ids`) and in the editor app alike: a file someone sends you can carry it. It is read by myst-parser 1.7.4, which runs markdown-it 13.0.2 with `html: true`, smartquotes (`typographer`) on and `linkify` off. markdown-it 13.0.2 has five advisories (fixed in 14.3.3); three of them are reachable this way and take quadratic time (a 1 MiB paragraph of quotation marks took about a minute):
|
|
49
|
+
|
|
50
|
+
- GHSA-r7fv-28h4-cvq7 (high) and GHSA-6v5v-wf23-fmfq: smartquotes. GHSA-vfgh-jcmw-g37q: inline HTML (`<!--`, `<?`, `<!A`, `<![CDATA[`).
|
|
51
|
+
- GHSA-38c4-r59v-3vqw and GHSA-253c-mchw-3w2r need `linkify`, which is off: not reachable.
|
|
52
|
+
|
|
53
|
+
**The guard** (`kit/core/article-text.mjs`, `ARTICLE_LIMITS`): each book file is at most 1 MiB, and before a file is parsed, every paragraph (markdown-it's inline blocks: paragraphs, headings, table cells, the arguments and body of directives; code blocks do not count) is counted. A paragraph with more than 512 quotation marks (`"` and `'`) or more than 64 tag openings (`<!`, `<?`) makes the check refuse the book (`articleUnsafeParagraph`, naming the section, the paragraph and its line), and myst-parser never sees that file. Below the limits the parse is unchanged. With the guard, the worst 1 MiB file for these advisories parses in about 0.15 s, as with 14.3.3.
|
|
54
|
+
|
|
55
|
+
**Why not 14.3.3 now.** No released myst-parser, markdown-it-dollarmath or myst-to-html allows markdown-it 14, and forcing it with `overrides` breaks them (they import `markdown-it/lib/common/utils.js`, which 14 does not have). `overrides` would also not reach `npm install egatari`, which resolves myst-parser's own `^13.0.0`. v0.6.6 bundles the book tools with markdown-it 14.3.3 for the CLI as the editor already bundles them; until then `.github/workflows/audit.yml` lists exactly these five advisories as exceptions (`tools/audit-check.mjs`: any other advisory at high or above still fails, and the list fails the job once the version reaches 0.6.6).
|
|
56
|
+
|
|
57
|
+
**If you installed `egatari` from npm.** `npm audit` in your project reports these five advisories for markdown-it 13.0.2, which comes with myst-parser. In plain terms:
|
|
58
|
+
|
|
59
|
+
- What is at risk: only the tools that read a book (`egatari build`, `egatari check`, `egatari ids`, `egatari portable pack`, and the editor app when it opens a lesson with a book). A book written to be slow, in a lesson or Egatari file someone sends you, could keep the process or the page busy for a minute or more. It cannot run code or read your files.
|
|
60
|
+
- Playing is not affected. Egatari Viewer and the player inside an Egatari file contain neither myst-parser nor markdown-it (the book is already HTML when it is played), so learners and participants are not exposed.
|
|
61
|
+
- The guard above refuses such a book with a message that names the section, the paragraph and its line. Ordinary books are read exactly as before.
|
|
62
|
+
- Do not run `npm audit fix --force` or add an `overrides` entry for markdown-it 14 in your project: in 0.6.5 that breaks the book tools. Update to v0.6.6, which bundles the book tools with markdown-it 14.3.3; after that `npm audit` no longer reports them.
|
|
63
|
+
|
|
46
64
|
## Dependency updates (cooldown)
|
|
47
65
|
|
|
48
66
|
Dependabot (`.github/dependabot.yml`) proposes a new npm release only after it has been public for 7 days (14 days for a major version), and a new action release after 7 days. This gives a hijacked release (like the npm worms and `preinstall` payloads of 2025-2026) time to be found and unpublished before it reaches a pull request here. Security updates are not delayed: Dependabot does not apply the cooldown to them. A human still reads every update.
|
package/kit/browser.mjs
CHANGED
|
@@ -9,8 +9,20 @@ import { chromium } from 'playwright-core';
|
|
|
9
9
|
|
|
10
10
|
export async function launch(opts = {}) {
|
|
11
11
|
// 試験が shareBrowser() で起動した 1 つのブラウザがあれば、起動せずにつなぐ(引数のない launch() だけ。close はつなぎを切るだけで、ページは新しい context に入る)
|
|
12
|
-
if (process.env[SHARED_WS] && !Object.keys(opts).length) return chromium.connect(process.env[SHARED_WS]);
|
|
13
|
-
return (await launchWhich(opts)).browser;
|
|
12
|
+
if (process.env[SHARED_WS] && !Object.keys(opts).length) return scaleDefaults(await chromium.connect(process.env[SHARED_WS]));
|
|
13
|
+
return scaleDefaults((await launchWhich(opts)).browser);
|
|
14
|
+
}
|
|
15
|
+
// 試験の待ちの上限を伸ばす(TEST_TIMEOUT_SCALE。tools/wait-scale.mjs と同じ値で、遅い CI の runner 向け):Playwright の既定の 30 秒
|
|
16
|
+
// (click・fill・waitForSelector・goto)に掛ける。値がなければ(試験のほか)何もしない
|
|
17
|
+
export function scaleDefaults(browser) {
|
|
18
|
+
const s = Number(process.env.TEST_TIMEOUT_SCALE);
|
|
19
|
+
if (!(s > 1)) return browser;
|
|
20
|
+
const ms = Math.round(30000 * s);
|
|
21
|
+
const set = (x) => { x.setDefaultTimeout(ms); x.setDefaultNavigationTimeout(ms); return x; };
|
|
22
|
+
const newContext = browser.newContext.bind(browser), newPage = browser.newPage.bind(browser);
|
|
23
|
+
browser.newContext = async (...a) => set(await newContext(...a));
|
|
24
|
+
browser.newPage = async (...a) => set(await newPage(...a));
|
|
25
|
+
return browser;
|
|
14
26
|
}
|
|
15
27
|
// launch と同じ順で探し、どれで起動したかも返す:{browser, via}(via は 'CHROME_PATH' | 'chrome' | 'msedge' | 'chromium'。egatari doctor)
|
|
16
28
|
export async function launchWhich(opts = {}) {
|
package/kit/check.mjs
CHANGED
|
@@ -535,7 +535,9 @@ for (const seg of built.segs) {
|
|
|
535
535
|
// ================================================================ C. パレットのコントラスト
|
|
536
536
|
phase = 'C パレット';
|
|
537
537
|
// oklch() や color-mix() は getComputedStyle だけでは rgb に落ちないことがあるので、
|
|
538
|
-
// 一度 1x1 の canvas に塗って画素として読み、実際に表示される sRGB
|
|
538
|
+
// 一度 1x1 の canvas に塗って画素として読み、実際に表示される sRGB 値を得る。rgb()・rgba() はそのまま数を読む(canvas を通しても同じ値):
|
|
539
|
+
// 込み合った macOS の CI で、どの組も 1.00:1 の contrastLow になったことがある(canvas の読み戻しがどの色も 0,0,0 を返せばそうなる)
|
|
540
|
+
// (canvas は willReadFrequently で CPU に置く。kit/core/layout-scan.mjs・kit/tools.js と同じ)
|
|
539
541
|
const palette = await page.evaluate(() => {
|
|
540
542
|
const vars = ['--fg', '--term', '--emph', '--muted', '--title', '--accent2', '--bg'];
|
|
541
543
|
const probe = document.createElement('div');
|
|
@@ -543,11 +545,13 @@ const palette = await page.evaluate(() => {
|
|
|
543
545
|
document.body.appendChild(probe);
|
|
544
546
|
const canvas = document.createElement('canvas');
|
|
545
547
|
canvas.width = 1; canvas.height = 1;
|
|
546
|
-
const ctx = canvas.getContext('2d');
|
|
548
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
547
549
|
const out = {};
|
|
548
550
|
for (const v of vars) {
|
|
549
551
|
probe.style.color = `var(${v})`;
|
|
550
552
|
const css = getComputedStyle(probe).color;
|
|
553
|
+
const m = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/.exec(css);
|
|
554
|
+
if (m) { out[v] = { css, rgb: [m[1], m[2], m[3]].map((x) => Math.round(+x)) }; continue; }
|
|
551
555
|
ctx.clearRect(0, 0, 1, 1);
|
|
552
556
|
ctx.fillStyle = css;
|
|
553
557
|
ctx.fillRect(0, 0, 1, 1);
|
|
@@ -71,6 +71,10 @@ export const ARTICLE_MESSAGES = {
|
|
|
71
71
|
articleConfig: { ja: (a) => `egatari.json の article(本文のファイルと読む順)${{ shape: 'が object でない', path: `の path(${a.path})が article.md でない`, chapters: 'の chapters が article/<名前>.md の重ならない並びでない', missing: `のファイル ${a.path} が作業フォルダにない`, unreadable: 'が読めない(egatari.json が JSON でない)' }[a.why]}:直すか、article の項目を消す(読む順は種類とファイルの名前の順になる)`, en: (a) => `egatari.json article (the book's files and reading order): ${{ shape: 'not an object', path: `path (${a.path}) is not article.md`, chapters: 'chapters is not a list of distinct article/<name>.md paths', missing: `${a.path} is not in the working folder`, unreadable: 'unreadable (egatari.json is not JSON)' }[a.why]}; fix it or remove the article member (the order then follows kind and file name)` },
|
|
72
72
|
articleUnlisted: { ja: () => '本文のファイルが egatari.json の article に載っていない(本に入らない):chapters に足すか、ファイルを外す', en: () => 'this article file is not listed in egatari.json article (it is not part of the book): add it to chapters or move the file' },
|
|
73
73
|
articleRead: { ja: (a) => `本文のファイルが読めない:${a.why}`, en: (a) => `cannot read the article file: ${a.why}` },
|
|
74
|
+
articleUnsafeParagraph: {
|
|
75
|
+
ja: (a) => `${a.heading ? `節${quoteJa(a.heading)}の` : ''}段落${quoteJa(a.text + '…')}に${a.what === 'html' ? 'タグの書き出し(<! と <?)' : '引用符(" と \')'}が ${a.count} 個ある。1 つの段落に ${a.max} 個を越えると安全に読めないので、本を読み込まない:段落を分けるか、${a.what === 'html' ? 'タグ' : '引用符'}を減らす`,
|
|
76
|
+
en: (a) => `the paragraph “${a.text}…”${a.heading ? ` in the section “${a.heading}”` : ''} has ${a.count} ${a.what === 'html' ? 'tag openings (<! and <?)' : 'quotation marks (" and \')'}. More than ${a.max} in one paragraph cannot be read safely, so the book is not read: split the paragraph or use fewer ${a.what === 'html' ? 'tags' : 'quotation marks'}`,
|
|
77
|
+
},
|
|
74
78
|
articleTooLarge: { ja: (a) => `本文のファイルが大きすぎる(${a.bytes} 字、${a.max} まで):章に分ける`, en: (a) => `the article file is too large (${a.bytes} characters, up to ${a.max}): split it into chapters` },
|
|
75
79
|
articleChapterNumber: { ja: () => '章のファイルに chapter(章の番号)がない:前付けに chapter: 番号 を書く', en: () => 'a chapter file has no chapter number: add chapter: <n> to its front matter' },
|
|
76
80
|
articleChapterTitle: { ja: () => '章のファイルに title(章の題)がない:前付けに title: 題 を書く', en: () => 'a chapter file has no title: add title: <title> to its front matter' },
|
|
@@ -8,15 +8,21 @@
|
|
|
8
8
|
// 版(package.json で固定):myst-parser 1.7.4・myst-transforms 1.3.51・myst-ext-proof 1.0.13・myst-ext-exercise 1.0.10・vfile 6.0.3。
|
|
9
9
|
// 仕様の正解の木は myst-parser 1.7.5 / myst-transforms 1.3.52 で作ったが、その 2 つは公開から 2 週間たっていない(2026-10-26)。
|
|
10
10
|
// 1 つ前の版(2026-09-21)で 49 の正解の木がすべて同じになることを確かめて、こちらに固定する(tools/test-article.mjs が毎回確かめる)。
|
|
11
|
-
// markdown-it は 13 のまま(14 は markdown-it-dollarmath
|
|
12
|
-
//
|
|
13
|
-
|
|
11
|
+
// markdown-it は 13 のまま(14 は markdown-it-dollarmath と myst-to-html が読めない:markdown-it/lib/common/utils.js が 14 にない)。
|
|
12
|
+
// myst-parser の既定では html と typographer(smartquotes)が入り、linkify は切れている。13 には 2 乗の時間がかかる書き方がある
|
|
13
|
+
// (smartquotes:GHSA-r7fv-28h4-cvq7・GHSA-6v5v-wf23-fmfq、行内の HTML の「<!」「<?」:GHSA-vfgh-jcmw-g37q)。開いたファイルの本文は
|
|
14
|
+
// 信用できない入力なので、読む大きさを ARTICLE_LIMITS.fileBytes までにし、1 つの段落の引用符(" と ')と「<!」「<?」の数を
|
|
15
|
+
// ARTICLE_LIMITS.paragraphQuotes・paragraphHtmlStarts までにする(越えたら myst-parser に渡さずに断る。articleUnsafeParagraph)。
|
|
16
|
+
// v0.6.6 で本の道具を markdown-it 14.3.3 といっしょに 1 本にまとめたら、この限りは外せる(.github/workflows/audit.yml の例外も)。
|
|
17
|
+
import { mystParse, createTokenizer } from 'myst-parser';
|
|
14
18
|
import { proofDirective } from 'myst-ext-proof';
|
|
15
19
|
import { exerciseDirectives } from 'myst-ext-exercise';
|
|
16
20
|
import { liftMystDirectivesAndRolesTransform, mystTargetsTransform, reconstructHtmlTransform, htmlTransform, containerChildrenTransform, captionParagraphTransform } from 'myst-transforms';
|
|
17
21
|
import { VFile } from 'vfile';
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
// fileBytes:1 ファイル 1 MiB まで(本の 1 章には十分)。paragraphQuotes・paragraphHtmlStarts:1 つの段落(markdown-it の行内の塊:段落・見出し・
|
|
24
|
+
// 表の欄など。コードブロックは数えない)の " と ' の数、「<!」「<?」の数の上限。最も悪い 1 MiB でも 13.0.2 で 0.15 秒ほどに収まる値
|
|
25
|
+
export const ARTICLE_LIMITS = Object.freeze({ fileBytes: 1 << 20, paragraphQuotes: 512, paragraphHtmlStarts: 64 });
|
|
20
26
|
|
|
21
27
|
// §9C.2 の定理の類(mystmd の proof 拡張の種類)
|
|
22
28
|
export const PROOF_KINDS = Object.freeze(['theorem', 'lemma', 'proposition', 'corollary', 'definition', 'example', 'remark', 'proof', 'axiom', 'assumption', 'conjecture', 'criterion', 'property', 'observation', 'algorithm']);
|
|
@@ -172,6 +178,52 @@ function keepIdeographicSpaces(tree) {
|
|
|
172
178
|
return tree;
|
|
173
179
|
}
|
|
174
180
|
|
|
181
|
+
// ---------------------------------------------------------------- 2 乗の時間がかかる段落(markdown-it 13 の smartquotes と行内の HTML)
|
|
182
|
+
// 1 つの段落の " と ' の数、「<!」「<?」の数を数える。速い道:空行で区切った行の並びごとに数える(markdown-it の行内の塊は空行をまたがないので、
|
|
183
|
+
// これが上限になる)。越える並びがあるときだけ、markdown-it のブロックの読み(線形)で行内の塊を出して数え直す(コードブロックは数えない。
|
|
184
|
+
// 指令の中身はあとで myst-parser が読み直すので、中身も同じように数える)。返すもの:越えた最初の段落 {what, count, max, line, heading, text} か null
|
|
185
|
+
const QUOTE_RE = /["']/g;
|
|
186
|
+
const HTML_START_RE = /<[!?]/g;
|
|
187
|
+
const countOf = (s, re) => { let n = 0; re.lastIndex = 0; while (re.exec(s)) n++; return n; };
|
|
188
|
+
const overLimit = (s) => {
|
|
189
|
+
const q = countOf(s, QUOTE_RE);
|
|
190
|
+
if (q > ARTICLE_LIMITS.paragraphQuotes) return { what: 'quotes', count: q, max: ARTICLE_LIMITS.paragraphQuotes };
|
|
191
|
+
const h = countOf(s, HTML_START_RE);
|
|
192
|
+
if (h > ARTICLE_LIMITS.paragraphHtmlStarts) return { what: 'html', count: h, max: ARTICLE_LIMITS.paragraphHtmlStarts };
|
|
193
|
+
return null;
|
|
194
|
+
};
|
|
195
|
+
let blockTokenizer = null;
|
|
196
|
+
function unsafeParagraph(body) {
|
|
197
|
+
let fast = false, run = '';
|
|
198
|
+
for (const ln of (body + '\n').split('\n')) {
|
|
199
|
+
if (/^[ \t]*$/.test(ln)) { if (run && overLimit(run)) { fast = true; break; } run = ''; } else run += ln + '\n';
|
|
200
|
+
}
|
|
201
|
+
if (!fast) return null;
|
|
202
|
+
blockTokenizer ||= createTokenizer({});
|
|
203
|
+
return unsafeIn(body, 0, '');
|
|
204
|
+
}
|
|
205
|
+
function unsafeIn(src, base, heading0) {
|
|
206
|
+
const tokens = [];
|
|
207
|
+
blockTokenizer.block.parse(src.replace(/\0/g, '\uFFFD'), blockTokenizer, {}, tokens);
|
|
208
|
+
let heading = heading0;
|
|
209
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
210
|
+
const t = tokens[i];
|
|
211
|
+
const line = base + (t.map ? t.map[0] : 0) + 1;
|
|
212
|
+
if (t.type === 'inline') {
|
|
213
|
+
if (tokens[i - 1] && tokens[i - 1].type === 'heading_open') heading = t.content.trim();
|
|
214
|
+
const o = overLimit(t.content);
|
|
215
|
+
if (o) return { ...o, line, heading: heading.slice(0, 40), text: t.content.trim().replace(/\s+/g, ' ').slice(0, 20) };
|
|
216
|
+
} else if (/fence$/.test(t.type) && /^\s*\{/.test(t.info || '')) {
|
|
217
|
+
// 指令(:::{…}・```{…}):引数の行と中身を数える(中身はあとで myst-parser が読み直す)
|
|
218
|
+
const o = overLimit(t.info || '');
|
|
219
|
+
if (o) return { ...o, line, heading: heading.slice(0, 40), text: String(t.info).trim().replace(/\s+/g, ' ').slice(0, 20) };
|
|
220
|
+
const inner = unsafeIn(t.content || '', line, heading);
|
|
221
|
+
if (inner) return inner;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
175
227
|
// ---------------------------------------------------------------- 本体
|
|
176
228
|
// 返すもの:{fm, tree, problems, conversions}。problems は {sev: 'error'|'warn', code, spec, line, data}(line は原稿の行、1 から)
|
|
177
229
|
export function parseArticleText(src, opts = {}) {
|
|
@@ -186,6 +238,12 @@ export function parseArticleText(src, opts = {}) {
|
|
|
186
238
|
const lines = front.body.split('\n');
|
|
187
239
|
const lineOf = (n) => (n && n.position ? n.position.start.line + off : null);
|
|
188
240
|
const add = (sev, code, spec, node, data = {}) => problems.push(P(sev, code, spec, typeof node === 'number' ? node : lineOf(node), data));
|
|
241
|
+
// 2 乗の時間がかかる段落があれば、myst-parser に渡さずに断る(上の markdown-it 13 の説明)
|
|
242
|
+
const unsafe = unsafeParagraph(front.body);
|
|
243
|
+
if (unsafe) {
|
|
244
|
+
problems.push(P('error', 'articleUnsafeParagraph', null, unsafe.line + off, { what: unsafe.what, count: unsafe.count, max: unsafe.max, heading: unsafe.heading, text: unsafe.text }));
|
|
245
|
+
return { fm: front.fm, tree: { type: 'root', children: [] }, problems, conversions, lineOffset: off };
|
|
246
|
+
}
|
|
189
247
|
const tree = keepIdeographicSpaces(mystParse(protectIdeographicSpaces(front.body), { directives: [proofDirective, ...exerciseDirectives] }));
|
|
190
248
|
|
|
191
249
|
// ---- 変換の前の木:指令・役割・生の HTML・コメント・区切り・字
|
package/kit/core/article.mjs
CHANGED
|
@@ -262,5 +262,6 @@ export function assignSectionIds(text, taken = new Set(), rand = (n) => globalTh
|
|
|
262
262
|
}
|
|
263
263
|
// 下から足す(行の番号がずれないように)
|
|
264
264
|
for (const a of [...added].reverse()) lines.splice(a.line - 1, 0, `(${a.id})=`);
|
|
265
|
-
|
|
265
|
+
// unsafe:2 乗の時間がかかる段落で読まなかったとき、その指摘(articleUnsafeParagraph。kit/core/article-text.mjs)。そのときは何も足さない
|
|
266
|
+
return { out: added.length ? lines.join(eol) : text, added, unsafe: r.problems.find((p) => p.code === 'articleUnsafeParagraph') || null };
|
|
266
267
|
}
|
package/package.json
CHANGED
package/tools/ids.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import { articleLayout, articleFiles, assignSectionIds, readArticle } from '../k
|
|
|
28
28
|
import { configObject, updateConfig } from '../kit/core/config-file.mjs';
|
|
29
29
|
import { FORMAT } from '../kit/core/format.mjs';
|
|
30
30
|
import { ARTICLE_LIMITS } from '../kit/core/article-text.mjs';
|
|
31
|
+
import { articleMessage } from '../kit/core/article-messages.mjs';
|
|
31
32
|
|
|
32
33
|
const USAGE = 'usage: npm run ids -- <working folder | deck.html> [--dry-run] [--confirm-links]';
|
|
33
34
|
const KEEP_EDITS = 30;
|
|
@@ -89,6 +90,8 @@ const articleWrites = [], articleSummary = [];
|
|
|
89
90
|
const text = rd(file);
|
|
90
91
|
if (text === null) continue;
|
|
91
92
|
const r = assignSectionIds(text, taken);
|
|
93
|
+
// 安全に読めない段落(kit/core/article-text.mjs):本を読まずに、何も書かないうちに断る(節の id も、つながりの記録も変えない)
|
|
94
|
+
if (r.unsafe) fail(`${articleMessage('ja', { ...r.unsafe, file: rel })}(何も書いていない)\n ${articleMessage('en', { ...r.unsafe, file: rel })} (nothing written)`);
|
|
92
95
|
for (const a of r.added) { taken.add(a.id); articleSummary.push(` ${rel}:${a.line} ${a.id} ← ## ${a.heading}`); }
|
|
93
96
|
if (r.added.length) articleWrites.push([file, r.out, rel, r.added.length]);
|
|
94
97
|
}
|