mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-29 13:40:08 +01:00
scanner: add a filter to escape ei protocol names
By default escape them with backticks for markdown
This commit is contained in:
parent
2fb1ff70e3
commit
eb9fa07c10
1 changed files with 10 additions and 0 deletions
|
|
@ -807,9 +807,19 @@ def generate_source(
|
|||
def filter_as_c_arg(name):
|
||||
return f"struct {name} *{name}"
|
||||
|
||||
# escape any ei[s]?_foo.bar with markdown backticks
|
||||
def filter_ei_escape_names(str, quotes="`"):
|
||||
if not str:
|
||||
return str
|
||||
|
||||
import re
|
||||
|
||||
return re.sub(rf"({component}[_-]\w*)(\.\w*)?", rf"{quotes}\1\2{quotes}", str)
|
||||
|
||||
env.filters["c_type"] = filter_c_type
|
||||
env.filters["as_c_arg"] = filter_as_c_arg
|
||||
env.filters["camel"] = snake2camel
|
||||
env.filters["ei_escape_names"] = filter_ei_escape_names
|
||||
jtemplate = env.get_template(filename)
|
||||
return jtemplate.stream(data)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue