Skip to content

fix(docs): render native bullets and contiguous code blocks in markdown append (#594)#627

Merged
steipete merged 5 commits into
openclaw:mainfrom
sebsnyk:fix/594-append-bullets-code
May 21, 2026
Merged

fix(docs): render native bullets and contiguous code blocks in markdown append (#594)#627
steipete merged 5 commits into
openclaw:mainfrom
sebsnyk:fix/594-append-bullets-code

Conversation

@sebsnyk
Copy link
Copy Markdown
Contributor

@sebsnyk sebsnyk commented May 21, 2026

Summary

Fixes #594.

docs write --markdown --append produced two visibly broken outputs on v0.17.0:

  1. Bullet lists rendered as NORMAL_TEXT paragraphs with a literal glyph (or 1.) sitting in the text run, instead of native BULLET paragraph style.
  2. Fenced code blocks rendered as N separate one-line Courier New NORMAL_TEXT paragraphs with no paragraph background, instead of a single contiguous shaded code block.

Both issues live in MarkdownToDocsRequests in internal/cmd/docs_formatter.go, which is the shared converter used by both the --append path and the find-replace --format=markdown path. The docs create --file --markdown path was unaffected because that path uploads text/markdown to Drive and lets Drive do the conversion — it doesn't touch this converter at all.

Changes

  • MDListItem / MDNumberedList: stop emitting a literal "• " / "1. " text prefix. Emit a bare paragraph and add a CreateParagraphBullets request with BULLET_DISC_CIRCLE_SQUARE (or NUMBERED_DECIMAL_NESTED) over its range. Inline text styles no longer need a prefix offset.
  • MDCodeBlock: replace embedded \n with \v (Docs soft line break) so the whole fenced block lives in one paragraph, then apply paragraph-level Shading.BackgroundColor (light grey) across the range. Monospace Courier New is still applied as a text style.
  • Added TestMarkdownToDocsRequests_AppendBulletsAndCode in docs_formatter_test.go covering both bullet/numbered presets and the code-block soft-break + shading path, plus a negative assertion that no literal glyph survives in any InsertText payload.

Scope vs #592

The issue hints that #594 might share a root cause with #592 (table insertion failing in the same --append --markdown path). After tracing both, they're independent failures:

Both bugs happen to surface on the --append --markdown path, but the fix points are different files and the fix here doesn't address #592. Keeping scope tight to #594 as requested; happy to follow up with #592 separately if useful.

Test plan

  • go test ./internal/cmd/ -run "TestMarkdownToDocsRequests" -v — new + existing formatter tests pass.
  • go test ./internal/cmd/ — full cmd suite green (including TestDocsWrite_MarkdownAppendUsesDocsFormatting, TestDocsWrite_MarkdownReplaceUsesDriveUpdate, all table/insert/sed coverage).
  • go test ./... — all packages green.
  • go vet ./internal/cmd/... — clean.
  • gofmt -d on edited files — no diff.

🤖 Generated with Claude Code

sebsnyk and others added 5 commits May 22, 2026 00:00
…wn append (openclaw#594)

`docs write --markdown --append` previously inlined a literal `• ` or `1. `
prefix into the text run for list items, leaving the resulting paragraph as
`NORMAL_TEXT` with the glyph baked into the content. Fenced code blocks were
emitted as one Courier-styled `NORMAL_TEXT` paragraph per source line with no
paragraph-level background, because the embedded `\n` characters split each
line into its own paragraph.

Fix the shared `MarkdownToDocsRequests` converter (used by both the append
path and the `find-replace` markdown path) so that:

- `MDListItem` and `MDNumberedList` emit a bare paragraph and a
  `CreateParagraphBullets` request with `BULLET_DISC_CIRCLE_SQUARE` or
  `NUMBERED_DECIMAL_NESTED`, matching the bullet plumbing already used by
  `docs_sed_helpers.buildParagraphStyleRequests` and `docs_sed_nesting`. The
  literal glyph prefix is gone, so inline text styles no longer need to be
  shifted past it.
- `MDCodeBlock` joins source lines with `\v` (Docs soft line break) so the
  whole fenced block stays in a single paragraph, then applies an
  `UpdateParagraphStyle` with `Shading.BackgroundColor` (light grey) across
  the range. The `Courier New` text style is still applied to the run.

Regression test in `docs_formatter_test.go` asserts the InsertText payload no
longer contains literal `• ` or `1. ` prefixes, that code-block lines are
joined by `\v`, and that `CreateParagraphBullets` + paragraph shading are
emitted with the expected presets.
@steipete steipete force-pushed the fix/594-append-bullets-code branch from 1b383dd to 8039ff4 Compare May 21, 2026 23:35
@steipete steipete merged commit b646e88 into openclaw:main May 21, 2026
7 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.

docs write --markdown --append emits literal bullets + per-line code paragraphs (no native list, no contiguous code block)

2 participants