omd2tex.tools.text_tools#
Functions
|
Remove all occurrences of a value from a list. |
|
Split a string by a delimiter and apply a function to alternating parts. |
|
Split a string by regex groups and apply a function to alternating parts. |
- omd2tex.tools.text_tools.remove_elements(lst: List[Any], elem: Any) List[Any][source]#
Remove all occurrences of a value from a list.
- Parameters:
lst – List to filter.
elem – Element to remove wherever it appears.
- Returns:
New list without items equal to
elem.
- omd2tex.tools.text_tools.return_func(string: str | List[str], elem: str, func: Callable[[str], str]) str[source]#
Split a string by a delimiter and apply a function to alternating parts.
Handles cases where the string begins with the delimiter differently from others, mirroring the original logic.
- Parameters:
string – Source text to process.
elem – Delimiter to split on.
func – Callable applied to selected split segments.
- Returns:
Recombined string after processing segments.
- omd2tex.tools.text_tools.return_regular(string: str, regular: str, function: Callable[[str], str]) str[source]#
Split a string by regex groups and apply a function to alternating parts.
Mirrors the behavior of
return_funcbut splits using a regular expression pattern.- Parameters:
string – Source text to process.
regular – Regular expression pattern defining split groups.
function – Callable applied to selected segments after splitting.
- Returns:
Reconstructed string after applying the transformation.