Comments (14)
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:
### <a name="implementation"></a>Implementation
and then link to it using the syntax:
[Implementation](data_structures/segment_tree.html#implementation)
But that seems pretty dirty and you really have to link the full file path, something like [Implementation](#implementation)
doesn't work.
from cp-algorithms.
Hm-m-m...
doesn't work.
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...
from cp-algorithms.
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:
### Implementation ### {#implem}
...
[go to Implementation](#implem)
from cp-algorithms.
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:
-
What is the proper syntax to refer to anchor link from a different article (to a different page)? I assume
[link name](data_structures/segment_tree.html#implementation)
as with other cross-page links? -
I suspect that on e-maxx.ru the table of contents is generated automatically. How hard is it to add such a feature to our pages? It would be nice to do something like this: gather all headers in the page, generate anchor links for them (for example, from the header text - we could have autogenerated links #implementation, #algorithm, #practice-problems etc.) and put these links together in a table of contents at the beginning of the article.
from cp-algorithms.
- Yes, that works.
- I also want that feature. Btw, on e-maxx.ru the anchors are
#0
,#1
, ..., but obviously I would prefer unique, short, appreciated title names.
from cp-algorithms.
Changed the label, because the main point of this issue is about generating a table of context for each article.
from cp-algorithms.
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).
from cp-algorithms.
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.
from cp-algorithms.
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:
<h1 data-toc="off">E-Maxx Algorithms in English</h1>
instead of simply
# E-Maxx Algorithms in English
Please have a look and tell whether it works and how it may need be improved...
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 hope they would be replaced by autogenerated ones :) Though we still shall need to remove tables of contents where they are already...
from cp-algorithms.
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...
from cp-algorithms.
Looks good.
from cp-algorithms.
A few improvement suggestions:
- Right now the font size of the table of contents is the same size as the font in the main part of the article; I would make it a little smaller to make is visually more distinct from the main text.
- Use different unordered list markers for 2nd and 3rd level titles to make them more distinct from each other (same as e-maxx.ru does).
- It would be really nice to use more descriptive names for autogenerated anchors, in case people want to link to them from other articles or from external sites. Something like split the title into words, convert them to lowercase, concatenate them with dashes as separators?
from cp-algorithms.
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:
- article may have several identical subheaders
- anchors will change when title wording/spelling is changed
- it would be better to generate them on server-side (if any link exists to them from anywhere besides table of contents) so no crawler may think it is a broken link
So it would be better for now to mark chosen subheaders with short and descriptive anchors manually...
from cp-algorithms.
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.
from cp-algorithms.
Related Issues (20)
- Problem on article "Stars and bars": Positive integers case HOT 1
- Number of upper-bound integer sums HOT 4
- Article for probability basics and expected value HOT 1
- Inclusion-Exclusion union bound / Bonferroni inequalities HOT 4
- Want to add Floyd Warshall Algorithm in Dynamic Programming HOT 4
- Problem on article "Dijkstra on sparse graphs"
- Problem on article "Dijkstra on sparse graphs" HOT 2
- Sort Practice Problems in order of difficulty and add some easy medium and hard tags HOT 3
- Article for surreal numbers and combinatorial games HOT 2
- Unnecessary Scrollbars with Math Latex Expressions HOT 3
- Need to make editing and adding articles easier HOT 8
- typo in kth order statistic HOT 7
- Variable Mixed Up in Knuth's Optimization lemma proof
- Problem on article "Finding a Negative Cycle in the Graph"
- The problem is no more accessible
- Typo in Minkowski sum of convex polygons HOT 1
- Problem on article "Longest increasing subsequence"
- Can I publish a Vietnamese translated version of cp-algorithms? HOT 1
- Raw code getting rendered on main page HOT 1
- Clarification Needed: Ambiguity in Article's Usage of "Map" Data Structure HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cp-algorithms.