Anchor links in trip reports

Check here for updates to the forum and site.
Forum rules
  • This is a mountaineering forum, so please keep your posts on-topic. Posts do not all have to be related to the 14ers but should at least be mountaineering-related.
  • Personal attacks and confrontational behavior will result in removal from the forum at the discretion of the administrators.
  • Do not use this forum to advertise, sell photos or other products or promote a commercial website.
  • Troll posts will be removed.
For more details, please see the Terms of Use you agreed to when joining the forum.
Post Reply
User avatar
supranihilest
Posts: 728
Joined: 6/29/2015
14ers: 58  42 
13ers: 709 1 8
Trip Reports (114)
 
Contact:

Anchor links in trip reports

Post by supranihilest »

Hi Bill,

I'm trying to add anchors within a TR so I can create a table of contents: click the name of a month in the TOC, jump to that month in the TR. Tinymce strips out the anchors every time I place them, despite all kinds of confusing behavior to the contrary. Let me give you an example (if you wish, you can look at TR 18940, which isn't publicly available):

Code: Select all

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p><a href="#october">October</a></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lacus libero, sollicitudin at urna et, posuere volutpat augue. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris pharetra porttitor dui, eu placerat mauris porttitor eget. Maecenas placerat porta lectus id consectetur. Proin commodo purus sit amet felis malesuada, at porta felis tincidunt. Nulla blandit facilisis magna id mollis. Nullam ac nibh nulla. Duis consequat, libero sed accumsan luctus, tortor libero vehicula ex, nec condimentum mi ligula non magna. Vivamus egestas eleifend elit at mollis.</p>

[a few more paragraphs of junk here, stripped for the purpose of this post, but serves to allow the page to visually jump to the anchor]

<p>Pellentesque pellentesque venenatis facilisis. Maecenas ultrices libero at vehicula tincidunt. Donec magna arcu, molestie porttitor bibendum id, faucibus ut dolor. In et mattis turpis, non cursus urna. Praesent egestas condimentum suscipit. Duis finibus, magna id porttitor suscipit, dui ipsum vehicula augue, non tempor lacus tellus vitae risus. Suspendisse iaculis lectus in odio vulputate, vel hendrerit erat rutrum. Donec commodo nec libero ac luctus. Nunc fermentum nibh tellus, et molestie risus luctus ut. In venenatis neque non mattis tempus. Cras ornare fermentum nisi id maximus.</p>

<a name="october"></a><h1>October</h1>
</body>
</html>
The anchor in the third to last line gets stripped out, leaving just the header tag. Clicking the October link at the top does nothing. The link at the top does link to the #october anchor within the same page, but obviously goes nowhere since the anchor doesn't exist.

I am able to create an anchor, and Tinymce even puts in an anchor icon (see the image below) but then removes it when I save the TR.

Image

I have also attempted to give the header element its own ID, like

Code: Select all

<h1 id="october">October</h1>
as is possible in both HTML4 and HTML5 specification, but once again it is stripped out. I assume this is default behavior in Tinymce, though perhaps not intended by you as webmaster.

Even more strange, when I use the graphic editor to place a link, and click the "name" box a drop down menu appears where the October link is shown, (I have no idea why or where it got that from and now it won't go away, no matter what I do), as well as <top> and <bottom> (both of which make sense, and work as expected):

Image

If I click the "October" link in the drop down it then automatically sets itself to "#h_90554721421553211074647", which I'm not sure where it got that from (perhaps each link gets a unique ID inside the system?), proceeds to strip itself upon saving, and then magically changes back to "#october", an in-page link, when previewing the report.

Image

If I attempt to add an anchor on a line entirely by itself, such as:

Code: Select all

<a id="october"></a>
the editor even shows an "anchor" drop down menu on the graphical link editor!

Image

Alas, this still does nothing, and even more strange, the source code editor (which is where I'm adding <a id="october"></a> in the first place) immediately replaces the entire anchor with a non-breaking space on its own paragraph (<p>&nbsp;</p>), but the link editor dynamically adds the anchor drop down; that is, until I save the TR, upon which it is all simply converted into an empty paragraph.

I'm not sure what to make of all of that. Am I doing something wrong? Is using in-page anchoring something that should be possible? It would be very useful for multi-peak/multi-trip combined reports!
User avatar
BillMiddlebrook
Site Administrator
Posts: 6918
Joined: 7/25/2004
14ers: 58  46  19 
13ers: 172 44 37
Trip Reports (2)
 
Contact:

Re: Anchor links in trip reports

Post by BillMiddlebrook »

Wow, that's a lot of detail.

Well, I hadn't installed the TinyMCE "anchor" plug-in so I did that and it allows you to insert anchors and reference them from above but then, after some testing, I found that TinyMCE strips out the anchors still. I've done some research and there doesn't appear to be an easy fix right now.

I'll keep looking...
"When I go out, I become more alive. I just love skiing. The gravitational pull. When you ski steep terrain... you can almost get a feeling of flying." -Doug Coombs
User avatar
supranihilest
Posts: 728
Joined: 6/29/2015
14ers: 58  42 
13ers: 709 1 8
Trip Reports (114)
 
Contact:

Re: Anchor links in trip reports

Post by supranihilest »

BillMiddlebrook wrote: Fri Mar 22, 2019 8:32 am Wow, that's a lot of detail.
Haha, as a sys admin/IT infrastructure/security guy myself I like to provide as much detail as possible. That user that doesn't provide enough detail? That ain't me. :mrgreen:
Well, I hadn't installed the TinyMCE "anchor" plug-in so I did that and it allows you to insert anchors and reference them from above but then, after some testing, I found that TinyMCE strips out the anchors still. I've done some research and there doesn't appear to be an easy fix right now.

I'll keep looking...
If it's not an easy fix no worries, it's more of a nice-to-have than a need, obviously. Thank you for looking into it!
User avatar
BillMiddlebrook
Site Administrator
Posts: 6918
Joined: 7/25/2004
14ers: 58  46  19 
13ers: 172 44 37
Trip Reports (2)
 
Contact:

Re: Anchor links in trip reports

Post by BillMiddlebrook »

Ok, I think I got it working now. I added the Anchor plugin and it works as expected. But I had to change my sanitizing, save process to allow the IDs on the anchors.

Let me know if it works ok for you


THANKS
"When I go out, I become more alive. I just love skiing. The gravitational pull. When you ski steep terrain... you can almost get a feeling of flying." -Doug Coombs
User avatar
supranihilest
Posts: 728
Joined: 6/29/2015
14ers: 58  42 
13ers: 709 1 8
Trip Reports (114)
 
Contact:

Re: Anchor links in trip reports

Post by supranihilest »

Bill, you are a saint. Thanks for all you do. Anchoring now works, and if I can be picky and pedantic for juuuust one more moment... This isn't an issue that seems like it will have an easy fix on your end but can probably be fixed with creative anchor placement on the user's part, but when the page jumps to an anchor it is cut off by the floating site header. If I put the anchor a paragraph or two back it works better but still not perfect. Here's an example where the anchor goes at the very start of a header line:

Code: Select all

[Table of Contents]
<p>&nbsp;</p>
<a id="january"></a><h1>January</h1>
<p>Lorem ipsum spam/remainder of TR</p>
Image

If I put the anchor at the end of the previous paragraph, instead of at the header itself, and then place an empty line between it's better but still not perfect:

Code: Select all

[Table of Contents]
<p>&nbsp;</p>
<h1>January</h1>
<p>&nbsp;</p>
Lorem ipsum spam<a id="february"></a>
<p>&nbsp;</p>
<h1>February</h1>
<p>Lorem ipsum spam/remainder of TR</p>
Image

Again, not a huge deal and would probably be a pain to fix and not worth it, if it could be fixed at all; anchoring works, that's what counts. Mostly the point of this post is to document it and hope that someone stumbles upon it when they run into this tiny issue themselves. You may consider my issue resolved at this point. Thank you again for all the hard work - I and all the other users of the site appreciate the hell out of it.
User avatar
BillMiddlebrook
Site Administrator
Posts: 6918
Joined: 7/25/2004
14ers: 58  46  19 
13ers: 172 44 37
Trip Reports (2)
 
Contact:

Re: Anchor links in trip reports

Post by BillMiddlebrook »

It’s my pleasure. The reports are helpful to many people and if I can make the editing process easier to use, that means better reports.

I might be able to change the top scroll point (Y value), which would solve the problem. I’ll take a look...

Thanks again!
"When I go out, I become more alive. I just love skiing. The gravitational pull. When you ski steep terrain... you can almost get a feeling of flying." -Doug Coombs
Post Reply