You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
390 B
Python
17 lines
390 B
Python
class FilterModule:
|
|
def filters(self):
|
|
return {
|
|
"enquote": enquote,
|
|
}
|
|
|
|
|
|
def enquote(string, delimiter='"', escape="\\"):
|
|
translation = str.maketrans(
|
|
{
|
|
delimiter: f"{escape}{delimiter}",
|
|
escape: f"{escape}{escape}",
|
|
}
|
|
)
|
|
escaped = string.translate(translation)
|
|
return f"{delimiter}{escaped}{delimiter}"
|