Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support anchors in SUMMARY #1173

Merged
merged 3 commits into from
Mar 24, 2020
Merged

Support anchors in SUMMARY #1173

merged 3 commits into from
Mar 24, 2020

Conversation

mcarton
Copy link
Member

@mcarton mcarton commented Mar 22, 2020

While porting a book of mine from GitBook to mdBook, I noticed that anchors are not supported in the SUMMARY file:

For example, given the following summary:

- [Foo](Foo.md)
    - [Subfoo 1](Foo.md#anchor-1)
    - [Subfoo 2](Foo.md#anchor-2)
- [Bar](Bar.md)

The following wrong things are going to happen when running mdbook build:

  • Files doc/Foo#anchor-1.md and doc/Foo#anchor-2.md are going to be created.
  • The navigation panel will only ever highlight "Subfoo 2" whether you click on "Foo", "Subfoo 1" or "Subfoo 2".
  • The navigation arrows don't work: the left arrow can't go back, the right arrow points to the last sub-section.
  • All 3 links in the Foo section point to Foo.html, which is empty.

@Dylan-DPC-zz Dylan-DPC-zz merged commit 2baed04 into rust-lang:master Mar 24, 2020
@ehuss
Copy link
Contributor

ehuss commented Mar 24, 2020

@Dylan-DPC I think it would be good to have some discussion before merging big changes like this. Some issues:

@mcarton mcarton deleted the anchors branch March 24, 2020 21:55
@mcarton
Copy link
Member Author

mcarton commented Mar 24, 2020

Don't hesitate to revert this if it causes any issue, however:

This is a pretty fundamental change to how mdbook previously assumed every chapter is a separate file. I suspect it will have large ramifications, and will break external tools.

It shouldn't break any existing book though, because files with anchors are completely broken now.

This seems to be broken for focus on the side-bar. It seems to always focus the last element.

This is incorrect: it always focuses the main section, eg. for my book it will display as

image

even if you click on the Debug.md#format-with link. This is IMO a good thing. To focus the right sub-section would need CSS or JS magic AFAIK.

@Dylan-DPC-zz
Copy link

@ehuss ah my bad didnt see the issue.

Dylan-DPC-zz pushed a commit that referenced this pull request Mar 24, 2020
@Dylan-DPC-zz
Copy link

reverted in #1175

Dylan-DPC-zz pushed a commit that referenced this pull request Mar 24, 2020
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
* Parse anchors in `SUMMARY.md`

* Support sub-links in SUMMARY with html renderer

* Add some tests for anchors
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
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.

3 participants