@jacobbubu/md-to-lark
v1.7.1
Published
Publish Markdown to Feishu docs with a stable pipeline.
Readme
md-to-lark
md-to-lark publishes Markdown (GFM) content to Feishu docs through a repeatable pipeline.
It is not a one-off rendering script. The pipeline covers input preparation, title policy, asset detection and upload, Mermaid rendering, table enhancement, dry-run, and stage-by-stage artifacts for debugging.
Repository And Package Name
- GitHub repository: jacobbubu/md-to-lark
- The npm package metadata is configured as
@jacobbubu/md-to-lark - The dependency
@jacobbubu/md-zh-formatremains unchanged
Notes:
- The commands in this README are still focused on local development and verification.
- Once the package is actually published to npm, it can be installed as
@jacobbubu/md-to-lark.
What It Is Good For
- Publishing a single Markdown file to a Feishu doc
- Recursively publishing multiple
.mdfiles from a directory - Preparing local assets, remote images, and standalone URLs before publish
- Running a full dry-run without writing to Feishu
- Rewriting Markdown before publish with one or more ordered presets
Quick Start
Install dependencies first:
npm installThen prepare .env:
cp .env.sample .envAt minimum, make sure these values are valid:
LARK_APP_ID="xxx"
LARK_APP_SECRET="xxx"
LARK_TOKEN_TYPE=tenant
LARK_FOLDER_TOKEN="xxx"If you want the returned documentUrl to use a specific browser domain, set this too:
LARK_DOCUMENT_BASE_URL="https://li.feishu.cn"Notes:
- Pure local
--dry-rundoes not require Feishu credentials,--folder, or--doc. - Real publishing requires either
--docorLARK_FOLDER_TOKEN/--folder, plus valid Feishu credentials.
The first run should use a built-in sample:
npm run publish:md -- --input ./test-md/comp/comp.md --dry-runThis runs the full pipeline without actually writing to Feishu. After that looks correct, remove --dry-run:
npm run publish:md -- --input ./test-md/comp/comp.mdSuccessful CLI runs now print a JSON array to stdout. Each item contains:
documentIdtitlestatusdocumentUrl
Progress logs and exceptions are written to stderr.
documentUrl is built from documentId plus a document base URL:
- Prefer
--document-base-url - Otherwise use
LARK_DOCUMENT_BASE_URL - Otherwise fall back to the current compatibility derivation from
LARK_BASE_URL
Relative local assets such as ./img-001.png still resolve against the Markdown file directory by default. If your caller generates a temporary Markdown file elsewhere, use --resource-base-dir to keep local asset resolution pinned to the original content directory.
Common Commands
Basic publish:
npm run publish:md -- --input ./test-md/comp/comp.md
npm run publish:md -- --input ./test-md/comp/comp.md --dry-run
npm run publish:md -- --input ./test-mdTarget document and title:
npm run publish:md -- --input ./test-md/comp/comp.md --doc <document_id>
npm run publish:md -- --input ./test-md --title "Team Notes"
npm run publish:md -- --input ./test-md/comp/comp.md --no-date-prefixPresets, Mermaid, and stage artifacts:
npm run publish:md -- --input ./test-md/comp/comp.md --preset medium --dry-run
npm run publish:md -- --input ./test-md/comp/comp.md --preset zh-format --dry-run
npm run publish:md -- --input ./test-md/comp/comp.md --preset zh-format --preset ./my-preset.mjs --dry-run
npm run publish:md -- --input ./paper.md --single-dollar-text-math --dry-run
npm run publish:md -- --input ./tmp/generated/article.md --resource-base-dir ./source-assets --dry-run
npm run publish:md -- --input ./test-md/mermaid.md --mermaid-target board --dry-run
npm run publish:md -- --input ./test-md/comp/comp.md --pipeline-cache-dir ./out/debug-cache --dry-runDebugging and helper scripts:
npm run dev:playground
npm run example:module
npm run fetch:board-data -- --doc <document_id> --index 1Testing
Default local verification:
npm run check
npm testLive Feishu end-to-end tests:
npm run test:e2e
npm run test:e2e:watchNotes:
npm testonly runs local tests and never writes to Feishu.npm run test:e2eruns real Feishu end-to-end tests and requires a local.env-test..env-testis already ignored by Git and can be prepared from.env-test.example.
Release Process
Releases are now driven by semantic-release.
- Only pushes to
maincan trigger a real release - Version numbers are calculated from commit messages
- GitHub Releases and npm publishing are both handled automatically
CHANGELOG.mdis maintained by CI
Required repository setup:
- GitHub Actions must be enabled
- The repository must have an
NPM_TOKENsecret with publish permission for@jacobbubu/md-to-lark - Commits merged into
mainshould continue to use Conventional Commit style such asfeat:andfix:
Guardrails:
- Non-
mainbranches do not trigger the release workflow - Non-
mainbranches can still run local checks, tests, and build verification - npm publishing is expected to happen only through the
mainbranch CI flow
Core Capabilities
- Single-file and recursive directory publish
- Title derivation, title prefix, and single-H1 promotion
- Local attachment and image detection with real upload
- Programmatic image display width control through
imageSizeResolver - Versioned
article-render/v1contracts with inheritance, capability negotiation, strict pre-publish validation, and render reports - Semantic figures, tables, equations, callouts, and GFM footnotes rendered to native Lark block structures
- Automatic
assets/manifest.ymlimage sizing in renderer-contract mode - Remote image download and standalone URL preparation
- Mermaid
text-drawingandboardoutput paths - Opt-in single-dollar inline math parsing for LaTeX-heavy papers
- Table width heuristics and numeric-column right alignment
- Chinese Markdown formatting preset (
zh-format) - Ordered preset composition from CLI and programmatic usage
- Legacy stage cache output from
00-sourceto05-publish; protocol mode adds contract and semantic stages through07-publish - Programmatic access through
publishMdToLark
Where To Read Next
README is only the entry point. It does not repeat the full parameter reference or implementation details.
If this is your first time using the project, read in this order:
01-getting-started -> 02-guides -> 03-reference -> 04-internals
