jackwener / jackwener/xiaohongshu-cli

feat(read): 增加正文全文与 Markdown 友好输出模式

Open
#55 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
2.6k
Forks
272
PR merge metrics
No merged PRs in 30d

Description

### Current version

0.6.4

### Describe the feature

希望 `xhs read` 增加“正文全文可读输出”能力,尤其是直接输出 `note_card.desc`,避免必须手动解析超长 JSON。

期望新增:
- 支持直接输出全文正文,例如:
- `xhs read 1 --full`
- 或 `xhs read 1 --field desc`
- 支持 Markdown 友好输出(便于批量导出):
- `xhs read 1 --md`
- 输出标题 + 全量 desc 的干净 Markdown 文本
- 可选支持分页器阅读(终端慢慢看):
- `xhs read 1 --full --pager`(或自动使用 `$PAGER`)

### Use case

当前问题:
- `xhs read ` 只显示截断后的正文预览;
- `xhs read --json` 虽然有完整内容,但信息过于冗长,不利于终端阅读和脚本处理, 同样--yaml。

我想要的效果类似于
```bash
xhs read 1 --json | jq -r '.data.items[0].note_card.desc // ""' | less
```

建议命令形式(示例):
- `xhs read 1 --field desc`
- `xhs read 1 --field title,desc --format markdown`
- `xhs read 1 --full --no-truncate`

这样会显著提升以下场景体验:
- 终端阅读长笔记正文;
- 提取内容;
- 批量将可读文本追加到 `.md` 文件。

我的使用流程是先 `xhs search ... --page N`,然后循环执行 `xhs read 1..20` 批量收集内容。
在这个流程中,我最需要的是“可读的正文全文(desc)”,用于:
- 终端逐行阅读(类似 less);
- 输出到 .md 进行后续整理。

目前默认输出会截断,JSON 输出又过长且噪声大。
如果支持“全文/字段/Markdown 输出”,会极大提升笔记整理效率。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the xhs read command and compare its current truncated output with the existing --json and --yaml modes. Review how note_card.desc is exposed, then determine which proposed options (--full, --field, --md, or --pager) are in scope. Done means long note text can be read or exported without truncation while retaining a clean Markdown-oriented output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.