Skip to content

Commit

Permalink
add: clean urls
Browse files Browse the repository at this point in the history
  • Loading branch information
TOsmanov committed Nov 14, 2024
1 parent 784137b commit f3d9d8c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions foliant/preprocessors/includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ def _add_anchors(self, l: list, content: str) -> list:
l.append(anchor)
return l

def clean_tokens(self, url: str) -> str:
return re.sub(r"(https*://)(.*)@(.*)", r"\1\3", url)

def process_includes(
self,
markdown_file_path: Path,
Expand Down Expand Up @@ -1054,6 +1057,7 @@ def process_includes(

if self.includes_map_enable:
donor_md_path = included_file_path.as_posix()
donor_md_path = self.clean_tokens(donor_md_path)
self.logger.debug(f'Set the repo URL of the included file to {recipient_md_path}: {donor_md_path} (1)')


Expand Down Expand Up @@ -1112,6 +1116,7 @@ def process_includes(

if self.includes_map_enable:
donor_md_path = self._prepare_path_for_includes_map(included_file_path)
donor_md_path = self.clean_tokens(donor_md_path)
self.logger.debug(f'Set the path of the included file to {recipient_md_path}: {donor_md_path} (2)')

if self.includes_map_enable and self.includes_map_anchors:
Expand Down Expand Up @@ -1155,6 +1160,7 @@ def process_includes(

if self.includes_map_enable:
donor_md_path = include_link + options.get('path')
donor_md_path = self.clean_tokens(donor_md_path)
self.logger.debug(f'Set the link of the included file to {recipient_md_path}: {donor_md_path} (3)')

if self.includes_map_enable and self.includes_map_anchors:
Expand Down Expand Up @@ -1188,6 +1194,7 @@ def process_includes(

if self.includes_map_enable:
donor_md_path = options['url']
donor_md_path = self.clean_tokens(donor_md_path)
self.logger.debug(f'Set the URL of the included file to {recipient_md_path}: {donor_md_path} (4)')

if self.includes_map_enable and self.includes_map_anchors:
Expand Down Expand Up @@ -1220,6 +1227,7 @@ def process_includes(

if self.includes_map_enable:
donor_md_path = self._prepare_path_for_includes_map(included_file_path)
donor_md_path = self.clean_tokens(donor_md_path)
self.logger.debug(f'Set the path of the included file to {recipient_md_path}: {donor_md_path} (5)')

if self.includes_map_enable and self.includes_map_anchors:
Expand Down

0 comments on commit f3d9d8c

Please sign in to comment.