Skip to content

feat(block): 'block update' accepts --file markdown and --markdown for inline#45

Merged
4ier merged 1 commit into
mainfrom
feat/block-update-file
Apr 30, 2026
Merged

feat(block): 'block update' accepts --file markdown and --markdown for inline#45
4ier merged 1 commit into
mainfrom
feat/block-update-file

Conversation

@4ier
Copy link
Copy Markdown
Owner

@4ier 4ier commented Apr 30, 2026

Closes #36. Brings block update in line with block append / block insert.

  • --file <path> — markdown must parse to exactly one block; type must match.
  • --markdown — when combined with --text, runs inline parser.
  • --text/--file mutually exclusive; at least one required.
  • Code-fence language aliases + to_do.checked preserved.

Smoke-tested: plain, markdown with bold/link, code block with 'sh' alias, and the type-mismatch guard.

…r inline

Closes #36. Brings 'block update' in line with 'block append' / 'block
insert', which have supported markdown input since earlier releases.

New flags:
  --file <path>   read markdown from a file; must parse to exactly one
                  block. Fails fast on type mismatch because Notion's
                  PATCH /v1/blocks/:id cannot change a block's type.
                  Code-fence language aliases from #22 apply here, so
                  --file with a 'ts' / 'sh' / 'yml' fence still works.
  --markdown      when combined with --text, runs the inline parser
                  (bold / italic / code / strikethrough / links).

Mutual-exclusion and validation:
  - --text and --file are mutually exclusive.
  - --markdown is implied for --file; supplying both is rejected.
  - At least one of --text / --file is required.
  - --file preserves type-specific inner fields (code.language, to_do.
    checked, etc.) from the parsed block.

Logic extracted to buildUpdateBlockBody() so it's unit-testable without
network. Tests cover plain text, --markdown annotations, --file parsing
with language normalization, type mismatch, multi-block rejection, and
missing-file errors.

Smoke-tested end-to-end: paragraph → plain update, paragraph → markdown
update with links/bold, code block → sh-alias update normalized to
'shell', and the type-mismatch guard fires correctly.
@4ier 4ier merged commit 89f9e90 into main Apr 30, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

block update --file: support markdown updates like append/insert

1 participant