替换 front matter 中的单行字段,并尽量保留原始引号风格
(content, field_name, new_value)
| 122 | return description |
| 123 | |
| 124 | def replace_front_matter_field(content, field_name, new_value): |
| 125 | """替换 front matter 中的单行字段,并尽量保留原始引号风格""" |
| 126 | pattern = rf"^({field_name}:\s*['\"]?)(.*?)(['\"]?\s*)$" |
| 127 | return re.sub(pattern, rf"\g<1>{new_value}\g<3>", content, count=1, flags=re.MULTILINE) |
| 128 | |
| 129 | def split_and_generate_files(input_file, tmp_en_file): |
| 130 | """ |
no outgoing calls
no test coverage detected