@jacobbubu/md-to-lark
v1.3.1
Published
Publish Markdown to Feishu docs with a stable pipeline.
Downloads
261
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:
--dry-runstill validates Feishu configuration first. It is not a zero-config mode.- As long as
--docis not provided,LARK_FOLDER_TOKENis required for single-file, directory, dry-run, and real publish modes.
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
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 ./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
- Remote image download and standalone URL preparation
- Mermaid
text-drawingandboardoutput paths - Table width heuristics and numeric-column right alignment
- Chinese Markdown formatting preset (
zh-format) - Ordered preset composition from CLI and programmatic usage
- Stage cache output from
00-sourceto05-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
