Skip to content

feat(im): support Markdown image rendering in post content#893

Open
liujiashu-shiro wants to merge 2 commits into
mainfrom
feat/markdown_image
Open

feat(im): support Markdown image rendering in post content#893
liujiashu-shiro wants to merge 2 commits into
mainfrom
feat/markdown_image

Conversation

@liujiashu-shiro
Copy link
Copy Markdown
Collaborator

@liujiashu-shiro liujiashu-shiro commented May 14, 2026

Summary

Leverage underlying URL compatibility and remove redundant URL conversion logic to simplify the Markdown-to-Post element processing pipeline. Also add documentation for sending Markdown images, and align image handling guidance with actual runtime behavior.

Changes

  • Remove buildPostElements, buildPostElementNodes, scanPostToken, scanBareURLToken, scanMarkdownLinkToken, scanBalancedParenToken, trimBareURLToken, appendMDPostNode, marshalJSONNoEscape, marshalStringNoEscape and related constants
  • Revert buildSingleMDPost / buildSegmentedPost to single {"tag":"md"} serialization
  • Replace marshalJSONNoEscape with standard json.Marshal
  • Remove corresponding unit tests
  • Add Markdown image instructions in lark-im-messages-send.md and lark-im-messages-reply.md
  • Align Markdown image documentation with runtime behavior: clarify that img_xxx keys are the most reliable input, local paths are not supported, and remote URLs are auto-resolved at runtime (removed with a warning on failure); recommend pre-uploading via images.create for reliability

Test Plan

  • Unit tests pass (go test ./shortcuts/im/)
  • Verify lark im send --markdown with bare URLs renders correctly
  • Verify sending images via Markdown image syntax displays properly

Summary by CodeRabbit

  • Documentation
    • Updated Markdown image handling guidance for messaging features to clarify that local file paths are not supported
    • Added recommendations to pre-upload images via images.create for improved reliability
    • Added workflow examples demonstrating best practices for referencing images in Markdown messages and replies
    • Clarified that remote URLs may be auto-downloaded/uploaded with possible removal on failure

Review Change Stack

Leverage underlying URL compatibility and remove redundant URL conversion logic. Add the ability to send Markdown images.
Clarify that remote URLs are auto-resolved at runtime and only removed
on failure, rather than being unsupported. Recommend pre-uploading via
images.create for reliability. Update caveats, common mistakes, and
notes in both messages-send and messages-reply references.
@github-actions github-actions Bot added domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact labels May 14, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a88bc4fd-581d-4af9-8486-041306b585aa

📥 Commits

Reviewing files that changed from the base of the PR and between 52e0129 and ec827b6.

📒 Files selected for processing (4)
  • shortcuts/im/helpers.go
  • shortcuts/im/helpers_test.go
  • skills/lark-im/references/lark-im-messages-reply.md
  • skills/lark-im/references/lark-im-messages-send.md

📝 Walkthrough

Walkthrough

This PR simplifies Feishu markdown post wrapping by consolidating tokenized inline elements into single md elements, replacing custom no-escape JSON marshaling with standard marshaling, removing URL and code-block decomposition helpers, and documenting the updated image handling constraints requiring pre-upload or remote URL resolution for --markdown replies and sends.

Changes

Markdown wrapping simplification and image documentation

Layer / File(s) Summary
Markdown wrapping simplification
shortcuts/im/helpers.go
Replaces custom no-escape JSON marshaling with json.Marshal, consolidates segmented post construction from multi-element decomposition (buildPostElementNodes) to single md elements, and removes tokenization/splitting helpers for URL and code-block preservation.
Test validation for plain markdown wrapping
shortcuts/im/helpers_test.go
Rewrites TestWrapMarkdownAsPost to validate only the simplified plain markdown wrapping case, removing prior sub-tests for URL-to-link transformation and code-block URL preservation.
Image constraint documentation for messages-reply and messages-send
skills/lark-im/references/lark-im-messages-reply.md, skills/lark-im/references/lark-im-messages-send.md
Clarifies markdown image handling across both skill references: documents pre-uploaded img_xxx keys as the recommended input, states local file paths in markdown syntax are not supported, notes remote URLs may be auto-downloaded/uploaded at runtime with removal on failure, and adds examples plus common-mistake warnings for image usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • larksuite/cli#206: Both PRs modify shortcuts/im/helpers.go markdown-to-Feishu post wrapping (wrapMarkdownAsPost), with this PR consolidating to single md elements via standard json.Marshal, whereas PR #206 tokenizes into mixed md/a elements with no-escape marshaling.
  • larksuite/cli#338: Both PRs modify shortcuts/im/helpers.go's markdown-to-Feishu wrapping pipeline (e.g., wrapMarkdownAsPost and content builders), with this PR removing tokenization/splitting behavior compared to the segmentation refactoring in #338.

Suggested labels

domain/im, size/L

Suggested reviewers

  • YangJunzhou-01
  • fangshuyu-768

Poem

🐰 A simpler path for posts to take,
No tokens split, just md to make,
Pre-uploaded images shine so bright,
Local paths are out of sight,
The wrapping's clean—what a delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(im): support Markdown image rendering in post content' clearly and concisely describes the main change—adding Markdown image rendering support to the IM feature.
Description check ✅ Passed The pull request description includes all required template sections: Summary (motivation and scope), Changes (main modifications listed), Test Plan (verification steps with checkmarks), and Related Issues. Content is clear and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/markdown_image

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.

@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@ec827b6ccf1cfadb3edcc25bfab8d7bb33b72593

🧩 Skill update

npx skills add larksuite/cli#feat/markdown_image -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.87%. Comparing base (b0c9a4d) to head (ec827b6).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #893      +/-   ##
==========================================
- Coverage   65.90%   65.87%   -0.03%     
==========================================
  Files         518      520       +2     
  Lines       48830    49171     +341     
==========================================
+ Hits        32181    32391     +210     
- Misses      13882    14014     +132     
+ Partials     2767     2766       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant