Skip to content

Commit

Permalink
update and add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
TOsmanov committed Jul 19, 2024
1 parent ff5e3b4 commit 2d91a1f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion foliant/preprocessors/includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ def process_includes(
'''

recipient_md_path = f'{self.src_dir}/{markdown_file_path.relative_to(self.working_dir).as_posix()}'

markdown_file_path = markdown_file_path.resolve()

self.logger.debug(f'Processing Markdown file: {markdown_file_path}')
Expand Down Expand Up @@ -964,6 +965,8 @@ def process_includes(
included_file_path = repo_path / body.group('path')

donor_md_path = included_file_path.as_posix()

self.logger.debug(f'Set the repo URL of the included file to {recipient_md_path}: {donor_md_path}')

if included_file_path.name.startswith('^'):
included_file_path = self._find_file(
Expand Down Expand Up @@ -991,7 +994,6 @@ def process_includes(
self.logger.debug('Local file referenced')

included_file_path = self._get_included_file_path(body.group('path'), markdown_file_path)
donor_md_path = f"{self.src_dir}/{included_file_path.relative_to(os.getcwd()).relative_to(self.working_dir).as_posix()}"

if included_file_path.name.startswith('^'):
included_file_path = self._find_file(
Expand All @@ -1016,6 +1018,10 @@ def process_includes(
nohead=options.get('nohead')
)

donor_md_path = f"{self.src_dir}/{included_file_path.relative_to(os.getcwd()).relative_to(self.working_dir).as_posix()}"

self.logger.debug(f'Set the path of the included file to {recipient_md_path}: {donor_md_path}')

else: # if body is missing
self.logger.debug('Using the new syntax rules')

Expand Down Expand Up @@ -1053,6 +1059,8 @@ def process_includes(
)

donor_md_path = include_link

self.logger.debug(f'Set the link of the included file to {recipient_md_path}: {donor_md_path}')

elif options.get('url'):
self.logger.debug('File to get by URL referenced')
Expand Down Expand Up @@ -1081,6 +1089,8 @@ def process_includes(
)

donor_md_path = options['url']

self.logger.debug(f'Set the URL of the included file to {recipient_md_path}: {donor_md_path}')

elif options.get('src'):
self.logger.debug('Local file referenced')
Expand All @@ -1094,6 +1104,8 @@ def process_includes(
donor_md_path = f"{self.src_dir}/{_path.relative_to(self.working_dir).as_posix()}"
else:
donor_md_path = _path.as_posix()

self.logger.debug(f'Set the path of the included file to {recipient_md_path}: {donor_md_path}')

if options.get('project_root'):
current_project_root_path = (
Expand Down

0 comments on commit 2d91a1f

Please sign in to comment.