Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ termdown uses the Kitty graphics protocol to render Markdown with large-font hea
termdown rasterizes H1-H3 headings as PNG images and draws them directly in the terminal through the Kitty graphics protocol. It provides two modes:

- **Interactive TUI** (default) -- `termdown README.md` provides a vim/less-like experience with paging, search, a table of contents, and link navigation for longer documents.
- **Direct output** -- `termdown --cat README.md` prints rendered Markdown like `cat`, making it suitable for short documents or piping to other programs.
- **Direct output** -- `termdown --cat README.md` prints rendered Markdown like `cat`, making it suitable for short documents. Piped or redirected output uses text headings instead of Kitty images.

H4-H6 headings always use ANSI bold text instead of simulating more font sizes and weights that could reduce readability in a terminal.

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ termdown 基于 Kitty 图形协议,在终端中以大字体标题渲染 Markdo
termdown 将 H1-H3 标题栅格化为 PNG 图片,通过 Kitty 图形协议直接绘制到终端。提供两种使用模式:

- **交互式 TUI**(默认)—— `termdown README.md`,提供类似 vim/less 的体验,支持翻页、搜索、查看目录和链接跳转,适合阅读较长文档。
- **直接输出** —— `termdown --cat README.md`,像 `cat` 一样直接输出渲染后的 Markdown,适合查看短文档或通过管道交给其他程序处理
- **直接输出** —— `termdown --cat README.md`,像 `cat` 一样直接输出渲染后的 Markdown,适合查看短文档;通过管道或重定向输出时,标题使用文本而不是 Kitty 图片

H4-H6 标题始终以 ANSI 粗体文本渲染,不再模拟更多字号和字重,以免损害终端中的可读性。

Expand Down
4 changes: 3 additions & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ termdown [OPTIONS] [FILE]
| `-V`, `--version` | Show version. |

By default, passing a `FILE` opens it in the interactive TUI. Piped/redirected
stdout, stdin input, or `--cat` all fall back to cat mode.
stdout, stdin input, or `--cat` all fall back to cat mode. Piped or redirected
output uses text headings instead of Kitty images so downstream programs retain
the heading content.

### Examples

Expand Down
3 changes: 2 additions & 1 deletion docs/USAGE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ termdown [选项] [文件]
| `-V`, `--version` | 显示版本。 |

默认情况下,传入文件会进入交互式 TUI。stdout 被管道/重定向、输入来自 stdin、或加
`--cat` 时都会回退到 cat 模式。
`--cat` 时都会回退到 cat 模式。通过管道或重定向输出时,标题使用文本而不是 Kitty
图片,确保下游程序保留标题内容。

### 示例

Expand Down
2 changes: 1 addition & 1 deletion fixtures/expected/specialized/metadata-none.ansi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<IMG>
Plain Document, No Frontmatter

This file has no YAML or TOML metadata block. The  ---  line further down
should be rendered as a normal horizontal rule, not as the opening
Expand Down
78 changes: 39 additions & 39 deletions fixtures/expected/supported-syntax.ansi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata · title=Supported Syntax Showcase, author=termdown, tags=[markdown, …]

<IMG>
Supported Syntax Showcase

This fixture is the single source of truth for syntax termdown currently
supports
Expand All @@ -12,47 +12,47 @@ The YAML frontmatter above is parsed and rendered as a single dim summary line
in  --cat , or as a collapsible inline box in TUI (toggle with  m ). It does
not leak into body content.

<IMG>
1. Headings

This section exercises all six heading levels, depth nesting, repeated titles,
and
long-title wrapping — covering both the heading rasterizer and the TUI
table-of-contents
panel.

<IMG>
1.1 Levels

<IMG>
H1 标题 / Heading One

<IMG>
H2 标题 / Heading Two

<IMG>
H3 标题 / Heading Three

H4 — 四级标题

H5 — 五级标题

H6 — 六级标题 (the deepest level Markdown supports)

<IMG>
1.2 Headings with emoji & mixed scripts

<IMG>
🚀 Launch builders, not just code

<IMG>
✨ 标题里的 emoji 和中文混排

<IMG>
🧪 Body Text Baseline · 正文基线

<IMG>
1.3 Repeated titles (slug disambiguation)

Duplicate

Duplicate

<IMG>
1.4 Very long heading that should wrap inside a narrow TOC panel across multiple lines

Filler paragraph so the long heading above is followed by some body content.

<IMG>
2. Emphasis

Italic via underscores, italic via asterisks.

Expand All @@ -64,9 +64,9 @@ Filler paragraph so the long heading above is followed by some body content.

斜体 · 粗体 · 粗斜体组合 · 中文删除线

<IMG>
3. Lists

<IMG>
3.1 Unordered, nested

• Item 1
• Item 2
Expand All @@ -76,32 +76,32 @@ Filler paragraph so the long heading above is followed by some body content.
• Item 2b.ii
• Item 3

<IMG>
3.2 Ordered, nested

1. Step one
2. Step two
1. Sub-step 2.1
2. Sub-step 2.2
3. Step three

<IMG>
3.3 中英混排列表

• 第一项 (item 1)
• 第二项 (item 2)
• 嵌套 a / nested a
• 嵌套 b / nested b

<IMG>
4. Task lists

<IMG>
4.1 Project TODO

[✓] Setup project structure
[✓] Add markdown parser
[ ] Implement task list rendering
[ ] Add configuration options
[ ] Write documentation

<IMG>
4.2 Nested tasks

[✓] Phase 1
[✓] Design architecture
Expand All @@ -111,7 +111,7 @@ Filler paragraph so the long heading above is followed by some body content.
[ ] Performance optimization
[ ] Integration testing

<IMG>
4.3 Mixed with regular list items & inline formatting

1. Ordered item one
2. Ordered item two
Expand All @@ -124,7 +124,7 @@ Filler paragraph so the long heading above is followed by some body content.
[ ] Task with bold and italic text
[ ] Task with  inline code 

<IMG>
5. Links

Inline link: Markdown Live Preview (https://markdownlivepreview.com/).

Expand All @@ -135,7 +135,7 @@ Reference-style link: reference example (https://ex
Bare URL (GFM autolink): https://example.com/docs/readme.html — bare email:
support@example.com — these are part of the autolink roadmap.

<IMG>
6. Images

│ Roadmap feature —  TODO.md  中"图片支持"。当前 termdown
│ 渲染图片的能力还不完整,本节
Expand All @@ -158,7 +158,7 @@ Reference-style image:

[🖼 ref image](https://example.com/banner.png)

<IMG>
7. Blockquotes

│ Markdown is a lightweight markup language with plain-text-formatting syntax,
│ created in 2004 by John Gruber with Aaron Swartz.
Expand All @@ -169,17 +169,17 @@ Reference-style image:
│ 中文引用块:Markdown 是一种轻量级标记语言,使用纯文本格式语法。
│ │ 嵌套引用:常用于编写 readme 文件与在线论坛中的消息格式化。

<IMG>
8. Tables

<IMG>
8.1 Three alignment modes

Left  │ Center  │ Right
───────────────── ┼ ──────────── ┼ ──────
a  │ b  │ c
long left content │ center  │ 1
x  │ bold in cell │  code 

<IMG>
8.2 Mixed scripts & emoji in cells

Case  │ Example
────────────────── ┼ ───────────────────
Expand All @@ -188,7 +188,7 @@ Mixed text  │ 修正版 ✨ version 2
Symbol-like  │ ✅ ⚠ ❌
Variation selector │ ☀️ ❤️ ⭐️

<IMG>
9. Code blocks

Fenced block with language tag:

Expand All @@ -211,7 +211,7 @@ Indented code block:
Inline code: this web site is using  markedjs/marked , and shell command
 cargo run -- fixtures/supported-syntax.md  should render this file.

<IMG>
10. HTML tags

│ Roadmap feature —  TODO.md  中"测试 html 标签支持"。覆盖块级 HTML、行内
│ HTML、HTML 注释。
Expand All @@ -233,29 +233,29 @@ An HTML comment: end of line.
Self-closing void element: line one
line two on the same paragraph.

<IMG>
11. Long-text wrap & indent

│ Roadmap feature —  TODO.md 
│ 中"长文本换行时缩进的处理"。本节专门用于验证:长行换行后
│ 续行的缩进是否与首行对齐(特别是在列表、引用、标题里)。

<IMG>
11.1 Long paragraph

This is a deliberately long English paragraph that should wrap multiple times
in a narrow terminal so we can verify that continuation lines start flush with
the left margin and do not get an accidental indent.
这是一段足够长的中文段落,用来验证终端窗口较窄时,软换行产生的续行应该与首行左对齐而不应该出现额外缩进,特别是混排了
emoji 🚀 与英文 ASCII 之后宽度计算仍然正确。

<IMG>
11.2 Long line in a nested list

• 顶级列表项 / Top-level list item
第二层项目,这一项里写一段非常长的中英混排正文,用来验证在嵌套列表内部软换行后续行是否能够正确缩进到列表项内容的起始列,而不是退到列表标记本身的位置
— this nested item should wrap with its continuation lines aligned to the start
of the item text, not to the bullet marker.

<IMG>
11.3 Long line in a blockquote

│ 引用块里的长行也需要正确换行:这是一段被包在  > 
│ 引用标记里的中英混排长文,软换行
Expand All @@ -264,35 +264,35 @@ of the item text, not to the bullet marker.
│ English — wrapped continuation lines must remain inside the blockquote prefix
│ rather than escape to the outer margin.

<IMG>
11.4 Long heading (continuation indent test)

一个超长四级标题,包含中文、English、还有 emoji 🚀,用来验证标题在窄终端中换行后续行的缩进表现

After the long heading above, this short paragraph anchors the test so the
heading is followed by body content.

<IMG>
12. Emoji & 中英混排

<IMG>
12.1 Inline emoji

• 单个 emoji: 😀 😎 ✨ 🚀
• 中英混排: Hello 世界 🌍
• 符号混排: ✅ Done · ⚠ Warning · ❌ Failed
• 常见 emoji 变体: ☀️ ❤️ ⭐️

<IMG>
12.2 Complex ZWJ sequences

观察复杂 ZWJ emoji 的边界表现:👨‍👩‍👧‍👦 👩🏽‍💻 🧑‍🚀

<IMG>
12.3 Bidirectional & mixed-script paragraph

正文仍然由终端自身字体渲染,所以这里主要用来对比标题图片化与正文文本化的表现差异。
Body text mixes 中文、English、ASCII punctuation, and emoji 🌍 within the same
line.

│ 引用块里也放几个字符:💡 🛠 📦

<IMG>
End

如果以上每一节都能正确(或按当前能力部分正确)渲染,termdown
的核心语法覆盖就达标了。
Expand Down
Loading