Skip to content

fix: Make normalizers switch codeblock newlines to <p> tags - #891

Merged
szydlovsky merged 2 commits into
mainfrom
@szydlovsky/handle-codeblock-newlines-in-parsers
Nov 30, 2026
Merged

szydlovsky merged 2 commits into
mainfrom
@szydlovsky/handle-codeblock-newlines-in-parsers

Conversation

@szydlovsky

@szydlovsky szydlovsky commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When working on other parser-related PRs, CodeRabbit found out that we can have content newlines inside codeblocks even after normalization step. The fix is relatively simple - if they exist, we instead map them to separate <p> tags. It's applied on both mobile Gumbo normalizer as well as the dedicated Web one.

Test Plan

Use setValue on an external html like:

<pre>if (x) {
  y();
}</pre>

on any of the three platforms. It should be properly shown as three separate lines;

<codeblock>
<p>if (x) {</p>
<p>  y();</p>
<p>}</p>
</codeblock>

Screenshots / Videos

--

Compatibility

OS Implemented
iOS ✅
Android ✅
Web ✅

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@szydlovsky
szydlovsky requested a review from exploIF November 30, 2026 09:41
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0a65652 and d068a49.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Inline code-block content now becomes one paragraph per line break in both the C++ and TypeScript normalizers. Empty interior lines emit <br>, inline tags are reopened across lines, and content with block-producing children keeps its existing direct-walk path.

Changes: Code block line normalization

Layer / File(s) Summary
Inline code-block line emission
cpp/parser/GumboNormalizer.c, cpp/tests/GumboParserTest.cpp, src/web/normalization/htmlNormalizer.ts, src/web/__tests__/htmlNormalizer.test.ts
Both normalizers split inline code-block content at newlines and <br> tags, preserve indentation, and reopen inline tags across paragraphs. Empty interior lines emit <br>, trailing empty lines are omitted, and block-producing children still use the direct-walk path. Tests cover these cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: kacperzolkiewski, hejsztynx

Merge Risk: Minimal · previous review 0a656

This change makes multi-line code blocks keep their line breaks as separate paragraphs in the native and Web normalizers. The change is contained to code-block normalization and has unit tests for the main line-splitting cases. No concrete merge-blocking problem was established. The remaining uncertainty is how the iOS parser handles empty code lines, which is worth checking in the manual test pass.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names the main change: normalizers now convert codeblock newlines into separate

tags. The raw summary confirms this change in the Gumbo normalizer (C), its tests, and the Web normalizer.…

Description check Passed The description states that content newlines inside codeblocks remain after normalization and are now mapped to separate

tags in both the mobile Gumbo normalizer and the Web normalizer. It also gi…

Full details: Title check

Explanation

The title names the main change: normalizers now convert codeblock newlines into separate <p> tags. The raw summary confirms this change in the Gumbo normalizer (C), its tests, and the Web normalizer. The title does not name the tests or the br handling, which is acceptable.

Full details: Description check

Explanation

The description states that content newlines inside codeblocks remain after normalization and are now mapped to separate <p> tags in both the mobile Gumbo normalizer and the Web normalizer. It also gives a test plan with a sample <pre> input and the expected output. This matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8fadac6 and 0a65652.

Files selected for processing: 4

  • cpp/parser/GumboNormalizer.c
  • cpp/tests/GumboParserTest.cpp
  • src/web/__tests__/htmlNormalizer.test.ts
  • src/web/normalization/htmlNormalizer.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@szydlovsky szydlovsky changed the title fix: Nake normalizers switch codeblock newlines to <p> tags fix: Make normalizers switch codeblock newlines to <p> tags Nov 30, 2026
@szydlovsky
szydlovsky merged commit a663be0 into main Nov 30, 2026
10 checks passed
@szydlovsky
szydlovsky deleted the @szydlovsky/handle-codeblock-newlines-in-parsers branch November 30, 2026 14:19
@coderabbitai coderabbitai Bot mentioned this pull request Dec 1, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants