# How Feishu Document Creation Works with Markdown Formatting in qiaomu-anything-to-notebooklm

> Discover how qiaomu-anything-to-notebooklm enables Feishu document creation using Markdown. Learn about the four-stage pipeline from analysis to publication with lark-cli.

- Repository: [向阳乔木/qiaomu-anything-to-notebooklm](https://github.com/joeseesun/qiaomu-anything-to-notebooklm)
- Tags: how-to-guide
- Published: 2026-05-16

---

**Feishu document creation in qiaomu-anything-to-notebooklm operates through a four-stage pipeline that converts content into Feishu-compatible Markdown using Google NotebookLM for analysis and the `lark-cli` tool for final publication.**

The `qiaomu-anything-to-notebooklm` repository automates the transformation of web pages and documents into structured Feishu (Lark) documents. By integrating Google NotebookLM's analytical capabilities with a specialized Markdown formatting layer, the tool generates publication-ready documents that render correctly within Feishu's native editor.

## The Document Creation Pipeline

When invoking the tool with the `--to-feishu` flag, the system executes a precise workflow defined in [`main.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/main.py):

1. **Content Ingestion**: Source material uploads to Google NotebookLM for processing and analysis.
2. **Progressive Querying**: The tool poses three rounds of structured questions to extract comprehensive insights.
3. **Markdown Compilation**: Answers assemble into Feishu-compatible Markdown with specific block-level formatting rules.
4. **Document Publication**: The `lark-cli` client creates the final document in your Feishu workspace and returns the URL.

This orchestration initiates through the `deep_analysis()` function (lines 66‑71) when called with the `to_feishu=True` parameter, triggering the complete end-to-end flow.

## Core Implementation in main.py

The primary logic resides in two critical functions that handle Markdown generation and document submission.

### Markdown Structure Assembly

The `format_feishu_markdown()` function (lines 5‑24) constructs the document architecture by combining the title, questions, and NotebookLM answers. It produces a Feishu-optimized structure containing:

- A top-level H1 heading with the document title
- An introductory blockquote (`> `) providing context
- Numbered sections for each Q&A pair

This formatting ensures the output adheres to Feishu's expected Markdown flavor, which the `lark-cli` client consumes.

### CLI Integration and Document Creation

The `create_feishu_doc()` function (lines 25‑45) handles final publication by executing a subprocess call:

```bash
lark-cli docs +create --title "<title>" --markdown "<markdown_content>"

```

The function passes the pre-formatted Markdown string directly to the CLI, which authenticates with your Feishu account and returns the newly created document's URL upon successful completion.

## Feishu-Compatible Markdown Parsing

The [`feishu-read-mcp/src/parser.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/feishu-read-mcp/src/parser.py) file contains the critical `_block_to_markdown()` function, which guarantees all Markdown output complies with Feishu's rendering specifications. The parser converts internal HTML representations into structured blocks, mapping each type to its correct Markdown syntax:

- **Headings**: ATX-style headers (`#`, `##`, `###`) based on level (lines 47‑51)
- **Paragraphs**: Plain text blocks without decoration (lines 52‑54)
- **Lists**: Unordered lists use `-` and ordered lists use `1.` syntax (lines 55‑66)
- **Blockquotes**: Lines prefixed with `> ` (lines 67‑73)
- **Code blocks**: Fenced with triple backticks and optional language identifiers (lines 74‑82)
- **Tables**: Pipe-delimited Markdown tables with header separators
- **Images**: Standard syntax `![alt](url)` (lines 88‑96)
- **Links**: Either `[text](href)` or literal `<url>` format (lines 98‑106)

This block-level conversion ensures complex documents containing tables, code samples, and embedded media render correctly within Feishu's document editor.

## Practical Usage Examples

Generate a Feishu document directly from a web URL using the command-line interface:

```bash
python main.py https://example.com/article --deep-analysis --to-feishu

```

For programmatic usage, import the creation function directly and supply custom Markdown:

```python
from main import create_feishu_doc

markdown_content = """# Research Analysis

> Generated via NotebookLM Deep Analysis

## 1. Core Concepts

Key insights from the analysis...

## 2. Implementation Details

- Point one
- Point two
"""

success = create_feishu_doc("Research Analysis - Deep Dive", markdown_content)

```

This bypasses the NotebookLM analysis phase and publishes directly to Feishu.

## Summary

- **Pipeline flow**: Content uploads to NotebookLM, undergoes three rounds of questioning, formats into Feishu-compatible Markdown via [`main.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/main.py), and publishes through `lark-cli`.
- **Formatting authority**: The [`parser.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/parser.py) module enforces strict Markdown compliance across headings, lists, tables, code fences, and media embeds.
- **Entry points**: Use the `--to-feishu` CLI flag for automated workflows or call `create_feishu_doc()` directly for custom Markdown injection.
- **External dependency**: The tool requires pre-installed `lark-cli` credentials for Feishu authentication and document management.

## Frequently Asked Questions

### What Markdown elements does Feishu support through this tool?

The tool generates Feishu-compatible Markdown supporting ATX headings, fenced code blocks with language tags, pipe-delimited tables, ordered/unordered lists, blockquotes, images with alt text, and standard link syntax. The [`parser.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/parser.py) implementation specifically maps these elements to ensure proper rendering in Feishu's native document editor.

### How does the tool handle authentication with Feishu?

Authentication occurs entirely through the external `lark-cli` command-line client, which must be pre-installed and configured with valid Feishu credentials. The `create_feishu_doc()` function delegates all authentication and API communication to this client via subprocess execution, returning the document URL upon successful creation.

### Can I modify the Markdown before it reaches Feishu?

Yes. While the automated pipeline uses `format_feishu_markdown()` to structure NotebookLM responses, you can bypass this function and call `create_feishu_doc()` directly with any valid Markdown string. Ensure your content uses the block types defined in [`parser.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/parser.py) (headings, lists, code blocks, etc.) for proper Feishu rendering.

### Does the repository support reading existing Feishu documents?

Yes. The [`feishu-read-mcp/src/server.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/feishu-read-mcp/src/server.py) module implements an MCP server providing the `read_feishu_doc` RPC, which fetches existing Feishu documents and converts their HTML content back into Markdown using the same [`parser.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/parser.py) logic. This creates symmetry between reading and writing operations within the ecosystem.