chmhtml-help-workshop

CHM external link with ampersand


I'm building a CHM file with many external links. The links are in the Index.hhk and are supposed to display the external page in the CHM help.

All the links are something like this: http://dle.rae.es/srv/search?m=30&w=casa

As you see the path has the symbol & in it, and apparently CHM cannot handle it. All the links are cut down to " http://dle.rae.es/srv/search?m=30? " by HTML Help Workshop.

Is there a way to fix this?

I tried with %26, but it doesn't work.


Solution

  • This is a bit complicated and is related to the behavior of the HTMLHelp Workshop. Please remember, HTMLHelp (CHM's) is nearly 20 years old and Microsoft's Windows based help system is in "maintenance mode" only. Some characters are handled in a special way and this leads to problems especially with file names.

    So, e.g. a hash (#) is a registered character which is used for hyperlinks. This character can not be used (as well as "?","&" and "+" characters). All those have special meaning.

    We should address your problem now and a solution for your index.hhk and HTMLHelp Workshop. You may know the index.hhk file is a text file (old sitemap format) and can be edited by a plain text editor like NotePad++

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    <HTML>
    <HEAD>
    <meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
    <!-- Sitemap 1.0 -->
    </HEAD><BODY>
    <OBJECT type="text/site properties">
        <param name="WindowName" value="StackOverflow">
    </OBJECT>
    <UL>
        <LI> <OBJECT type="text/sitemap">
            <param name="Name" value="Ampersand-casa">
            <param name="Local" value="http://dle.rae.es/srv/search?m=30&amp;w=casa">
            </OBJECT>
                <LI> <OBJECT type="text/sitemap">
            <param name="Name" value="Ampersand-cerveza">
            <param name="Local" value="http://dle.rae.es/srv/search?m=30&amp;w=cerveza">
            </OBJECT>
        <LI> <OBJECT type="text/sitemap">
            <param name="Name" value="Welcome">
            <param name="Local" value="index.htm">
            </OBJECT>
    </UL>
    </BODY></HTML>
    

    So, you may search and replace & with &amp; using a regular expression and your prefered text editor like shown above. Using %26 leads to a server error using your sample URL from a compiled help file (*.CHM).

    Please note - opening index.hhk by HTMLHelp Workshop shortens the URL again as you have already seen. So you need to clean up your index.hhkand compile immediately afterwards without opening your index.hhk.

    As shown in the snap below it's resulting in a content pane for your needs.

    enter image description here