Closed Diom closed 2 years ago
Looks like this section is failing:
fileInfo = new FileInfo($"{absPath}.md");
if (fileInfo.Exists && fileInfo.Extension.Equals(".md", StringComparison.InvariantCultureIgnoreCase))
{
isMarkdown = true;
}
//only markdown files get a pdf internal link
if (isMarkdown)
{
For some reason, in the absPath
there is a ".wiki" being added to the parent folder? This causes the file to "not exist" and not get treated as an internal link.
var split = _path.Split(".wiki");
_rootWikiPath = split[0].IsNullOrEmpty() ? _path : split[0] + ".wiki";
added there.
Changing to this makes it work:
var split = _path.Split(".wiki");
_rootWikiPath = _path; //split[0].IsNullOrEmpty() ? _path : split[0] + ".wiki";
It looks like the work added to make the internal links work when exporting a sub-section broke the links. It made a bad assumption that ALL wiki have '.wiki' in the path, which is only true of the default wikis. A better mechanism to detect the root would be to use the path to the .attachments page.
I will look into that once I have my customer doc updates done!
Solved it properly by doing this:
public static DirectoryInfo FindNearestParentAttachmentsDirectory(DirectoryInfo exportBase)
{
DirectoryInfo[] attDirs = exportBase.GetDirectories("./.attachments");
if(attDirs != null && attDirs.Length > 0) {
return attDirs[0].Parent;
}
if (null != exportBase.Parent) {
return FindNearestParentAttachmentsDirectory(exportBase.Parent);
}
throw new WikiPdfExportException("Failed to locate the base of the Wiki using attachment detection");
}
Went for .attachments instead because maybe for some reason there is no git?? will try to find time to test it PRed soon
PR #98 opened
wow - intensive review and addition - THANK YOU @Diom
Issue:
Links to other sections of the wiki (not deep-linked) are not clickable in the generated PDF
To Reproduce:
Add a link to a wiki MD page:
Run the build (ctrl+f5)
Expected
Link to internal section of the PDF will work.
Actual
The text is styled as a link but does not work.
Example
Added the above to the test wiki in the repo and built the project. This was output in the console:
Attached PDF the link does not work (I took out the images at the top of the page for clarity in the console
export.pdf