TableOfContents-Talk

Please add new sections below this line.


Invalid XHTML

I noticed that since I activated the table of contents my pmwiki pages are no longer valid XHTML (checked via https://validator.w3.org). The errors that I get are like this one here:

there is no attribute "data-pmtoc" You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element.

As soon as I disable it again the pages become valid XHTML again.

The pmwiki-utils.js configuration for many core JavaScript functions ($PmTOC, LocalTimes, PmSyntax, WikiStyles#highlight, Sortable tables, $EnableCopyCode, ToggleNext, GuiButtons) is passed via data-* attributes, and indeed these attributes may not be valid in older (X)HTML standards. If the HTML validation, and any of these features is important for you, you can either enable a more recent HTML standard like "HTML5" for your skin, or install a recipe from the cookbook. There are recipes for most of these features, like several Tables of content. --Petko

Custom styles

I can't figure out how to create custom CSS for the table of contents to make it appear differently on a dark-mode skin. I want the boarder, background and text to have a distinct color on my custom skin. (It'd also be nice to figure out how to do so for the inline block box thingies, which appear to use the same CSS as far as i can tell) CharlieCC?

You can style the .frame and .PmTOCdiv a elements:

.frame {
  border: 1px solid #555;
  background-color: #222;
}
.PmTOCdiv a {
  color: yellow;
}

The .frame definition will apply to other elements with the frame CSS class, for example in the documentation or in the edit form. --Petko

Recent update

This seems to be broken on Vector skin, my last pmwiki update was 2.2.133 and now updated to 2.3.12 and it broke, it shows the header but the content is missing. I noticed a lot of the toc code moved into new files. AutoTOC works but lacks some of the features I like from this one such as limiting the max height, giving a scroll bar, backlinks, and roman numeral option. Thanks. --Naturevault

It works here with the Vector skin, so it is probably something else. When you upgrade, make sure you update all files in pmwiki/scripts/, especially stdmarkup.php and utils.php (new file), and the file pmwiki/pub/drt-utils.js. --Petko

How to disable pmwiki-utils.js script tag from a local PHP page?

Is there a maintainable way to disable adding the script tag for pmwiki-util.js in HTMLFooter? I would like to disable such script tag in a few local/Group.Page.php files while generally keeping it enabled for all other pages in local/config.php.

File scripts/stdmarkup.php adds pmwiki-utils.js based on a fairly long conditional expression. Consequently, to disable the script tag from a local PHP page, without prior knowledge of which core features are enabled, I should set:

$PmTOC['Enable'] = $PmEmbed = $EnableSortable = $EnableHighlight = $ToggleNextSelector = 0;
unset($LinkFunctions['mailto:']);

That works but it isn't easily maintainable; I worry that, on a future pmwiki version upgrade, I could forget to check if the conditional expression in stdmarkup.php has changed and change Group.Page.php accordingly. Is there, or could it be added, a better alternative to the above code? Thank you. SteP November 08, 2020, at 01:31 PM

Add the following in Group.Page.php: --Petko November 08, 2020, at 01:38 PM

  function DisablePmUtils(){
    global  $HTMLFooterFmt; 
    $HTMLFooterFmt['pmwiki-utils'] = '';
  }
  $PostConfig['DisablePmUtils'] = 900;

Thank you, Petko, it works well. SteP November 08, 2020, at 09:25 PM

From PmWiki 2.3.2, the utility library will be included in the header, not footer, and there is a new variable that makes it simpler to disable it. Use $EnablePmUtils = 0; in config.php instead of the above function. --Petko

Does $EnablePmUtils = 0; need to be inside config.php or can it be inside a local PHP page instead? SteP

This is a PHP variable, it needs to be in a PHP file, either pmwiki/local/farmconfig.php for a WikiFarm, or local/config.php for the one full wiki, or local/Group.php for a group, or local/Group.Page.php for one page only. --Petko


This is a talk page for improving PmWiki.TableOfContents.