@@ -2051,9 +2051,8 @@ def body_suffix_upsert(
20512051 suffix = (
20522052 BODY_SUFFIX_TITLE + "\n " + "\n " .join (items ) + "\n \n " + BODY_SUFFIX_FOOTER + "\n "
20532053 )
2054- if re .search (BODY_SUFFIX_RE , body , flags = re .M | re .I | re .X ):
2055- return re .sub (BODY_SUFFIX_RE , suffix , body , flags = re .M | re .I | re .X )
2056- return body .rstrip () + "\n \n " + suffix
2054+ new_body = re .sub (BODY_SUFFIX_RE , lambda _ : suffix , body , flags = re .M | re .I | re .X )
2055+ return new_body if new_body != body else body .rstrip () + "\n \n " + suffix
20572056
20582057
20592058#
@@ -2065,7 +2064,7 @@ def body_build_from_injected_text(
20652064) -> str :
20662065 return re .sub (
20672066 r"\s*" + re .escape (AI_PLACEHOLDER ) + r"\s*" ,
2068- f"\n \n { injected_text .text } \n \n " ,
2067+ lambda _ : f"\n \n { injected_text .text } \n \n " ,
20692068 injected_text .template_with_placeholder ,
20702069 )
20712070
@@ -2095,7 +2094,7 @@ def body_convert_to_injected_text(
20952094# Returns an AI hash comment.
20962095#
20972096def ai_hash_build (hash : str ) -> str :
2098- return re .sub (r"(?=-->)" , ":" + hash , AI_PLACEHOLDER )
2097+ return re .sub (r"(?=-->)" , lambda _ : f": { hash } " , AI_PLACEHOLDER )
20992098
21002099
21012100#
0 commit comments