Skip to content

Commit cb00f30

Browse files
committed
chore: improve front matter processing in documentation scripts
- Added a new section to aggressively fix front matter in schema markdown files, ensuring proper titles and navigation visibility for core and non-core schemas. - Enhanced the logic for handling code blocks and Liquid syntax within markdown files, improving overall formatting and escaping. - Streamlined the script to ensure robust processing of schema documentation, contributing to better organization and clarity.
1 parent 0e66d48 commit cb00f30

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

.github/scripts/docs/process-docs.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,43 @@ CORE_SCHEMAS=(
3030
if [ ! -d "$BASE_DIR/schemas" ]; then
3131
echo "⚠️ Directory $BASE_DIR/schemas not found. Skipping schema processing."
3232
else
33+
# Add this improved front matter fixing section
34+
echo "🔧 Super aggressive front matter fix for schema files..."
35+
find "$BASE_DIR/schemas" -type f -name "*.md" | while read file; do
36+
filename=$(basename "$file" .md)
37+
38+
# Skip index.md
39+
if [[ "$filename" == "index" ]]; then
40+
continue
41+
fi
42+
43+
echo " Fixing front matter in $filename"
44+
45+
# Check if this is a core schema
46+
is_core=false
47+
for core_schema in "${CORE_SCHEMAS[@]}"; do
48+
if [[ "$filename" == "$core_schema" ]]; then
49+
is_core=true
50+
break
51+
fi
52+
done
53+
54+
# Extract content without any current front matter
55+
content=$(sed -e '1{/^---$/!q0}' -e '1,/^---$/d' "$file" 2>/dev/null || cat "$file")
56+
57+
# Generate title from filename
58+
title=$(echo "$filename" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
59+
60+
# Create a completely new file with proper front matter
61+
if [ "$is_core" = true ]; then
62+
# Core schema - visible in navigation
63+
echo -e "---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\n---\n\n$content" > "$file"
64+
else
65+
# Non-core schema - hidden from navigation
66+
echo -e "---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\nnav_exclude: true\n---\n\n$content" > "$file"
67+
fi
68+
done
69+
3370
# Fix broken front matter AND set navigation visibility
3471
echo "🔧 Fixing front matter and configuring navigation..."
3572
find "$BASE_DIR/schemas" -type f -name "*.md" | while read file; do
@@ -204,7 +241,7 @@ else
204241
in_code_block=false
205242
while IFS= read -r line; do
206243
# Check if line starts/ends a code block
207-
if [[ "$line" =~ ^```.*$ ]]; then
244+
if [[ "$line" =~ ^\`\`\`.*$ ]]; then
208245
# Toggle code block state
209246
if $in_code_block; then
210247
in_code_block=false
@@ -217,7 +254,7 @@ else
217254

218255
if $in_code_block; then
219256
# Inside code blocks, wrap any {{ }} in raw tags
220-
if [[ "$line" =~ \{\{ || "$line" =~ \}\} ]]; then
257+
if [[ "$line" =~ (\{\{|\}\}) ]]; then
221258
# Replace any existing escape sequences
222259
line=$(echo "$line" | sed 's/\\{{ /{{ /g' | sed 's/ \\}}/ }}/g' | sed 's/\\{{/{{/g' | sed 's/\\}}/}}/g')
223260
# Wrap the entire line in raw tags if it contains liquid syntax

0 commit comments

Comments
 (0)