I'm continually amazed by KM's performance

I decided that I wanted to change the layout of our apps' help files, switching from a drop-down index to a sidebar-based nav layout, like this:

But because the sidebar is dependent on the help file's contents, it can't be built until the help file itself is written. And because this is running in Apple's Help system, and our apps are commercial products, I didn't want to include any sort of open-source processing engine.

What I needed was a way to process my HTML files after I wrote them. In the span of a few hours, I created a KM help file processing macro. The macro does the following:

Opens a specified help folder, and then does this for any HTML files in the folder:

  1. Searches each file for an index number, so the macro knows the order of items in the sidebar. I prepend the index number to the filename, sort that list, then remove the index number. Now I have a sorted list of file names to process.

  2. That list is then used in this step to build the HTML for the sidebar. This requires searching each file for some things—a title tag for the header (regex on the file), and then name tags for sub-bullets (a perl script). Each line also has to be processed with regex to add the proper HTML formatting for the sidebar.

  3. At the end of step two, I have a sidebar, but it's not specific to each file. Step three starts with that generic sidebar, then for each file, customizes it as needed (i.e. links are added and removed when each page is frontmost), and then writes the changes directly into each file.

For my tests, I used an old help file with four files totalling about 75KB of drive space. The macro goes through these files three separate times to do all the processing, and creates four distinct versions of the above nav bar (starting with absolutely nothing). And how long does that take?

0.15 seconds.

That's ... just ... crazy fast! Amazing work, @peternlewis!

-rob.

6 Likes