Skip to content

Commit

Permalink
Fix links to subfolders (Issue #525)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Nov 21, 2024
1 parent 4c61bca commit 274189f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
management and fix potential double-free bugs.
- Updated configure script to look for zlib with pkg-config (Issue #519)
- Updated markdown support code to mmd.
- Fixed hyperlinks to subfolders (Issue #525)
- Fixed export of UTF-8 HTML (Issue #526)
- Fixed handling of whitespace-only nodes (Issue #528)
- Fixed handling of tabs in PRE nodes (Issue #529)
Expand Down
16 changes: 13 additions & 3 deletions htmldoc/ps-pdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9064,7 +9064,7 @@ add_link(tree_t *html, /* I - HTML node */
{
uchar *filename; /* Filename */

if ((filename = htmlGetVariable(html->parent, (uchar *)"_HD_FILENAME")) != NULL)
if ((filename = htmlGetVariable(html->parent, (uchar *)"_HD_URL")) != NULL)
snprintf((char *)temp->name, sizeof(temp->name), "%s#%s", (char *)filename, (char *)name);
else
strlcpy((char *)temp->name, (char *)name, sizeof(temp->name));
Expand Down Expand Up @@ -9100,8 +9100,18 @@ find_link(uchar *name) /* I - Name to find */
name ++;

strlcpy((char *)key.name, (char *)name, sizeof(key.name));
match = (link_t *)bsearch(&key, links, num_links, sizeof(link_t),
(compare_func_t)compare_links);
match = (link_t *)bsearch(&key, links, num_links, sizeof(link_t), (compare_func_t)compare_links);

if (!match)
{
uchar *target = (uchar *)strchr((char *)name, '#');

if (target)
{
strlcpy((char *)key.name, (char *)target + 1, sizeof(key.name));
match = (link_t *)bsearch(&key, links, num_links, sizeof(link_t), (compare_func_t)compare_links);
}
}

return (match);
}
Expand Down

0 comments on commit 274189f

Please sign in to comment.