I noticed that my theme added a blank line where the "top" anchor was placed. I fixed this by giving it its own div in line 200.

So, I changed:

  $output = '<a name="top"></a>';

to:

  $output = '<div class="toc-filter-top-link"><a name="top"></a></div>';

This solved the problem nicely. I didn't need to do anything in CSS, but I did add a "div.toc-filter-top-link {}" line to my theme's css for completeness.

Thanks for the great and simple module - I certainly appreciate it!

Comments

shadlaws’s picture

jrockowitz’s picture

To keep it simple, I changed

<a name="top"></a>
- to -
<a name="top" class="toc-filter-top"></a>

And added the below css.
a.toc-filter-top {
display: none;
}

This should insure the #top anchor is never rendered.

WOW... for being a member of Drupal.org for only 9 hrs you already have 2 commits attributed to you.

shadlaws’s picture

Wow, thanks for the quick reply!

I tested the newest dev code, but the same problem occurred. If I inspect the element in Chrome, I can see that the display:none CSS line is indeed rendered, but it shows an extra <p>...</p> around the anchor. However, if I put it into a div, this goes away.

Thanks!

jrockowitz’s picture

Oh, you need to sort/arrange your input filters so that the 'Convert line breaks into HTML' filter, which is adding the p tags, comes before the 'TOC filter'

shadlaws’s picture

Good thought, but I'd already done that. Here's my filter order:

- TOC
- Replace tokens
- Convert URLs into links
- Convert line breaks into HTML
- Correct faulty and chopped off HTML

In trying to debug this, I thought of something perhaps fairly obvious: is this due to my WYSIWYG editor? To see, I looked at the plain text version of the source, and found this at the top:

<p>[toc]</p><h3>Foo bar</h3>

Hmm...

jrockowitz’s picture

You ordering should be....

- Replace tokens
- Convert URLs into links
- Convert line breaks into HTML
- Correct faulty and chopped off HTML
- TOC

shadlaws’s picture

Hmm... somehow I'd read your previous comment and interpreted the exact opposite of what you wrote. What an idiot. Sorry about that!

I moved it after line breaks (but before faulty and chopped HTML) and you were right - it's all fixed. Thanks!

shadlaws’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Closed (fixed)
shadlaws’s picture

Issue summary: View changes

Code block formatting corrected.