@@ -170,22 +170,33 @@ func extractDescription(readme string) string {
170170 // Replace markdown links `[text](url)` with just `text`.
171171 s = regexp .MustCompile (`\[([^\]]+)\]\([^)]+\)` ).ReplaceAllString (s , "$1" )
172172
173- // Drop table lines and horizontal rules.
173+ // Drop table lines and horizontal rules, and flatten all leading
174+ // whitespace: generateYAMLEntry embeds this under a `description: |`
175+ // literal block whose indentation is set by the first non-empty line.
176+ // If any line has extra leading whitespace (e.g. from an indented
177+ // `<p align="center">` block in the original README), YAML will pick
178+ // that up as the block's indent and every later line at a smaller
179+ // indent blows the block scalar. Stripping leading whitespace here
180+ // guarantees uniform 4-space indentation after formatTextContent runs.
174181 var kept []string
175182 for _ , line := range strings .Split (s , "\n " ) {
176- t := strings .TrimSpace (line )
177- if strings .HasPrefix (t , "|" ) {
183+ t := strings .TrimLeft (line , " \t " )
184+ ts := strings .TrimSpace (t )
185+ if strings .HasPrefix (ts , "|" ) {
178186 continue
179187 }
180- if strings .HasPrefix (t , ":--" ) || strings .HasPrefix (t , "---" ) || strings .HasPrefix (t , "===" ) {
188+ if strings .HasPrefix (ts , ":--" ) || strings .HasPrefix (ts , "---" ) || strings .HasPrefix (ts , "===" ) {
181189 continue
182190 }
183- kept = append (kept , line )
191+ kept = append (kept , t )
184192 }
185193 s = strings .Join (kept , "\n " )
186194
187- // Normalise whitespace.
195+ // Normalise whitespace and drop any leading blank lines so the literal
196+ // block in YAML doesn't start with a blank first line (which would
197+ // break the indentation detector the same way).
188198 s = cleanTextContent (s )
199+ s = strings .TrimLeft (s , " \t \n " )
189200
190201 // Truncate at a paragraph boundary around maxLen chars.
191202 const maxLen = 1200
0 commit comments