Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

org-lark

https://melpa.org/packages/org-lark-badge.svg

Two-way bridge between Lark/Feishu docs and Org files.

Fetches Markdown via lark-cli, normalizes Lark-specific custom blocks (tables, quotes, callouts, grids, …), and converts into an Org file. See the full sample export: example/exported.org

Requirements

Install

From MELPA:

M-x package-install RET org-lark RET

Or manually:

(add-to-list 'load-path "/path/to/org-lark")
(require 'org-lark)

Usage

;; Interactive
M-x org-lark-export

;; From Lisp
(org-lark-export "https://your-lark-doc" "~/notes/export.org")

;; Export URL at point
M-x org-lark-export-url-at-point

The minibuffer shows short status messages during export:

org-lark: fetching...
org-lark: converting...
org-lark: downloading media 3/12...
org-lark: running pandoc...
org-lark: done → export.org

Image and whiteboard tokens are downloaded automatically when org-lark-download-media is non-nil. The exporter calls lark-cli docs +media-download --token TOKEN from the Org file’s directory, passes a relative --output path such as assets/TOKEN, saves the result under the configured assets directory, and emits an Org image link such as:

#+attr_org: :width 640 :align center
[[file:assets/example.png]]

Publish

Push an Org file back up to Lark. If the file’s #+lark_doc_id: header is set, the existing remote doc is overwritten; otherwise a new doc is created and the doc id / URL are written back into the local file’s header.

;; Interactive
M-x org-lark-publish

;; From Lisp (async; callback gets (ERR URL))
(org-lark-publish-async "~/notes/export.org"
                        (lambda (err url)
                          (message "%s" (or url err))))

The pipeline reverses the export:

  1. Strip Org keyword headers; remember #+title, #+lark_doc_id, #+lark_source, and an optional #+lark_parent: (e.g. folder:TOKEN or wiki:SPACE/NODE).
  2. Reverse-map #+begin_lark_grid / _column / _chat_card / _addon / _source_synced / _reference_synced / _view, #+begin_quote with #+attr_org, and #+begin_example with :emoji back into Lark custom tags.
  3. Reverse-map [[lark-doc:..]], [[lark-user:..]], [[lark-task:..]], [[lark-sheet:..]] into the corresponding inline tags.
  4. Run Pandoc once (org → gfm --wrap=none).
  5. For each [[file:..]] image/attachment: reuse the cached Lark token when the file’s SHA-256 is unchanged; otherwise upload via lark-cli docs +media-upload and cache the returned token in org-lark-media-cache-file.
  6. Call lark-cli docs +create (new doc) or docs +update --mode overwrite (existing). When creating, the new doc id and URL are written back into the local file’s header.

Debugging

M-x org-lark-toggle-debug opens a read-only *org-lark-log* buffer with timestamped details: full shell commands, exit codes, byte counts, tag match counts, and per-step timing.

Customization

VariableDefaultDescription
org-lark-cli-program"lark-cli"Path to lark-cli
org-lark-pandoc-program"pandoc"Path to pandoc
org-lark-identity"user"--as identity for lark-cli
org-lark-download-mediatDownload images/files/whiteboards
org-lark-assets-directory"assets"Asset sub-directory
org-lark-timeout30Seconds before killing a subprocess
org-lark-open-after-exporttVisit converted file after export
org-lark-debugnilLog to *org-lark-log* buffer
org-lark-publish-default-parentnilFallback parent for created docs (folder:T or wiki:S/N)
org-lark-publish-update-mode"overwrite"Mode for docs +update on re-publish
org-lark-confirm-overwrite-remotetPrompt before overwriting an existing remote doc
org-lark-media-cache-fileorg-lark-media.eldPersistent media-upload cache (per-user)

Tests

emacs -Q --batch -L . -l test/org-lark-test.el -f ert-run-tests-batch-and-exit

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages