Skip to content

fix(docs-infra): fix code block deindentation in docs-code and docs-code-block#68566

Open
swseverance wants to merge 2 commits intoangular:mainfrom
swseverance:docs/fix-indentation
Open

fix(docs-infra): fix code block deindentation in docs-code and docs-code-block#68566
swseverance wants to merge 2 commits intoangular:mainfrom
swseverance:docs/fix-indentation

Conversation

@swseverance
Copy link
Copy Markdown
Contributor

Consolidates deindentation logic into formatCode so both docs-code and docs-code-block are covered by a single fix. The original deindent function incorrectly iterated over blank lines instead of non-blank lines when computing minimum indentation, causing code blocks to render with excessive leading whitespace. Also fixes region extraction which had the same trim-before-deindent ordering issue.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • [] Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

The indentation of many of the code samples is showing up incorrectly. For example:

image

Issue Number: N/A

What is the new behavior?

Leading indentation is properly stripped from code samples

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

…ode-block

Consolidates deindentation logic into formatCode so both docs-code and
docs-code-block are covered by a single fix. The original deindent
function incorrectly iterated over blank lines instead of non-blank
lines when computing minimum indentation, causing code blocks to render
with excessive leading whitespace. Also fixes region extraction which
had the same trim-before-deindent ordering issue.
@pullapprove pullapprove Bot requested a review from alan-agius4 May 5, 2026 01:50
@angular-robot angular-robot Bot added the area: docs-infra Angular.dev application and infrastructure label May 5, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 5, 2026
@alan-agius4 alan-agius4 requested review from JeanMeche May 5, 2026 13:00
Comment on lines +63 to +64
expect(codeBlock?.textContent).not.toContain(' // bar');
expect(codeBlock?.textContent).toContain(' // bar');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(codeBlock?.textContent).not.toContain(' // bar');
expect(codeBlock?.textContent).toContain(' // bar');
expect(codeBlock?.textContent).toMatch(/^ \/\/ bar/);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeanMeche updated to your suggestion with a small modification (the addition of the "m" flag to the regex)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Deployed adev-preview for b157589 to: https://ng-dev-previews-fw--pr-angular-angular-68566-adev-prev-5yfepf5l.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Replace two toContain assertions with a single toMatch
using a multiline regex, per reviewer suggestion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adev: preview area: docs-infra Angular.dev application and infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants