1 Commits

Author SHA1 Message Date
傅洋 315a2aaf0e feat(block): normalize markdown code-fence aliases to Notion's enum (#28)
Markdown / LLM output routinely uses short language labels (`ts`, `sh`,
`yml`, `py`, …) that the Notion API rejects because code.language is a
fixed enum. Previously every such fence hard-failed the whole PATCH with:

    body.children[N].code.language should be "abap", ..., "typescript",
    "yaml", or "java/c/c++/c#", instead was "ts".

Introduce `normalizeCodeLanguage`:
  - passes through any value that's already in the Notion enum,
  - maps ~50 common aliases (ts→typescript, sh→shell, yml→yaml, py→python,
    cpp→c++, cs→c#, dockerfile→docker, md→markdown, proto→protobuf, …),
  - for unknown values, falls back to 'plain text' and emits a one-line
    stderr warning so a single unrecognized fence can't break a long doc.

Applied to both markdown parsing (`notion block append --file`) and the
`--lang` flag on inline append/insert, so CLI-typed aliases like
`--lang ts` also work.

Closes #22
2026-04-30 12:58:22 +08:00