markdown-it / markdown-it/markdown-it
Header anchors [needs discussion]
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 21.9k
- Forks
- 1.8k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 1
Description
It's very popular request to add header ancors. Prior to do it, we need to discuss possible security problems and solutions.
Read first
- https://github.com/jch/html-pipeline/pull/111#issuecomment-34369984 - discussion about github implementation
- http://www.slideshare.net/x00mario/in-the-dom-no-one-will-hear-you-scream - awesome presentation about dom clobbering
Problems:
id- collisionsname- dom clobbering- cross-conflicts when multiple docs on the same page have the same headers
Possible solutions
- Do nothing
- unsafe, you need to control content, or site will be vulnerable
- Add prefix
- will require js to keep references work
- without js will make manual references typing not convenient
- does anyone type such way?
- not a problem for autogenerated tocs (we can add prefix to both anchors and refs)
- Add per-doc unique prefix
- not convenient in use. required in very limited cases
Need to discuss better solutions, and what to do by default, because anchors are really needed
current status
- Must have not empty default prefix
options.anchorPrefix- instance default.env.anchorPrefix- every-time-render override
- Open questions:
- default prefix name?
-or--of no objections (short and easy to type)
- should we autofix local relative anchor links? any bad side effects?
- default prefix name?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked html-pipeline discussion and the DOM clobbering presentation, then review the proposed anchorPrefix options and open questions in this issue. Done means reaching a decision on the safe default behavior, prefix naming, and whether local relative anchor links should be adjusted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- security, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100