| 
 | 1 | +# Indent Fixes Scripts  | 
 | 2 | + | 
 | 3 | +These scripts detect and fix incorrectly indented bullet lists in markdown files. This issue occurred during the content reorganization (PRs #16119, #16303) where bullet lists were inadvertently indented with 4 spaces, causing Hugo to render them as code blocks instead of proper lists.  | 
 | 4 | + | 
 | 5 | +## The Problem  | 
 | 6 | + | 
 | 7 | +In markdown, 4 spaces of indentation before a bullet point creates a code block instead of a list item:  | 
 | 8 | + | 
 | 9 | +```markdown  | 
 | 10 | +<!-- WRONG: Renders as code block -->  | 
 | 11 | +    - This is a bullet point  | 
 | 12 | +    - Another bullet point  | 
 | 13 | + | 
 | 14 | +<!-- CORRECT: Renders as list -->  | 
 | 15 | +- This is a bullet point  | 
 | 16 | +- Another bullet point  | 
 | 17 | +```  | 
 | 18 | + | 
 | 19 | +During the content reorganization, some bullet lists were accidentally indented with 4 spaces, breaking their rendering on the website.  | 
 | 20 | + | 
 | 21 | +## Usage  | 
 | 22 | + | 
 | 23 | +### Quick Start  | 
 | 24 | + | 
 | 25 | +From the repository root:  | 
 | 26 | + | 
 | 27 | +```bash  | 
 | 28 | +cd scripts/indent-fixes  | 
 | 29 | + | 
 | 30 | +# Step 1: Detect issues  | 
 | 31 | +python3 detect_indent_issues.py  | 
 | 32 | + | 
 | 33 | +# Step 2: Review the report, then fix all issues  | 
 | 34 | +python3 fix_indent_issues.py  | 
 | 35 | + | 
 | 36 | +# Step 3: Verify the changes  | 
 | 37 | +git diff content/docs/  | 
 | 38 | +```  | 
 | 39 | + | 
 | 40 | +### Step 1: Detection  | 
 | 41 | + | 
 | 42 | +Run the detection script to find all problematic indentations:  | 
 | 43 | + | 
 | 44 | +```bash  | 
 | 45 | +python3 detect_indent_issues.py  | 
 | 46 | +```  | 
 | 47 | + | 
 | 48 | +This will output:  | 
 | 49 | +- Summary count of files with issues  | 
 | 50 | +- Line-by-line listing of each problematic indentation  | 
 | 51 | +- Total count of issues found  | 
 | 52 | + | 
 | 53 | +**Example output:**  | 
 | 54 | +```  | 
 | 55 | +Found 14 files with potential indentation issues:  | 
 | 56 | +
  | 
 | 57 | +content/docs/iac/get-started/aws/next-steps.md: 5 issue(s)  | 
 | 58 | +  Line 22:     - Created a Pulumi new project.  | 
 | 59 | +  Line 23:     - Provisioned a new S3 bucket.  | 
 | 60 | +  Line 24:     - Turned it into a static website.  | 
 | 61 | +  Line 25:     - Created a website component for easy reuse.  | 
 | 62 | +  Line 26:     - Destroyed all of the resources you've provisioned.  | 
 | 63 | +
  | 
 | 64 | +Total: 66 potential issues across 14 files  | 
 | 65 | +```  | 
 | 66 | + | 
 | 67 | +### Step 2: Fix Issues  | 
 | 68 | + | 
 | 69 | +After reviewing the detection report, run the fix script:  | 
 | 70 | + | 
 | 71 | +```bash  | 
 | 72 | +python3 fix_indent_issues.py  | 
 | 73 | +```  | 
 | 74 | + | 
 | 75 | +This will:  | 
 | 76 | +- Process all markdown files in `content/docs/`  | 
 | 77 | +- Remove 4-space indentation from incorrectly indented bullet points  | 
 | 78 | +- Report the number of lines fixed per file  | 
 | 79 | + | 
 | 80 | +**Example output:**  | 
 | 81 | +```  | 
 | 82 | +Fixed 66 lines across 14 files:  | 
 | 83 | +
  | 
 | 84 | +  content/docs/iac/get-started/aws/next-steps.md: 5 line(s) fixed  | 
 | 85 | +  content/docs/iac/get-started/azure/destroy-stack.md: 5 line(s) fixed  | 
 | 86 | +  content/docs/iac/get-started/azure/next-steps.md: 3 line(s) fixed  | 
 | 87 | +  ...  | 
 | 88 | +```  | 
 | 89 | + | 
 | 90 | +### Step 3: Verify Changes  | 
 | 91 | + | 
 | 92 | +Review the changes made by the script:  | 
 | 93 | + | 
 | 94 | +```bash  | 
 | 95 | +# View summary of changes  | 
 | 96 | +git diff --stat content/docs/  | 
 | 97 | + | 
 | 98 | +# View detailed changes  | 
 | 99 | +git diff content/docs/  | 
 | 100 | + | 
 | 101 | +# Test the build  | 
 | 102 | +make build  | 
 | 103 | +```  | 
 | 104 | + | 
 | 105 | +## How It Works  | 
 | 106 | + | 
 | 107 | +### Detection Logic  | 
 | 108 | + | 
 | 109 | +The `detect_indent_issues.py` script intelligently identifies problematic indentations while avoiding false positives:  | 
 | 110 | + | 
 | 111 | +**What it detects:**  | 
 | 112 | +- Lines matching the pattern `^    - ` (4 spaces + dash + space)  | 
 | 113 | +- In markdown content sections (not frontmatter or code blocks)  | 
 | 114 | + | 
 | 115 | +**What it excludes:**  | 
 | 116 | +- **YAML frontmatter**: Indentation between `---` markers is correct YAML syntax  | 
 | 117 | +- **Code blocks**: Content within ` ``` ` fences is left untouched  | 
 | 118 | +- **Nested lists**: Legitimate 2nd-level list items (preceded by 2-space indented parent)  | 
 | 119 | +- **YAML-like structures**: Content that looks like YAML configuration blocks  | 
 | 120 | + | 
 | 121 | +### Fix Logic  | 
 | 122 | + | 
 | 123 | +The `fix_indent_issues.py` script:  | 
 | 124 | + | 
 | 125 | +1. Uses the same detection logic to identify problematic lines  | 
 | 126 | +2. Removes exactly 4 spaces from the beginning of each line  | 
 | 127 | +3. Writes the corrected content back to the file  | 
 | 128 | +4. Reports the number of changes made  | 
 | 129 | + | 
 | 130 | +**Safety features:**  | 
 | 131 | +- Only modifies lines that match the detection criteria  | 
 | 132 | +- Preserves all other formatting (newlines, trailing spaces, etc.)  | 
 | 133 | +- Non-destructive: Can be reviewed with `git diff` before committing  | 
 | 134 | + | 
 | 135 | +## When to Use These Scripts  | 
 | 136 | + | 
 | 137 | +- **After content reorganizations**: When files are moved/renamed, indentation issues may be introduced  | 
 | 138 | +- **When rendering issues occur**: If bullet lists appear as code blocks on the site  | 
 | 139 | +- **Periodic audits**: Run detection periodically to catch any new issues  | 
 | 140 | + | 
 | 141 | +## Workflow  | 
 | 142 | + | 
 | 143 | +1. Make content changes or complete a reorganization  | 
 | 144 | +2. Run `python3 detect_indent_issues.py` to check for issues  | 
 | 145 | +3. Review the detection report  | 
 | 146 | +4. Run `python3 fix_indent_issues.py` to apply fixes  | 
 | 147 | +5. **IMPORTANT** -- Review changes with `git diff`! There *will* be false positives!  | 
 | 148 | +6. Run `make build` to verify the site builds correctly  | 
 | 149 | +7. Commit the fixes  | 
 | 150 | + | 
 | 151 | +## Exit Codes  | 
 | 152 | + | 
 | 153 | +Both scripts return:  | 
 | 154 | +- **0** - Success (issues found and reported, or no issues found)  | 
 | 155 | +- **Non-zero** - Unexpected error occurred  | 
 | 156 | + | 
 | 157 | +## Related  | 
 | 158 | + | 
 | 159 | +- See `scripts/alias-verification/` for tools to verify file move aliases  | 
 | 160 | +- See `STYLE-GUIDE.md` for markdown formatting guidelines  | 
 | 161 | + | 
 | 162 | +## History  | 
 | 163 | + | 
 | 164 | +These scripts were created to fix issues introduced during:  | 
 | 165 | +- PR #16119: Major documentation reorganization  | 
 | 166 | +- PR #16303: Insights & Governance docs reorganization  | 
 | 167 | + | 
 | 168 | +The fixes were partially addressed in:  | 
 | 169 | +- PR #16427: Fixed get-started guides  | 
 | 170 | +- PR #16428: Fixed next-steps pages  | 
 | 171 | + | 
 | 172 | +This toolset completes the remediation and provides ongoing verification.  | 
0 commit comments