File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed
Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 1+ __pycache__
Original file line number Diff line number Diff line change 22import os
33import re
44
5-
6- def compute_page_id (root_dir , input_filepath ):
7- # Compute the file's absolute path and then its relative path from the root directory.
8- abs_input_path = os .path .abspath (input_filepath )
9- rel_path = os .path .relpath (abs_input_path , root_dir )
10- # Remove the file extension.
11- rel_path_no_ext , _ = os .path .splitext (rel_path )
12- # Replace path separators with underscores.
13- page_id = rel_path_no_ext .replace (os .sep , "_" )
14- return page_id
15-
5+ from md_utils import compute_page_id
166
177def replace_special_symbols (text ):
188 # Define your symbol mappings using Unicode escape sequences.
Original file line number Diff line number Diff line change 1+ import os
2+
3+ def compute_page_id (root_dir , input_filepath ):
4+ """
5+ Compute a unique page id based on the file's path relative to the project root.
6+
7+ For example, if input_filepath is:
8+ <root_dir>/Path/To/page.md
9+ then the returned page id becomes:
10+ Path_To_page
11+ """ # Compute the file's absolute path and then its relative path from the root directory.
12+ abs_input_path = os .path .abspath (input_filepath )
13+ rel_path = os .path .relpath (abs_input_path , root_dir )
14+ # Remove the file extension.
15+ rel_path_no_ext , _ = os .path .splitext (rel_path )
16+ # Replace path separators with underscores.
17+ page_id = rel_path_no_ext .replace (os .sep , "_" )
18+ return page_id
You can’t perform that action at this time.
0 commit comments