Utils for strings.
Handsdown API Index / Handsdown / Utils / Strings
Auto-generated documentation for handsdown.utils.strings module.
Extract title from the first line of content.
If title is present - return a title and a remnaing content. if not - return an empty title and untouched content.
extract_md_title('# Title\ncontent')
('Title', 'content')
extract_md_title('no title\ncontent')
('', 'no title\ncontent')A tuple fo title and remaining content.
def extract_md_title(content: str) -> tuple[str, str]: ...Convert pathlib.Path part or any other string to a human-readable title.
Replace underscores with spaces and capitalize result.
make_title(Path("my_module/my_path.py").stem)
"My Path"
make_title("my_title")
"My Title"
make_title("__init__.py")
"Init Py"
make_title(Path("my_module/__main__.py").stem)
"Module"file_stem- Stem from path.
A human-readable title as a string.
def make_title(file_stem: str) -> str: ...