Skip to content

Commit

Permalink
ci: fix broken newline check with code block syntax (#6239)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander authored Jan 30, 2022
1 parent 82d17ab commit bbebdc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/doc-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion utils/fix-zh-doc-segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit bbebdc9

Please sign in to comment.