string_processor
¶
apply_string_processors(string, string_processors)
¶
Apply sequence of string transformation functions via reduce.
Why
Multiple transformations (markdown parsing, keyword bolding, escaping) need sequential application. Functional reduce pattern chains processors cleanly without intermediate variables.
Parameters:
-
string(str | None) –Input string or None.
-
string_processors(list[Callable[[str], str]]) –Functions to apply in order.
Returns:
-
str | None–Transformed string, or None if input was None.
Source code in src/rendercv/renderer/templater/string_processor.py
build_keyword_matcher_pattern(keywords)
cached
¶
Build cached regex pattern for matching keywords with longest-first priority.
Why
Keyword matching happens repeatedly during rendering. Cached patterns avoid recompilation. Longest-first sorting prevents "Python" from matching before "Python 3" in same text.
Parameters:
-
keywords(frozenset[str]) –Set of keywords to match.
Returns:
-
Pattern–Compiled regex pattern.
Source code in src/rendercv/renderer/templater/string_processor.py
clean_url(url)
¶
Remove protocol, www, and trailing slashes from URL.
Why
CV formatting displays cleaner URLs without https:// prefix. Used as Jinja2 filter in templates for consistent URL presentation.
Parameters:
-
url(str | HttpUrl) –URL to clean.
Returns:
-
str–Clean URL string.
Source code in src/rendercv/renderer/templater/string_processor.py
make_keywords_bold(string, keywords)
¶
Wrap all keyword occurrences in Markdown bold syntax.
Why
Users configure keywords like "Python" or "Machine Learning" to highlight in their CV. Automatic bolding applies consistent emphasis across all content without manual markup.
Example
Parameters:
-
string(str) –Text to process.
-
keywords(list[str]) –Keywords to make bold.
Returns:
-
str–String with keywords wrapped in ** markers.
Source code in src/rendercv/renderer/templater/string_processor.py
substitute_placeholders(string, placeholders)
¶
Replace all placeholder occurrences with their values.
Why
Output file names use placeholders like NAME and YEAR for dynamic naming. Pattern matching with longest-first ensures "YEAR_IN_TWO_DIGITS" matches before "YEAR" in same string.
Example
Parameters:
-
string(str) –Template string with placeholders.
-
placeholders(dict[str, str]) –Map of placeholder names to replacement values.
Returns:
-
str–String with all placeholders replaced.