Remove anchor ID from TOC entries

Anchor numbers (referenced as <a name="239043"...) are used throughout your output in most formats. They function as destination markers for links and cross-references. Without them, these links just open the requested document and show the top of the file, whereas a link that includes the anchor name would (in most browsers) scroll to the appropriate paragraph.

Sometimes, though, it's desirable to remove the anchor reference on some links. For example, one user implemented context-sensitive help with the Microsoft HTML Help format by using HTML file names instead of map IDs. Because the CHM table of contents contains references to the anchor name for each entry, the TOC was not synchronized when only a file name was called.

In this instance, the solution was to remove the XSL code which adds the link anchor to the TOC entry. To repeat this solution, follow these steps:

  • Perform an override on a file called toc.xsl, located by default in the ePublisher Pro installation directory, here:
    • ePublisher Pro/Formats/Microsoft HTML Help 1.x/Transforms/
  • When you have copied the file into your project directory, open it with a text editor, such as NotePad.

  • Locate this bit of code:
    • <xsl:variable name="VarLink"> <xsl:value-of select="$VarRelativeLinkPath" /> <xsl:text>#</xsl:text> <xsl:value-of select="$VarEntry/@linkid" />

    • </xsl:variable>

  • That variable builds the link for each TOC entry. It uses a relative path to the HTML file, and then adds the # symbol, along with the "linkid" attribute for the referenced paragraph. For this override, we want to remove that last bit. So, delete the corresponding lines, so that the variable now reads:
  • Save toc.xsl and regenerate your output to apply the changes.

This modification can be applied in other areas, and in other formats. Anywhere you see the # sign added to a variable, along with the linkid attribute, it means the anchor name of a referenced paragraph is being added to the link to that topic file. The most common locations are in toc.xsl and content.xsl. Search for "linkid," and you should find most of the instances where this syntax is used, should you need to modify i


Permalinks/Solutions/Output/CHM/RemoveAnchorID (last edited 2009-05-01 21:47:16 by LaurenLever)