[Feature] Bullet character: --bullet *|-|+

未关闭
#94 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
76/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
cli

调研方向

Start with flag handling in cmd/gh-md-toc/config.go, then follow the configuration into coretoc.Config and Renderer.Render in internal/core/toc/renderer.go. Check the existing flag and renderer tests, and README.md for documentation conventions. Done means --bullet accepts *, - or + across the stated input modes, rejects invalid combinations, and keeps the default output unchanged.

由索引模型根据 Issue 内容生成。

描述

enhancement

Is your feature request related to a problem? Please describe.

Every TOC entry starts with *, and there is no way to use another bullet, for example
a dash. The marker is hardcoded in internal/core/toc/renderer.go
(indent+"* ["+text+"]("+link+")"). The same request for the Bash version is
ekalinin/github-markdown-toc#71, and it is implemented there in
ekalinin/github-markdown-toc#182.

Describe the solution you'd like

The same option as in the Bash version: --bullet <CHAR> with *, - or + (the
three bullet markers of CommonMark), which starts every entry with that character:

- [Title one](#title-one)
  - [Section](#section)
- [Title two](#title-two)

Behavior in the Bash version:

  • The default stays *, so without --bullet the output does not change.
  • The bullet applies to stdin, local files, remote URLs, several inputs and --insert.
  • An unknown character is an error with exit code 1, before any network call.
  • --bullet with --numbered list is an error: an ordered list has no bullet.
    With --numbered outline the bullet replaces *: - [2.1. Section](#section).

Describe alternatives you've considered

  • Replace the marker after generation:
    gh-md-toc README.md | sed 's/^\( *\)\* \[/\1- [/'. It does not work with
    --insert, which writes the TOC into the file directly.

Additional context

  • --numbered is not implemented here yet (#92). The two --numbered rules above apply
    to whichever of the two options lands second.
  • Places to change, as for the other flags: the flag in cmd/gh-md-toc/config.go, a new
    field in coretoc.Config (default *), and the marker in Renderer.Render. Plus
    tests and README.md.
主要语言
Go
星标
525
派生
89
平均合并
6 分钟
30 天内合并 PR
1

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ekalinin/github-markdown-toc.go 的其他 Issue

查看 ekalinin/github-markdown-toc.go 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。