Skip to content

Change named headers into subtle links to themselves #497

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

Merged
merged 1 commit into from
Mar 16, 2014

Conversation

JakobOvrum
Copy link
Member

Many sections in the language reference have page anchors, but to know the anchor name one has to look in the source code, effectively rendering them useless.

This change makes these headers links to themselves, so people can easily share links to specific parts of a page.

The links have subtle styling. When not hovering over one, it looks like any other header. Hover over it, and it gets an underline and a pilcrow/paragraph symbol after it.

@JakobOvrum
Copy link
Member Author

Fixed issue where $(GNAME ...) would be affected by the change.

@@ -156,6 +156,24 @@ a:visited
color: #606;
}

a.anchor
{
color: rgb(102, 51, 51);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing the color?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regular links should be left unchanged, but these anchor links should look like regular headers unless hovered. It's common practice for this kind of feature. Leaving it as the default link color would not only change the colour design of the site, but headers with and without anchor names would have different colouring (which looks rather arbitrary).

I'll add a comment.

@MartinNowak
Copy link
Member

Nice, I hope that the increased visibility of anchors will help to add more of them.

@JakobOvrum
Copy link
Member Author

Commented the style. Please have a look and see if you agree with those decisions.

@brad-anderson
Copy link
Member

The regular header color with a ¶ is pretty common. See Python's docs. Looks like Node.js uses a # instead but is basically the same (no hover required though). I'd prefer them not stand out compared to other headers because it could just be confusing to some users why some headers are different colors than others (when the color difference means nothing about the content).

@JakobOvrum
Copy link
Member Author

Looking at the Python docs, it looks like they use JavaScript to trigger the visibility of the pilcrow instead of :hover, which allows them to limit the bounds of the link to just the pilcrow symbol. Our JavaScript situation is a bit messy and to avoid a <noscript> path, I think the :hover solution is good for now. However, I liked their idea of having a nice title attribute; pushed that just now.

As for Node.js' permanently visible links; it would probably look a little weird on dlang.org since it's kind of arbitrary which headers have anchors. Or maybe that would be a good thing? ;)

@JakobOvrum
Copy link
Member Author

@9rnsr, what do you think about this?

@9rnsr
Copy link
Contributor

9rnsr commented Feb 15, 2014

The idea is definitely good. For style issue, I have no opinion.

On the other hand, I have one logical issue - each current anchors are not considered to be displayed (they are internal links just for cross reference). So their name styles are random. For example:

Hyphenate vs underbar:
http://dlang.org/arrays#static-arrays
http://dlang.org/statement#foreach_with_ranges

Singular vs plural:
http://dlang.org/template#alias-template
http://dlang.org/template#function-templates

Section anchor conflicts with the grammar which has same name:
http://dlang.org/expression#Expression

So we need to unify the name styles before publishing them by this change.

@JakobOvrum
Copy link
Member Author

So we need to unify the name styles before publishing them by this change.

You think it's OK to change them one last time? I personally agree we should do that, but I wouldn't be surprised if some people didn't... link breakage is serious, but these links were nigh unobtainable in the first place. I think I'll raise the issue on the NewsGroup.

edit:

http://forum.dlang.org/post/srqvufwxkqguaijwgnuo@forum.dlang.org

@ghost
Copy link

ghost commented Feb 15, 2014

Is it possible to set up automatic redirects? E.g. http://dlang.org/template#function-templates redirects to http://dlang.org/template#function-template.

If the answer is yes this would also help out in factoring out the changelog into multiple pages without breaking existing links.

@andralex
Copy link
Member

ready to merge?

@andralex
Copy link
Member

guess I just will

andralex added a commit that referenced this pull request Mar 16, 2014
Change named headers into subtle links to themselves
@andralex andralex merged commit 3772785 into dlang:master Mar 16, 2014
@JakobOvrum
Copy link
Member Author

No, this was in fact not ready to merge:

So we need to unify the name styles before publishing them by this change.

I was still working on that (actually working on trying to rebase your giant DDoc PR before adding yet more points of breakage).

JakobOvrum pushed a commit to JakobOvrum/dlang.org that referenced this pull request Mar 16, 2014
…to themselves"

PR dlang#497 was merged prematurely.

This reverts commit d1dd941.
@JakobOvrum
Copy link
Member Author

I'll open this again after unifying the anchor names.

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.

5 participants