[Feature] TOC for GitHub wiki pages

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
cli

Research direction

Read the README section on “Remote files” and trace how remote URLs are routed between remotehtml and remotemd. Then inspect the existing HTML extraction path and its tests, if present, to identify how wiki page URLs can produce a TOC and how multi-input links are prefixed. Done means the supplied GitHub wiki URL yields the requested headings and links.

Written by the indexing model from the issue text.

Description

enhancement

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

The Bash version builds a TOC for a GitHub wiki page by its URL (see "Remote files" in its
README). Here such a URL fails:

$ gh-md-toc https://github.com/ekalinin/nodeenv/wiki/Who-Uses-Nodeenv
process "https://github.com/ekalinin/nodeenv/wiki/Who-Uses-Nodeenv": get remote HTML "https://github.com/ekalinin/nodeenv/wiki/Who-Uses-Nodeenv": unexpected content type "text/html; charset=utf-8"

Every URL outside githubusercontent.com goes to remotehtml, which asks for JSON and
reads the TOC from the payload that GitHub embeds in blob pages. A wiki page is served as
HTML only.

Describe the solution you'd like

A wiki page URL (https://github.com/<owner>/<repo>/wiki/<page>) gives a TOC, as in the
Bash version:

* [Who Uses Nodeenv?](#who-uses-nodeenv)
  * [edx](#edx)
  * [OpenStack](#openstack)
  ...

With several inputs, the links are prefixed with the page URL, as for other remote pages.

Describe alternatives you've considered

The raw Markdown of a wiki page already works, through the remotemd path:

gh-md-toc https://raw.githubusercontent.com/wiki/ekalinin/nodeenv/Who-Uses-Nodeenv.md

Additional context

Possible ways to support it: rewrite a wiki URL to its raw.githubusercontent.com/wiki/...
form, or extract the headings from a text/html answer with RegexpExtractor, as the
Bash version does with the page HTML.

Dominant language
Go
Stars
525
Forks
89
Avg merge
6m
Merged PRs (30d)
1

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ekalinin/github-markdown-toc.go

All issues in ekalinin/github-markdown-toc.go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.