Skip to content

block append: map common markdown code-fence aliases (ts, js, sh, ...) to Notion's enum #22

@4ier

Description

@4ier

Summary

notion block append --file <md> passes markdown code-fence language strings straight to the Notion API, which only accepts a fixed enum (typescript, javascript, shell, …). Common short aliases (ts, js, sh, py, yml, …) therefore fail hard.

Repro

cat > /tmp/test.md <<'EOF'
```ts
const x: number = 1;
echo hello
key: value

EOF

notion block append --file /tmp/test.md


Actual:

Error: append block: validation_error: body failed validation:
body.children[N].code.language should be "abap", "abc", ...
"typescript", "yaml", or "java/c/c++/c#", instead was "ts".


## Expected

CLI should normalize common aliases at markdown-parse time before serializing the request, since the Notion enum is fixed and well-known. Unknown values should fall back to `plain text` with a warning rather than a hard error.

Suggested alias table:

| User writes | Map to |
|---|---|
| `ts` | `typescript` |
| `tsx` | `typescript` |
| `js` | `javascript` |
| `jsx` | `javascript` |
| `py` | `python` |
| `rb` | `ruby` |
| `rs` | `rust` |
| `sh` / `zsh` / `bash` | `shell` (note: `bash` is actually in the enum, so no-op) |
| `yml` | `yaml` |
| `md` | `markdown` |
| `Dockerfile` / `dockerfile` | `docker` |
| `proto` | `protobuf` |
| *(empty / unset)* | `plain text` |
| *(unknown)* | `plain text` + stderr warn: `unknown code language "foo", falling back to plain text` |

## Current workaround

```bash
sed -i 's/^```ts$/```typescript/' file.md
# and similar for each alias in the file

Priority

Medium — trivial to fix and prevents a confusing error message on almost every markdown file produced by modern editors / LLMs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions