|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Script to convert Simple Icons emoji syntax to local SVG references |
| 4 | +# This is a workaround for Zensical not supporting Simple Icons yet |
| 5 | + |
| 6 | +# Icon mapping: :simple-name: -> filename.svg |
| 7 | +declare -A ICON_MAP=( |
| 8 | + ["simple-asana"]="asana" |
| 9 | + ["simple-azuredevops"]="azuredevops" |
| 10 | + ["simple-clubhouse"]="clubhouse" |
| 11 | + ["simple-codereview"]="codereview" |
| 12 | + ["simple-dependabot"]="dependabot" |
| 13 | + ["simple-githubactions"]="githubactions" |
| 14 | + ["simple-html5"]="html5" |
| 15 | + ["simple-javascript"]="javascript" |
| 16 | + ["simple-python"]="python" |
| 17 | + ["simple-renovatebot"]="renovatebot" |
| 18 | + ["simple-ruby"]="ruby" |
| 19 | + ["simple-slack"]="slack" |
| 20 | + ["simple-snyk"]="snyk" |
| 21 | + ["simple-sonarcloud"]="sonarcloud" |
| 22 | + ["simple-zapier"]="zapier" |
| 23 | +) |
| 24 | + |
| 25 | +# Function to convert Simple Icon syntax to local SVG |
| 26 | +# Example: [:simple-sonarcloud: SonarCloud](/path) |
| 27 | +# Becomes: [{ width="20" } SonarCloud](/path) |
| 28 | + |
| 29 | +convert_file() { |
| 30 | + local file="$1" |
| 31 | + local backup="${file}.bak" |
| 32 | + |
| 33 | + echo "Converting: $file" |
| 34 | + |
| 35 | + # Create backup |
| 36 | + cp "$file" "$backup" |
| 37 | + |
| 38 | + # Convert each Simple Icon |
| 39 | + for icon_name in "${!ICON_MAP[@]}"; do |
| 40 | + local svg_file="${ICON_MAP[$icon_name]}" |
| 41 | + |
| 42 | + # Replace [:simple-name: Text](link) with [{ width="20" } Text](link) |
| 43 | + sed -i.tmp "s|\[:${icon_name}: \([^]]*\)\](\([^)]*\))|[{ width=\"20\" } \1](\2)|g" "$file" |
| 44 | + rm -f "${file}.tmp" |
| 45 | + done |
| 46 | + |
| 47 | + echo "✓ Converted $file (backup saved as $backup)" |
| 48 | +} |
| 49 | + |
| 50 | +# Main script |
| 51 | +if [ $# -eq 0 ]; then |
| 52 | + echo "Usage: $0 <markdown-file> [<markdown-file> ...]" |
| 53 | + echo "" |
| 54 | + echo "Example:" |
| 55 | + echo " $0 docs/integrations/README.md" |
| 56 | + echo "" |
| 57 | + echo "This converts Simple Icons emoji syntax to local SVG references." |
| 58 | + exit 1 |
| 59 | +fi |
| 60 | + |
| 61 | +for file in "$@"; do |
| 62 | + if [ -f "$file" ]; then |
| 63 | + convert_file "$file" |
| 64 | + else |
| 65 | + echo "⚠ File not found: $file" |
| 66 | + fi |
| 67 | +done |
| 68 | + |
| 69 | +echo "" |
| 70 | +echo "Done! Test the changes and remove .bak files if satisfied." |
0 commit comments