Skip to content

feat: support all BFM formats in both inline and block reference directives#5323

Merged
lukemelia merged 1 commit into
mainfrom
cs-11704-bfm-support-all-formats-in-both-inline-and-block-reference
Jun 24, 2026
Merged

feat: support all BFM formats in both inline and block reference directives#5323
lukemelia merged 1 commit into
mainfrom
cs-11704-bfm-support-all-formats-in-both-inline-and-block-reference

Conversation

@lukemelia

Copy link
Copy Markdown
Contributor

Resolves CS-11704.

Why

BFM previously coupled render format to placement: the inline directive :card[url] had no size/format slot, so it was hardcoded to atom; only the block directive ::card[url | spec] could express embedded / fitted / isolated / dimensions. This decouples format from placement so every format works in both modes — the grammar ("dictionary") side of the Markdown Editing UI design.

What changed

Grammar — packages/runtime-common/bfm-card-references.ts

  • parseBfmSizeSpec accepts atom (and confirms embedded/isolated); BfmSizeSpec.format gains 'atom'.
  • Inline tokenizer splits the bracket on | and captures the specifier; inline renderer emits data-boxel-bfm-format / -width / -height via a new shared bfmSizeAttrs helper used by both the inline and block renderers.
  • extractBfmReferences strips the specifier from inline URLs (so :card[url | spec] extracts just the URL).
  • bfmBlockFormatAndSizebfmRefFormatAndSize (BfmBlockFormatBfmRefFormat, now includes atom) with a defaultFormat param — block defaults to embedded, inline to atom.

Writer — packages/base/markdown-helpers.ts

  • markdownEmbedForCard honors the size option for inline embeds (:card[id | embedded]).

Renderers — packages/host/.../rendered-markdown.gts + packages/base/default-templates/markdown.gts (kept in parallel)

  • Inline refs derive format/size from the data attributes instead of forcing atom. Resolved non-atom inline slots flow as display: inline-block (new --inline-embed class); loading/broken inline placeholders adopt the derived footprint. Plain (atom) inline refs are unchanged.

Docs — updated the dev-bfm-syntax and dev-markdown-format skill grammar tables to document inline specs and the atom spec.

Acceptance criteria

  • :card[url | embedded], :card[url | 400x200], and ::card[url | atom] all parse, extract, and render in the correct format and placement. ✅

Scope note (read/grammar side only)

This is the partial-on-main slice agreed for CS-11704. The literal serializeBfmRef function and the markdown-embed-preview-pane test referenced in the ticket live only on the open PR #5303 (cs-11673) branch, not on main, so they're deferred. On main the writer is markdownEmbedForCard (which #5303 turns into a serializeBfmRef delegate); the inline-size logic added here moves into serializeBfmRef as a straightforward conflict resolution when #5303 lands, after which the chooser emits/previews inline-formatted embeds with no further change.

Tests

  • Unit (bfm-card-references-test, markdown-helpers-test): inline pipe-extraction, inline renderer emits format/size attrs, parseBfmSizeSpec('atom'), bfmRefFormatAndSize atom + defaultFormat, block | atom, "ignored for inline" flipped to "honored for inline".
  • Integration (rendered-markdown-test): inline embedded/fitted/atom data-attr + broken-footprint cases.
  • Integration (rich-markdown-field-test): real-card resolved inline embed asserts the --inline-embed (inline-block) slot class; atom ref keeps --inline.

Verified locally with ember-tsc (host + runtime-common), eslint, and ember-template-lint. The host QUnit suite runs on CI.

🤖 Generated with Claude Code

…ctives

Inline BFM reference directives (`:card[url]`) previously carried no
size/format slot, so the renderer hardcoded them to atom; only block
directives (`::card[url | spec]`) could express embedded / fitted /
isolated / dimensions. This makes every format available in both
placements.

Grammar (runtime-common/bfm-card-references.ts):
- parseBfmSizeSpec accepts `atom`; BfmSizeSpec.format gains 'atom'.
- The inline tokenizer splits the bracket on `|` and captures the
  specifier; the inline renderer emits data-boxel-bfm-format/-width/
  -height via a shared bfmSizeAttrs helper used by both renderers.
- extractBfmReferences strips the specifier from inline URLs.
- bfmBlockFormatAndSize becomes bfmRefFormatAndSize (now includes atom)
  with a defaultFormat parameter (block -> embedded, inline -> atom).

Writer (base/markdown-helpers.ts):
- markdownEmbedForCard honors the size option for inline embeds.

Renderers (host rendered-markdown.gts + base markdown.gts):
- Inline refs derive format/size from the data attributes instead of
  forcing atom. Resolved non-atom inline slots flow as inline-block;
  loading/broken inline placeholders adopt the derived footprint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   2h 0m 35s ⏱️
3 191 tests 3 176 ✅ 15 💤 0 ❌
3 210 runs  3 195 ✅ 15 💤 0 ❌

Results for commit 1e153da.

Realm Server Test Results

    1 files      1 suites   11m 15s ⏱️
1 727 tests 1 727 ✅ 0 💤 0 ❌
1 820 runs  1 820 ✅ 0 💤 0 ❌

Results for commit 1e153da.

@lukemelia lukemelia requested a review from FadhlanR June 23, 2026 20:36
@lukemelia lukemelia marked this pull request as ready for review June 23, 2026 20:36
@lukemelia lukemelia requested a review from a team June 23, 2026 21:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Decouples BFM render format from placement so inline (:card[...]) and block (::card[...]) directives can both express any supported format/size, with placement-specific defaults (inline → atom, block → embedded).

Changes:

  • Extended BFM size parsing/extraction/rendering to support atom and inline | spec, emitting shared data-boxel-bfm-format/width/height attributes for both inline and block refs.
  • Updated markdown writer helper (markdownEmbedForCard) to serialize inline embeds with an optional | size spec.
  • Updated host + base markdown renderers to derive inline slot format/footprint from data attributes and render non-atom inline embeds as inline-block (with matching loading/broken placeholders), plus added/updated tests and docs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/runtime-common/bfm-card-references.ts Adds atom size parsing, inline `
packages/base/markdown-helpers.ts Allows inline embeds to include `
packages/host/app/components/operator-mode/preview-panel/rendered-markdown.gts Derives inline format/footprint from BFM data attrs; adds inline-embed slot/loading/broken behaviors and styles.
packages/base/default-templates/markdown.gts Mirrors host renderer changes for base realm markdown rendering (format derivation + inline-embed flow/styling).
packages/host/tests/unit/bfm-card-references-test.ts Adds coverage for inline pipe URL extraction, inline/block attribute emission (including atom), and bfmRefFormatAndSize defaulting behavior.
packages/host/tests/unit/markdown-helpers-test.ts Updates expectations so inline embeds honor size, and adds an inline embedded size test.
packages/host/tests/integration/components/rendered-markdown-test.gts Adds integration coverage for inline size/format attrs and unresolved inline footprint behavior (embedded/fitted/plain).
packages/host/tests/integration/components/rich-markdown-field-test.gts Verifies resolved inline embeds use --inline-embed for non-atom while atom keeps --inline.
packages/boxel-cli/plugin/skills/dev-bfm-syntax/SKILL.md Documents inline `:card[URL
packages/boxel-cli/plugin/skills/dev-markdown-format/SKILL.md Updates helper table to document inline `

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lukemelia lukemelia merged commit 597c8f2 into main Jun 24, 2026
89 of 103 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.

4 participants