7 Replies Latest reply on Aug 14, 2006 10:57 PM by Roger N

    Wrapping TOC Titles

    landsafetom Level 1
      Has anyone out there discovered a way to make the TOG topic titles wrap? I know this has been asked before, but am wondering if anyone has figured this out since then.

      I'm using RH X5 and generating WebHelp.
        • 1. Re: Wrapping TOC Titles
          Roger N Level 2
          landsafetom -

          You haven't gotten an answer on this one cause its a tough one. The TOC is built dynamically, on-the-fly, so to speak.

          If you stroke across a TOC item, copy it, and paste it into say, MS Word, your can turn formatting on and see that there are no-break spaces in between the words. I looked to find and remove those no-break symbols ( ) or entities between all the words in the TOC Topic Titles at the point where the TOC objects are broken into the text and URLs. I did that.

          Even then, the titles didn't wrap. Perhaps someone else can figure this out, as I've run out of ideas and time:

          In the whthost.js file, you can find the funcion:


          function writeBookItems(nIdx,num)

          To swap out the no-break spaces for plain spaces, Search-n-Replace this:
          ==================================================

          function writeBookItems(nIdx,num)
          {
          var sHTML="";
          if(num>0){
          var nCIdx=0;
          do{
          nCIdx++;
          var i=nIdx+nCIdx;
          var nItemType=getItemType(i);
          if(nItemType==1||nItemType==4||nItemType==8){
          sHTML+=writeBook(i);
          nCIdx+=getItemContentsNum(i);
          }
          else if(nItemType==2||nItemType==16){
          sHTML+=writeAnItem(i);
          }
          }
          while(nCIdx<num);
          }
          return sHTML;
          }
          ======================================================
          with this:

          =======================================================

          function writeBookItems(nIdx,num)
          {
          var pattern = /\&nbsp\;/g;
          var sHTML="";
          var newsHTML="";
          var softsHTML="";

          if(num>0){
          var nCIdx=0;
          do{
          nCIdx++;
          var i=nIdx+nCIdx;
          var nItemType=getItemType(i);
          if(nItemType==1||nItemType==4||nItemType==8){
          sHTML+=writeBook(i);
          nCIdx+=getItemContentsNum(i);
          }
          else if(nItemType==2||nItemType==16){

          newsHTML=writeAnItem(i);

          softsHTML= newsHTML.replace(pattern," "); ///////////////////////// swap it

          sHTML+=softsHTML;
          }
          }
          while(nCIdx<num);
          }
          return sHTML;
          }
          =========================================================
          • 2. Re: Wrapping TOC Titles
            HKabaker Level 2
            What happens when you hover the cursor over the truncated line in the TOC?

            Harvey
            • 3. Re: Wrapping TOC Titles
              landsafetom Level 1
              Roger: Thanks. I've spent too much time in the whthost.js file this week. I'l play around with it some more next week.

              Harvey: Hovering the cursor over the truncated line in the TOC displays the entire title in a tooltip-like popup. Better than nothing, but not what I want.
              • 4. Re: Wrapping TOC Titles
                HKabaker Level 2
                Okay, you asked for it . . . (wink)(smile)

                In the output folder whgdata, find a file named whlstt0.htm and, depending on how many items are in the TOC, you'll see whlstt1.htm, whlstt2.htm . . . . .

                Text for each TOC line is enclosed in tags
                <nobr>.........</nobr>

                I don't have time to pursue this, but I'll bet it means
                <"no line break from here> ..... <to here>

                Probably this is where the hard spaces are inserted.

                If you try deleting the "nobreak" tags, please post back with results.

                I'm not certain whether you need to do this in all the whlsttnnnn.htm files.

                By the way, the third letter in these file names is a lower case "L" (l) not an upper case i (I). You'll see several file names with an upper case i (I). These contain Index data. Do you also want to wrap long lines in the index and glossary?

                Harvey
                • 5. Re: Wrapping TOC Titles
                  Roger N Level 2
                  Harvey –

                  I considered this, but changing those no-breaks didn’t seem to help, and the getItemsFromObj() function uses that tag to recognize the text of the links. Still works when I take them out, so I’m now sure how it uses them.
                  That’s why I replaced the no-break spaces after the links are generated.

                  But, I found the other components of the fix:

                  The TocWriteFixedWidth function, change the table to remove the width property,

                  WriteBook() and WriteAnItem(), – remove <nobr></nobr> from the strings

                  . . . and . . . ta da , - the TOC wraps just fine.
                  • 6. Re: Wrapping TOC Titles
                    HKabaker Level 2
                    Nice going, Roger!

                    So, to be sure I understand, it needs your changes in TocWriteFixedWidth, WriteBook and WriteAnItem, (all in whthost.js) as well as removing the nobr tags in the output files whlsttnnnn.htm?

                    Harvey
                    • 7. Re: Wrapping TOC Titles
                      Roger N Level 2
                      In whthost.js:

                      1) edit the function writeBookItems() as described.

                      2) remove the width property from the TocWriteFixedWidth() function,

                      3) remove the single <nobr> and </nobr> from the string found in the function WriteAnItem().

                      To wrap the book titles, you would do the same for the WriteBook() function, and insert the script replacement mentioned above (in the first post) wherever it goes for books (ok, I'm getting lazy again).