diff --git a/.autocorrectignore b/.autocorrectignore index 01e0bbf9054ee2..e172afde0a7792 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -2,7 +2,7 @@ # https://github.com/huacnlee/autocorrect # # Like `.gitignore`, this file to tell AutoCorrect which files need to check, some need to ignore. -files/ -docs/ +/* !files/zh-cn/ +!docs/zh-cn/ _wikihistory.json diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml deleted file mode 100644 index 6c69cef150d67d..00000000000000 --- a/.github/workflows/autocorrect-lint.yml +++ /dev/null @@ -1,44 +0,0 @@ -# This workflow to use AutoCorrect tool for checking the copywriting, correct spaces and punctuations for CJK contents. -# -# For example: -# -# - incorrect: "欢迎阅读MDN文档." -# - correct: "欢迎阅读 MDN 文档。" -# -# - incorrect: "Welcome,this is MDN Web Docs。" -# - correct: "Welcome, to read MDN Web Docs." -# -# More details: -# https://github.com/huacnlee/autocorrect -name: AutoCorrect Lint -on: - pull_request: - branches: - - main - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Get changed files - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - run: | - # Use the GitHub API to get the list of changed files - # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits - DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ - --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') - # filter out files that are not markdown - DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/zh-cn/" | xargs) - echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - - - name: AutoCorrect changed content - if: ${{ env.DIFF_DOCUMENTS }} - uses: huacnlee/autocorrect-action@v2.9.0 - with: - args: ${{ env.DIFF_DOCUMENTS }} --lint --no-diff-bg-color diff --git a/.github/workflows/markdown-lint-fix.yml b/.github/workflows/markdown-lint-fix.yml index 7440889f0d406d..b6fdc5300588dc 100644 --- a/.github/workflows/markdown-lint-fix.yml +++ b/.github/workflows/markdown-lint-fix.yml @@ -61,6 +61,7 @@ jobs: run: | yarn markdownlint-cli2 --fix "**/${{ matrix.lang }}/**/*.md" node ./scripts/check-url-locale.js --fix "files/${{ matrix.lang }}" + ls -d 2>/dev/null "files/${{ matrix.lang }}" "docs/${{ matrix.lang }}" | xargs yarn autocorrect --fix yarn prettier -w "**/${{ matrix.lang }}/**/*.md" cd ${{ github.workspace }}/mdn/content && yarn fix:fm --config-file ${{ github.workspace }}/front-matter-config.json "${{ github.workspace }}/files/${{ matrix.lang }}" diff --git a/.github/workflows/pr-check-lint_content.yml b/.github/workflows/pr-check-lint_content.yml index 9b0910d33d6f58..8729e246a94ed5 100644 --- a/.github/workflows/pr-check-lint_content.yml +++ b/.github/workflows/pr-check-lint_content.yml @@ -117,6 +117,9 @@ jobs: echo "Running url locale checker" node ./scripts/check-url-locale.js --fix ${files_to_lint} + echo "Running autocorrect" + yarn autocorrect --fix ${files_to_lint} + echo "Running Prettier" yarn prettier -w ${files_to_lint} diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 7dcd408346bf8d..bb7aed780bfda6 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -3,6 +3,7 @@ "*.md": [ "markdownlint-cli2 --fix", "node ./scripts/check-url-locale.js --fix", + "autocorrect --fix", "prettier --write" ] } diff --git a/files/zh-cn/glossary/accent/index.md b/files/zh-cn/glossary/accent/index.md index 0b455b9af9d55b..60ec2907638a9b 100644 --- a/files/zh-cn/glossary/accent/index.md +++ b/files/zh-cn/glossary/accent/index.md @@ -7,7 +7,7 @@ slug: Glossary/Accent **强调色**(accent)通常为一种明亮的颜色,与颜色方案中更实用的背景和前景色形成对比。这些颜色存在于很多平台(但不是所有平台)的视觉样式中。 -在 web 上,强调色有时用于 {{HTMLElement("input")}} 元素中控件的活跃部分,例如勾选的[复选框](/zh-CN/docs/Web/HTML/Element/input/checkbox)的背景。 +在 Web 上,强调色有时用于 {{HTMLElement("input")}} 元素中控件的活跃部分,例如勾选的[复选框](/zh-CN/docs/Web/HTML/Element/input/checkbox)的背景。 ## 参见 diff --git a/package.json b/package.json index f3073669ed9540..899f6cf6bf0687 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "type": "module", "scripts": { "fix:json": "prettier -w \"**/*.json(c)?\"", - "fix:md": "markdownlint-cli2 --fix \"**/*.md\" && node ./scripts/check-url-locale.js --fix files && prettier -w \"**/*.md\"", + "fix:md": "markdownlint-cli2 --fix \"**/*.md\" && node ./scripts/check-url-locale.js --fix files && yarn autocorrect --fix . && prettier -w \"**/*.md\"", "fix:yml": "prettier -w \"**/*.yml\"", "lint:json": "prettier -c \"**/*.json(c)?\"", - "lint:md": "markdownlint-cli2 \"**/*.md\" && node ./scripts/check-url-locale.js files && prettier -c \"**/*.md\"", + "lint:md": "markdownlint-cli2 \"**/*.md\" && node ./scripts/check-url-locale.js files && yarn autocorrect --lint . && prettier -c \"**/*.md\"", "lint:yml": "prettier -c \"**/*.yml\"", "prepare": "husky install" }, @@ -27,6 +27,7 @@ "node": ">=18.0.0" }, "dependencies": { + "autocorrect-node": "2.9.0", "cld": "^2.9.1", "fdir": "^6.1.1", "front-matter": "^4.0.2", diff --git a/yarn.lock b/yarn.lock index 5762dcd7e67064..d2f2d6088fe89d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -88,6 +88,42 @@ argparse@^2.0.1: resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== +autocorrect-node-darwin-arm64@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-arm64/-/autocorrect-node-darwin-arm64-2.9.0.tgz#b1c058bfb226f6d25300f9fd3aca0020c8f62243" + integrity sha512-lNG5RvydyBWUToJ5dDgGCu1Mmi6uxJsErGNokyiLj0tP0HXsI7Ed+MPnVd2QLWDrSfTIaGr4JyJ0KjVe0TyznA== + +autocorrect-node-darwin-x64@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-x64/-/autocorrect-node-darwin-x64-2.9.0.tgz#6399885701ec8ca7e22d7a06da4c33b0a7580334" + integrity sha512-giOy9nHnReU5pJH44jI1grPSdtyv0jhVt/UqKpnW3XaH8kss2CvF1BzW0/BAD6FbUOlh7S1JjrfTD4bWkqR1ZA== + +autocorrect-node-linux-x64-gnu@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-gnu/-/autocorrect-node-linux-x64-gnu-2.9.0.tgz#55af46b851ba5f29e77796acc31ae88a74eaeac9" + integrity sha512-KMAwr4TM04HYQN0+fSVaxJ/+o+msrluSOKwI79wYnIukrSQSBLbVthVowsP6coUHi9A9Jq8fHhlAFdOQPVKGUA== + +autocorrect-node-linux-x64-musl@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-musl/-/autocorrect-node-linux-x64-musl-2.9.0.tgz#ffbea51cda8d3c3d49cfca41f8ce20eb2f78f9e6" + integrity sha512-Uly0OHk2ZSriClKNh6QEFI0CP9Uf8rUX0EFBNoPONwZtLWfvuthFZPb+9WJMW5H4+yRMU8T/p8yMM1iSnNgi9g== + +autocorrect-node-win32-x64-msvc@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/autocorrect-node-win32-x64-msvc/-/autocorrect-node-win32-x64-msvc-2.9.0.tgz#081857f163f53ddbfff7ec9c5e14c59eef554f12" + integrity sha512-MKJxmoDMZzOq6OEvqcDV/2WnQ0KWBvqtWm7l0o0MBNG5PqTlV2wqHtmCk6gfLGLV0oNT9A30WsgYfGyEeNJ0wg== + +autocorrect-node@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/autocorrect-node/-/autocorrect-node-2.9.0.tgz#4f89ff98bd5ad7cbcc4d2639ff73e9e3aeaa0d6b" + integrity sha512-a5/llf9KoBJg2H7dj1iCYbo/uYYiYm4Shr9zMMFrvsPS3LTMVDwfvUmpGhlod2F8AChaFpHS5OirFMd8Fxw+ag== + optionalDependencies: + autocorrect-node-darwin-arm64 "2.9.0" + autocorrect-node-darwin-x64 "2.9.0" + autocorrect-node-linux-x64-gnu "2.9.0" + autocorrect-node-linux-x64-musl "2.9.0" + autocorrect-node-win32-x64-msvc "2.9.0" + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"