TOC in div with id?
Flying Drupalist - January 1, 2009 - 23:56
| Project: | Table of Contents |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | critical |
| Assigned: | AlexisWilke |
| Status: | needs review |
Description
I can't seem to find any way to style the TOC because it's not wrapped in anything. Please give it a id.

#1
Oh, I apologize I see what's going on. There is a div but the HTML filter rips it out. Is there a way to use TOC with HTML filter? It rips out the comment if it put it before, and rips out the div if I put it after... :(
#2
It's actually a core bug (mentioned in the README as well). I reported it nearly a year ago, and it turns out it affects quite a few modules: http://drupal.org/node/222926
If you have the time, your best bet is to work on creating tests for the filter module so that a patch can be hammered out and rolled into core.
#3
#4
I understand, I didn't realize that HTML Filter and HTML Corrector were the same thing. Thanks.
#5
Actually, they aren't the same thing. There is a bug with HTML Corrector (contrib module for D5, in core for D6).
The expected order is that the HTML filter comes first. On the site that I'm using this for, with an earlier version, it works as expected, but something looks to have broken in the -dev versions when the HTML filter is enabled. I'll investigate this further.
#6
Ok, I found what happened. In Drupal 5.6, there was a security fix due to an issue in IE6: http://drupal.org/node/208564
I missed the note that this would affect input filters :). Also, on my test site, it turned out I had a module enabled which was escaping brackets for me.
Now that I know what's going on, a fix should be soon. I imagine this effects just about every user of this module.
#7
Terrific, thank you. Would be happy to use this. :)
#8
Here are patches for both versions. Could you please test this and let me know if it works for you?
I used http://drupal.org/node/209715 as my guide for this patch.
#9
Marking as critical as it means that most users likely have disabled the HTML filter if they're using this module.
#10
Works like a charm. Thank you.
#11
deviantintegral,
Would you mind to actually add the code that changes the square brackets in the 2nd part? (in the handling of the teaser)
Where you say:
<?php+ // We can leave the angle brackets here as this occurs before content
+ // filtering.
?>
That way, using the [tableofcontents-toc] tag would work perfectly! At this time, that part is broken for the tag.
I would propose:
<?phpif($node->teaser) {
$new_teaser = preg_replace(array('!<\!-- *tableofcontents(.*)-->!', '!\[tableofcontents-toc](.*)\[/tableofcontents-toc]!'), array('', ''), $node->teaser));
if ($node->teaser != $new_teaser) {
...
?>
(And yes, I'm suggesting that you set $new_teaser outside of the if() which is cleaner code)
Also in the replace, you probably want to use * instead of ?.
<?php+ // Replace angle brackets as per #209715
- $text = preg_replace('!<\!-- ?tableofcontents(.*)-->!', '[tableofcontents-toc]$1[/tableofcontents-toc]', $text);
+ $text = preg_replace('!<\!-- *tableofcontents(.*)-->!', '[tableofcontents-toc]$1[/tableofcontents-toc]', $text);
?>
Thank you.
Alexis Wilke
#12
Is the patch by deviantintegral mentioned in #8 been applied to 6.x-2.3?
#13
lvl1,
No. I will put it in 3.x-dev for now.
And I will change the name of the tag to just 'toc'.
[toc <em>params</em>]to be more in line with most of the other tags in Drupal.
There will be backward support, of course.
Thank you.
Alexis
#14
I implemented a partial fix in 3.x-dev (to be posted soon).
It includes support for [toc ...] instead of <-- tableofcontents ... -->, although the comment is still supported, the 'prepare' action will transform it to the toc tag.
What is not yet fixed is the implementation of the teaser. That will be required!
Feel free to report problems in link with the PEAR wiki thingy you mention here. (outside of the teaser problem)
Thank you.
Alexis Wilke
#15
This is done in 3.x-dev, Jul 5, 2009.
Note that I did not fix version 5.x... and I don't think the previous author did apply the fix yet, which is why this is still open.
Thank you.
Alexis Wilke