Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine and Relative Paths #6

Open
coreywan opened this issue Dec 1, 2021 · 3 comments
Open

Combine and Relative Paths #6

coreywan opened this issue Dec 1, 2021 · 3 comments

Comments

@coreywan
Copy link

coreywan commented Dec 1, 2021

The below reference seems to be where you create the combined md file without taking into account relative path links in the sourced md files. Thus, when the end combined document gets created, the images or relative links will not load. (Specifically I was testing images in md files). I have a multi-level folder structure. I think if you had a fairly basic mkdocs documentation it would not be an issue, or you could strategically place your images to resolve the issue.

I wanted to open this issue to see if this has been thought through.

def write_combined_pandoc(self, output_path: str):
combined_md = output_path + ".md"
with open(combined_md, "w") as f:
for p in self.pages:
if p is None:
log.error("Unexpected error - not all pages were rendered properly")
continue
with open(p, "r") as rf:
lines = rf.readlines()
f.writelines(lines)
if not lines[-1].endswith("\n"):
f.write("\n")
f.write("\n")
self.write_pandoc(combined_md, output_path)

@coreywan
Copy link
Author

coreywan commented Dec 1, 2021

Looking into this a little more, I was able to find a workaround to this by using the --resource-path argument in pandoc, and adding that to the pandoc_extra_args attribute in the pandoc plugin section of mkdocs.yml

@dabukalam
Copy link

Ran into the same issue, and this was very useful. Thanks @coreywan.

@dabukalam
Copy link

Suggested it's added to README here #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants