-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Table of contents #211
Comments
In general I would be nice to be able to link to different sections of the article easily. In my Segment Tree article I made such references by creating a name for each relevant section:
and then link to it using the syntax:
But that seems pretty dirty and you really have to link the full file path, something like |
Hm-m-m...
I think this means not "doesn't work" but, "leads to wrong (main) page"? I'm trying to test this now - it seems to be due to using "base" in the html-template. If so, I'll try to see for workaround in the morning... |
I hope this is fixed (I added the code which adds page relative address to anchor links after processing markdown)... I've tried to change anchor in the "Segment Tree Article" to see if it works. Feel free to tell if I'm wrong. Also I have noted there is syntax for naming headers:
|
Neat syntax! The anchor in segment tree works, when I have time I'll look through other articles to add anchored links to places which refer to a specific part of the article. @RodionGork Two questions about this:
|
|
Changed the label, because the main point of this issue is about generating a table of context for each article. |
Well, perhaps we can really make this autogenerated (when expanding templates from markdown)... Like gathering all the 2-nd and 3-rd level titles and inserting the table under the 1-st level title... Or in the place specially marked? Will this be good? Or yet another approach - we can do this in javascript also (I believe it may be simpler). |
Gathering all the 2-nd and 3-rd level titles and inserting the resulting table under the 1-st level title sounds like a plan. We just need to make sure anchor links are autogenerated properly if the 2-nd or 3-rd level title has a manual anchor link written for it in Markdown. |
I've just attempted to implement this. Though on javascript side (e.g. after user loads it in browser, small table of content should be inserted at once) - mainly because I've found it painful to manage html elements on the server side. It looks like working for me, though I found it necessary to add special tag to header on the main page (as here table of contents looks ridiculous). The same should be done wherever it is not needed:
instead of simply
Please have a look and tell whether it works and how it may need be improved...
I hope they would be replaced by autogenerated ones :) Though we still shall need to remove tables of contents where they are already... |
Ah, damn... I now got what you've meant. It is wrong to substitute them with autogenerated anchors, for it breaks other links. I'll fix this bit later. UPD now should be better. thanks for this hint! Tested on "segment tree" article... |
Looks good. |
A few improvement suggestions:
|
I've made style changes as you proposed. Not sure we really want making text as small as at original e-maxx, for the sake of people who may use phone or tablet to view the site (it seems we have almost 20% of them now). (browser may need to update cached css to reflect this) As for descriptive names :) The matter seems a bit more tricky... And I'm a bit hesitant and lazy to rush on such improvement right now:
So it would be better for now to mark chosen subheaders with short and descriptive anchors manually... |
I like how the table of contents looks, not too small and not too large, just right :-) Anchors will also change with the current approach - if, say, a header is removed or added before the header to which a link leads. It would be nice to do something unified about it, but the current approach will work for now. |
On e-maxx.ru most pages contains table of contents at the beginning. Perhaps it also should be added here.
The text was updated successfully, but these errors were encountered: