diff --git a/.github/workflows/doc-lint.yml b/.github/workflows/doc-lint.yml index 2244e3721600..e37f7d432365 100644 --- a/.github/workflows/doc-lint.yml +++ b/.github/workflows/doc-lint.yml @@ -28,7 +28,7 @@ jobs: ./utils/fix-zh-doc-segment.py > \ /tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1) if grep "find broken newline in file: " /tmp/check.log; then - cat /tmp/error.log + cat /tmp/check.log echo "Newline can't appear in the middle of Chinese sentences." echo "You need to run ./utils/fix-zh-doc-segment.py to fix them." exit 1 diff --git a/utils/fix-zh-doc-segment.py b/utils/fix-zh-doc-segment.py index da0ccf684724..1d76f2a98e46 100755 --- a/utils/fix-zh-doc-segment.py +++ b/utils/fix-zh-doc-segment.py @@ -43,8 +43,11 @@ def check_segment(root): with open(fn) as f: lines = f.readlines() new_lines = [lines[0]] + skip = False for i in range(1, len(lines)): - if need_fold(lines[i-1], lines[i]): + if lines[i-1].startswith('```'): + skip = not skip + if not skip and need_fold(lines[i-1], lines[i]): new_lines[-1] = new_lines[-1].rstrip("\r\n") + lines[i] else: new_lines.append(lines[i])