Skip to content

feat(preview): click to expand truncated YAML frontmatter values#28

Merged
delphinus merged 1 commit into
mainfrom
feat/frontmatter-expand
Jul 8, 2026
Merged

feat(preview): click to expand truncated YAML frontmatter values#28
delphinus merged 1 commit into
mainfrom
feat/frontmatter-expand

Conversation

@delphinus

Copy link
Copy Markdown
Owner

概要

Obsidian ノート等のプレビューで、YAML フロントマターの横幅を越えた値は で省略表示されますが、テーブルのセルと違ってクリックしても展開できませんでした。テーブルと同じ操作で展開できるようにします。

Before:

```yaml
hoge: あいうえおかきく…
```

クリック / `za` / `` で After:

```yaml
hoge: あいうえおかきく
けこ
```

実装

  • 折り返し省略された各エントリを `expandable_regions` として登録し、既存の `expand_state` / `block_id` 機構と共通のクリック / `za` / `` ハンドラでトグルできるようにした (テーブルのセル展開と同じ経路)。
  • 展開時は値を `wrap_words` (CJK・禁則処理対応) で折り返し、継続行を値の開始桁 (`key: ` の直後) にインデント揃え。
  • フロントマターの `block_id` は負数を採番し、テーブルの展開 ID (正のソース行番号) と衝突しないようにした。パースは決定的なので rebuild をまたいでも展開状態は各エントリに保持される。
  • 値内に URL がある場合はクリックで展開ではなくリンクを開く、という既存の優先順位もそのまま。

テスト

  • 新規 `tests/frontmatter_test.lua` (21 アサーション): 省略表示・展開時の折り返しとインデント揃え・元の値の復元・複数エントリの ID 一意性を確認。
  • 既存スイートに回帰なし (toggle 149 / key_toggle 18 ほか全て green)。stylua / luacheck も pass。

🤖 Generated with Claude Code

Long frontmatter values were truncated with "…" but, unlike table cells,
could not be expanded. Register each overflowing entry as an expandable
region so a click / za / <CR> toggles it, reusing the existing
expandable_regions / expand_state / block_id machinery.

When expanded, the value is wrapped with wrap_words (CJK / kinsoku aware)
and continuation lines are indented to align under the value column, e.g.

  hoge: あいうえおかきく
        けこ

Frontmatter block ids are negative so they never collide with table
expand ids, which are positive source line numbers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@delphinus
delphinus merged commit 56057d9 into main Jul 8, 2026
8 checks passed
@delphinus
delphinus deleted the feat/frontmatter-expand branch July 8, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant