Skip to content

Commit e4f7bcd

Browse files
fix(docs): sanitize generated emoji shortcodes
1 parent 7655b3b commit e4f7bcd

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎.github/workflows/docs-nav.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
workflow_dispatch:
99
pull_request:
1010
paths:
11-
- "docs/sdks/**"
11+
- "docs/**"
12+
- "scripts/sanitize-docs-emoji.sh"
1213
- "scripts/gen-docs-nav.sh"
1314
- ".github/workflows/docs-nav.yaml"
1415

@@ -23,6 +24,9 @@ jobs:
2324
token: ${{ secrets.GITHUB_TOKEN }}
2425

2526
# jq is preinstalled on GitHub-hosted ubuntu runners.
27+
- name: Sanitize generated docs emoji
28+
run: scripts/sanitize-docs-emoji.sh
29+
2630
- name: Regenerate docs navigation
2731
run: scripts/gen-docs-nav.sh
2832

‎scripts/sanitize-docs-emoji.sh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$ROOT"
6+
7+
DOCS_DIR="docs"
8+
9+
if [[ ! -d "$DOCS_DIR" ]]; then
10+
echo "missing $DOCS_DIR" >&2
11+
exit 1
12+
fi
13+
14+
find "$DOCS_DIR" -type f -name '*.mdx' -exec perl -0pi -e '
15+
s/:heavy_check_mark:/✅/g;
16+
s/:heavy_minus_sign:/➖/g;
17+
s/:warning:/⚠️/g;
18+
' {} +
19+
20+
if matches="$(find "$DOCS_DIR" -type f -name '*.mdx' -exec grep -HnE ':[a-z][a-z0-9_+-]*:' {} + || true)" && [[ -n "$matches" ]]; then
21+
echo "unmapped emoji shortcodes remain under $DOCS_DIR, add them to this script:" >&2
22+
printf '%s\n' "$matches" >&2
23+
exit 1
24+
fi

0 commit comments

Comments
 (0)