Skip to content

Commit

Permalink
Make sure there is exactly one empty line before any heading
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 12, 2024
1 parent 556aca7 commit 7ac32bb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions monorepo/scripts/docs/MarkdownFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ protected function run(): void
$new_lines[] = '';
}

// Make sure there are two empty lines before level 2 headings (but not if it's the first l2 heading)
// DEPRECATED: No longer desired style
if ($is_inside_fenced_code_block !== true && str_starts_with($line, '## ') && $index > $firstHeadingLevel + 3) {
// Make sure there is exactly one empty line before any heading
if (! $is_inside_fenced_code_block && preg_match('/^#{1,6} /', $line) && trim($last_line) != '') {
$new_lines[] = '';
}

Expand All @@ -88,7 +87,7 @@ protected function run(): void
}

// Check if line is a heading
if (str_starts_with($line, '##')) {
if (preg_match('/^#{1,6} /', $line)) {
$was_last_line_heading = true;
global $headings;
$headings[$filename][$index + 1] = $line;
Expand Down

0 comments on commit 7ac32bb

Please sign in to comment.