Closed kknives closed 3 years ago
Thanks for your contributions, and for the detailed explanation ! Merging into master.
@lzanini Thank you for merging my PRs! I would like to help out and refactor more of the code, if you don't mind.
@kknives I don't mind at all, as long as you document the changes as you did for this PR, you're more than welcome to do so !
Issue
11 was caused by the program using the relative path defined in
book.toml
:This will not work if
mdBook
is called from outside the book directory as @str4d reported.Solution
This PR fixes #11 by using the
PreprocessorContext
'sroot
field, defined here as:so that the macros file is now located by an absolute path:
Refactoring
In order to make a test case for this issue, I had to refactor the part of
load_macros
that locates the macros file into its own helper function:get_macro_path
and then test it instead ofload_macros
.This was because, I was not able to mock a
PreprocessorContext
(no public constructor) thatload_macros
needs:Feel free to ask me any questions regarding the changes in this PR