Skip to content

Commit 559e30c

Browse files
committed
fix: improve Liquid template wrapping in documentation script
- Enhanced the fix-docs.sh script to process Liquid syntax line by line, ensuring proper wrapping with {% raw %} and {% endraw %} tags. - Replaced the previous sed command with a more robust method that creates a temporary file for better handling of Liquid tags.
1 parent d266f46 commit 559e30c

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.github/scripts/docs/fix-docs.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,23 @@ for dir in code-based configuration-based; do
1717

1818
# Fix the Liquid templates in both files
1919
for target in "$file" "$lowercase"; do
20-
# Replace {{ with {% raw %}{{ and }} with }}{% endraw %}
21-
sed -i.bak -E 's/\{\{([^}]*)\}\}/\{% raw %\}\{\{\1\}\}\{% endraw %\}/g' "$target"
22-
rm -f "$target.bak"
20+
# Create a temporary file
21+
temp_file="${target}.tmp"
22+
> "$temp_file" # Create empty file
23+
24+
# Process line by line to properly wrap Liquid tags
25+
while IFS= read -r line; do
26+
if [[ "$line" == *"{{"*"}}"* ]]; then
27+
# Line contains Liquid syntax, wrap it
28+
echo "{% raw %}${line}{% endraw %}" >> "$temp_file"
29+
else
30+
# No Liquid syntax, keep as is
31+
echo "$line" >> "$temp_file"
32+
fi
33+
done < "$target"
34+
35+
# Replace original with fixed version
36+
mv "$temp_file" "$target"
2337
done
2438
fi
2539
done

0 commit comments

Comments
 (0)