MCPcopy
hub / github.com/nonebot/nonebot2 / escape_tag

Function escape_tag

nonebot/utils.py:115–123  ·  view source on GitHub ↗

用于记录带颜色日志时转义 ` ` 类型特殊标签 参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color) 参数: s: 需要转义的字符串

(s: str)

Source from the content-addressed store, hash-verified

113
114
115def escape_tag(s: str) -> str:
116 """用于记录带颜色日志时转义 `<tag>` 类型特殊标签
117
118 参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color)
119
120 参数:
121 s: 需要转义的字符串
122 """
123 return re.sub(r"</?((?:[fb]g\s)?[^<>\s]*)>", r"\\\g<0>", s)
124
125
126def deep_update(

Callers 8

initFunction · 0.90
handle_eventFunction · 0.90
load_pluginMethod · 0.90
register_adapterMethod · 0.90
runMethod · 0.90
test_loguru_escape_tagFunction · 0.90
logFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_loguru_escape_tagFunction · 0.72