Skip to content

fix: add inline block embeds support to fix #114#119

Merged
bingryan merged 1 commit intomasterfrom
bingryan/analyze-pr-114
Jan 3, 2026
Merged

fix: add inline block embeds support to fix #114#119
bingryan merged 1 commit intomasterfrom
bingryan/analyze-pr-114

Conversation

@bingryan
Copy link
Copy Markdown
Owner

@bingryan bingryan commented Jan 3, 2026

Summary

  • Fixes issue [FR] Option to embed blocks as text, not as links #114 where block embeds ![[#^blockid]] don't work after export
  • Adds new setting "Inline Block Embeds" to replace block references with actual content
  • Fixes execution order: process embeds before WikiLinks conversion (prevents malformed links)
  • Adds getBlockContent() to extract block content using Obsidian Metadata API
  • Adds parseEmbedLink() to parse file path and block reference ID
  • Prevents "undefined" output when embed content is not found

Test plan

  • Code change follows existing patterns in the codebase
  • Build succeeds without errors
  • Setting added to UI with proper description
  • Block embeds ![[#^blockid]] are now handled correctly
  • When "Inline Block Embeds" is enabled, block content is extracted and inlined
  • When disabled, block embeds are preserved (may not work in exported markdown)
  • No more "undefined" output for missing embeds

Fixes #114

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added "Inline Block Embeds" setting in plugin preferences to control how block embeds appear in markdown exports. When enabled, block embeds are replaced with their actual content formatted as blockquotes. When disabled, embeds are preserved as-is.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 3, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new "Inline Block Embeds" feature that allows users to export block references as embedded text content rather than preserved links. A configuration option is added with UI toggle, and embed processing logic is enhanced with helper functions to parse, fetch, and format block content as blockquotes.

Changes

Cohort / File(s) Summary
Configuration & UI
src/config.ts, src/main.ts
Added inlineBlockEmbeds: boolean setting with default false. New toggle switch in settings tab to control inline block embed behavior with user-facing description.
Embed Processing Logic
src/utils.ts
Added getBlockContent() and parseEmbedLink() helper functions. Modified embed replacement flow: attempts embedMap lookup first; if not found and setting enabled, parses embed link to extract block ID, fetches block content, formats as blockquote, and uses as replacement. Moved WikiLink conversion after embed processing to ensure correct precedence.

Sequence Diagram

sequenceDiagram
    participant Plugin as Plugin
    participant EmbedProc as Embed Processor
    participant EmbedMap as EmbedMap
    participant Parser as Link Parser
    participant FS as File System
    participant Formatter as Content Formatter

    Plugin->>EmbedProc: Process embed in content
    EmbedProc->>EmbedMap: Lookup embed link
    alt Found in EmbedMap
        EmbedMap-->>EmbedProc: Return mapped content
        EmbedProc-->>Plugin: Use mapped content
    else Not found & inlineBlockEmbeds enabled
        EmbedProc->>Parser: Parse embed link
        Parser->>Parser: Extract filePath & blockId
        Parser-->>EmbedProc: Resolved path & blockId
        EmbedProc->>FS: Fetch block content by ID
        rect rgb(230, 245, 255)
            FS-->>EmbedProc: Block content retrieved
        end
        EmbedProc->>Formatter: Format as blockquote
        Formatter-->>EmbedProc: "> " prefixed lines
        EmbedProc-->>Plugin: Use formatted content
    else Not found & setting disabled
        EmbedProc-->>Plugin: No replacement
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit's ode to embedded blocks

Once links that led to distant mines,
Now blocquotes dance in nested lines—
A toggle flips, the syntax bends,
Where embed becomes where text transcends! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding support for inline block embeds to address issue #114.
Linked Issues check ✅ Passed The PR directly addresses issue #114 by implementing an 'Inline Block Embeds' setting that replaces block reference embeds with actual content, fixing the broken embed links problem.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the inline block embeds feature: config settings, UI toggle, embed parsing, and block content extraction.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35a1029 and fe1184c.

📒 Files selected for processing (3)
  • src/config.ts
  • src/main.ts
  • src/utils.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/utils.ts (1)
src/main.ts (1)
  • MarkdownExportPlugin (117-266)
🔇 Additional comments (5)
src/main.ts (1)

441-454: LGTM! Clean settings UI implementation.

The new "Inline Block Embeds" setting follows the established patterns in the codebase and provides a clear description of the feature's behavior.

src/config.ts (1)

34-35: LGTM! Configuration correctly defined.

The new inlineBlockEmbeds setting is properly typed and defaulted to false, making this an opt-in feature that won't affect existing users.

Also applies to: 55-56

src/utils.ts (3)

485-531: LGTM! Well-structured block content extraction.

The function correctly uses the Obsidian Metadata API to locate and extract block content. Error handling is appropriate with null returns and console logging.


540-588: LGTM! Comprehensive embed link parsing.

The function correctly handles all three embed formats (block references, headings, and regular links) with appropriate path resolution and edge case handling.


801-846: LGTM! Correct processing order and two-stage replacement.

The changes correctly:

  1. Process embeds before WikiLink conversion to prevent malformed links
  2. Implement two-stage replacement (embedMap first, then block content extraction)
  3. Prevent "undefined" output by only replacing when content is found
  4. Format block content consistently as blockquotes

This implementation directly addresses the issues described in #114.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Add new setting "Inline Block Embeds" to replace block refs with content
- Fix execution order: process embeds before WikiLinks conversion
- Add getBlockContent() to extract block content using Obsidian API
- Add parseEmbedLink() to parse file path and block reference ID
- Prevent "undefined" output when embed content is not found

Fixes #114

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bingryan bingryan force-pushed the bingryan/analyze-pr-114 branch from 08bbcd3 to fe1184c Compare January 3, 2026 00:37
@bingryan bingryan merged commit 6481f92 into master Jan 3, 2026
5 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.

[FR] Option to embed blocks as text, not as links

1 participant