HTML Table Of Contents Script

Table of Contents

 

The Problem with Building a Table of Contents in TDX

Need to build a table of contents for a KB Article?

It can be quite cumbersome to add anchors and hyperlinks between the table of contents and your headers.

This Script performs the hard work for you.

 

The script takes a list of headings, like this:

the problem with building a table of contents in tdx
the script
How to Run the Script to Generate a Table of Contents
 

And generates HTML code that can be pasted in an Article Source to create a Table of Contents and section Headings like this:

Article Source (HTML Code) Example
Article Body Example


 

Return to the Article Table of Contents above

 

The Script

Note: These scripts were written by SVC Employees. Be wary of running scripts found on the Internet Not written/reviewed by IT. If in doubt, Do Not Run Internet Scripts: have someone in IT who is familiar with the script language check it before you run it.

 

  • Attached Files: 
    • Attached files typically show in the Top Right of the KB article.
      • Smaller browser windows will move these to the very bottom of the article.
    • You can either View the file to copy it's contents directly from your web browser, or click the file name to download and open the file itself to copy it's contents.

 

Simplest Method for One Offs:

Copy and Paste

 

Use it frequently? Create a file on your desktop:

Save as a Batch File

 

Or Save it to your PowerShell Profile 

Save as a Function

 


 

Return to the Article Table of Contents above

How to Run the Script to Generate a Table of Contents

 

  1. Run the script via your preferred method
    • See above at The Script â€‹â€‹â€‹â€‹
    • Copy and Paste Method: Paste Code directly into PowerShell
    • Batch File Method: Double Click the batch file on your desktop
    • Function Method: Open PowerShell and type ConvertTo-HTMLTableOfContents 
      1. You can tab twice after HTML to complete the command
  2. Confirm if the copied text is what you want to process. 
    1. If not:
      1. Copy your list to your computer clipboard
      2. Type No in the PowerShell prompt and press enter on your keyboard to recheck your clipboard.
    2. Once confirmed that you have the correct list copied, type Yes in the PowerShell prompt and press enter.
  3. The HTML is automatically copied to your clipboard. 

 

  1. Click the Source button to toggle Source View ON in the TDX KB article
  2. Paste the HTML Code into the Code editor.
  3. Click the Source button again to toggle Source View Off and return to the article body.
  4. Indent any Table of Contents as required.

 

 

Pro Tip: You can use this to Add to a Table of Contents
Pro Tip: Sub-Table of Contents within Section Headings

 

Return to the Article Table of Contents above

 

Details

Article ID: 146246
Created
Mon 8/29/22 2:21 PM
Modified
Thu 9/1/22 11:50 AM