feat: add --with-content and --with-links flags
- Add GetNodeLinks method to retrieve wikilink targets
- Extend SearchResult with Content and Links fields (omitempty)
- Add WithContent and WithLinks to SearchOptions
- Update output formatters to display content and links
- Performance: 8ms for 10 results with content+links
- All tests passing
| | |
| | | title = title[:18] + ".." |
| | | } |
| | | sb.WriteString(fmt.Sprintf("%-50s %-20s %-8s %d\n", r.Path, title, r.Section, r.Score)) |
| | | |
| | | // 输出内容(如果有) |
| | | if r.Content != "" { |
| | | sb.WriteString("\n--- 内容 ---\n") |
| | | sb.WriteString(r.Content) |
| | | sb.WriteString("\n") |
| | | } |
| | | |
| | | // 输出关联文档(如果有) |
| | | if len(r.Links) > 0 { |
| | | sb.WriteString("\n--- 关联文档 ---\n") |
| | | for _, link := range r.Links { |
| | | sb.WriteString(fmt.Sprintf("- %s\n", link)) |
| | | } |
| | | } |
| | | } |
| | | |
| | | sb.WriteString(fmt.Sprintf("\n共 %d 条结果\n", len(results))) |