Skip to content

Commit f6fb9e4

Browse files
committed
Update the file link code to add both the basename and relative filename within
the document tree, and to put the target at the top of the page that actually contains the start of the HTML file (Issue #534)
1 parent d06f586 commit f6fb9e4

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fixed a regression that caused spaces to disappear between some words
44
(Issue #533)
5+
- Fixed broken links to HTML files in the document (Issue #534)
56

67

78
# Changes in HTMLDOC v1.9.19

htmldoc/ps-pdf.cxx

+24-10
Original file line numberDiff line numberDiff line change
@@ -4126,23 +4126,37 @@ parse_doc(tree_t *t, /* I - Tree to parse */
41264126
}
41274127
else if (t->markup == MARKUP_FILE)
41284128
{
4129-
/*
4130-
* Add a file link...
4131-
*/
4129+
// Add file links, stripping any trailing HTTP GET parameters...
4130+
uchar newname[256], // New filename
4131+
*sep; // "?" separator in links
4132+
int linkpage; // Link page
4133+
4134+
// Figure out what page the file will actually start on...
4135+
linkpage = *page;
4136+
4137+
if ((chapter > 0 && OutputType == OUTPUT_BOOK) ||
4138+
((linkpage > 0 || *y < *top) && OutputType == OUTPUT_WEBPAGES))
4139+
{
4140+
if (*y < *top)
4141+
linkpage ++;
41324142

4133-
uchar newname[256], /* New filename */
4134-
*sep; /* "?" separator in links */
4143+
if (PageDuplex && (linkpage & 1))
4144+
linkpage ++;
4145+
}
41354146

4147+
// Base filename link...
4148+
strlcpy((char *)newname, (char *)htmlGetVariable(t, (uchar *)"_HD_FILENAME"), sizeof(newname));
4149+
if ((sep = (uchar *)strchr((char *)newname, '?')) != NULL)
4150+
*sep = '\0';
41364151

4137-
// Strip any trailing HTTP GET data stuff...
4138-
strlcpy((char *)newname, (char *)htmlGetVariable(t, (uchar *)"_HD_FILENAME"),
4139-
sizeof(newname));
4152+
add_link(NULL, newname, linkpage, (int)*top);
41404153

4154+
// Relative filename link...
4155+
strlcpy((char *)newname, (char *)htmlGetVariable(t, (uchar *)"_HD_URL"), sizeof(newname));
41414156
if ((sep = (uchar *)strchr((char *)newname, '?')) != NULL)
41424157
*sep = '\0';
41434158

4144-
// Add the link
4145-
add_link(NULL, newname, *page, (int)*y);
4159+
add_link(NULL, newname, linkpage, (int)*top);
41464160
}
41474161

41484162
if (chapter == 0 && !title_page)

0 commit comments

Comments
 (0)