mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 05:10:38 +08:00
count_chars_without_html
This commit is contained in:
@ -431,12 +431,20 @@ class PRDescription:
|
|||||||
pass
|
pass
|
||||||
return pr_body
|
return pr_body
|
||||||
|
|
||||||
|
|
||||||
|
def count_chars_without_html(string):
|
||||||
|
if '<' not in string:
|
||||||
|
return len(string)
|
||||||
|
no_html_string = re.sub('<[^>]+>', '', string)
|
||||||
|
return len(no_html_string)
|
||||||
|
|
||||||
|
|
||||||
def insert_br_after_x_chars(text, x=70):
|
def insert_br_after_x_chars(text, x=70):
|
||||||
"""
|
"""
|
||||||
Insert <br> into a string after a word that increases its length above x characters.
|
Insert <br> into a string after a word that increases its length above x characters.
|
||||||
Use proper HTML tags for code and new lines.
|
Use proper HTML tags for code and new lines.
|
||||||
"""
|
"""
|
||||||
if len(text) < x:
|
if count_chars_without_html(text) < x:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
# replace odd instances of ` with <code> and even instances of ` with </code>
|
# replace odd instances of ` with <code> and even instances of ` with </code>
|
||||||
@ -458,12 +466,6 @@ def insert_br_after_x_chars(text, x=70):
|
|||||||
if i < len(lines) - 1:
|
if i < len(lines) - 1:
|
||||||
words[-1] += "<br>"
|
words[-1] += "<br>"
|
||||||
|
|
||||||
def count_chars_without_html(string):
|
|
||||||
if '<' not in string:
|
|
||||||
return len(string)
|
|
||||||
no_html_string = re.sub('<[^>]+>', '', string)
|
|
||||||
return len(no_html_string)
|
|
||||||
|
|
||||||
new_text = []
|
new_text = []
|
||||||
is_inside_code = False
|
is_inside_code = False
|
||||||
current_length = 0
|
current_length = 0
|
||||||
|
Reference in New Issue
Block a user