Tool to merge HTML files?
I've encountered this problem twice in the past few years, and I wonder whether there is a tool to solve it.
The problem is: how to merge two or more HTML files into one?
Simply mashing together the <body> tags doesn't work, because the pages may be crosslinked. In the merging process the crosslinked references must become internal references. That is, a tag that starts as <a href="xyz.html#abc"> must be changed to <a href="#abc">. If two or more files use the same identifier one of them must be changed, for examples, from "abc" to "abc-2." And there's a whole series of less common issues to be addressed, such as: if two or more of the files refer to CSS or JS files, how do you decide the merge order?
I once did this by hand, and it was a horrible experience.
I could write this tool myself, but I'm not into reinventing the wheel, so if this particular wheel has already been invented, I'd like to find it.