Skip to content

fix(clipboard): preserve table cell line breaks and math - #1019

Merged
eszlamczyk merged 2 commits into
mainfrom
fix/html-clipboard-round-trips
Oct 16, 2026
Merged

eszlamczyk merged 2 commits into
mainfrom
fix/html-clipboard-round-trips

Conversation

@hryhoriiK97

Copy link
Copy Markdown
Collaborator

What/Why?

Copying a table loses two things: HTML export writes cell line separators through as whitespace, which receiving apps collapse, and Copy as Markdown drops the $…$ around inline equations. The HTML escapers now emit <br> for line separators outside code blocks, with CRLF as one break, and both markdown serializers emit LatexMathInline with its delimiters.

This carries @Yash-Singh1's #995 (3be6e76, here 8d688af) unchanged as the first commit, rebased onto current main, plus one follow-up. #995 comes from an organization-owned fork, which GitHub does not let maintainers push to, so the follow-up lands here. #995 stays open for the discussion there and closes when this merges; both commits keep their authorship.

Closes #992.

Follow-up commit on top of #995

  • iOS collectParagraphsData split blocks with lineRangeForRange:, which treats the U+2028 a hard break renders as like a paragraph end. A paragraph with a hard break already exported as two <p> blocks and a list item as two <li> items, and with the new <br> escaping the first half gained a trailing <br>. It now splits with paragraphRangeForRange:, so the break stays inside its block and comes out as <p>line one<br>line two</p>. Android renders hard breaks as \n, which its splitter also treats as a block end, so this PR does not change Android's hard-break export; that needs a marker on the break and is separate work.
  • Tests are named by feature like fix: size ordered list markers to their widest number #1015: ClipboardExportTests.mm and ClipboardExportTest.kt, since both cover HTML and Markdown export. Added on top of the PR's cases: a rendered hard-break paragraph and list item on iOS, the code block gate on Android, a run mixing escaped characters with a line break, and math nested in strong, on both platforms. The Android style map gained the spoiler, superscript and subscript entries the renderer resolves eagerly.

Notes

  • Table cells cannot hold a line break from markdown today: <br> stays literal with HTML spans disabled and a backslash break ends the row. Once fix(parser): preserve named and numeric character references #1018 merges, | a&#10;b | decodes to a real newline in the cell and this PR's escaper is what turns it into <br>, so the separator cases are the right coverage for that. A rendered end-to-end case through the parser is worth adding after fix(parser): preserve named and numeric character references #1018.
  • Spoiler is missing from both markdown serializers in the same way math was, so ||x|| in a cell also loses its delimiters on Copy as Markdown. Left for a separate change.

Testing

  • Example app's iOS unit-test target on iPhone 17 / iOS 26.5: 12 tests green, 5 in this suite.
  • RN Android Robolectric ClipboardExportTest through the example's Gradle host: 4 tests green.
  • clang-format, ktlint and commitlint pass via the commit hooks.

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable, no public API change
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added, unit tests cover the exporters; no Maestro flow exercises table copy yet

🤖 Generated with Claude Code

Yash-Singh1 and others added 2 commits October 16, 2026 18:07
collectParagraphsData split on lineRangeForRange:, which treats the U+2028
a hard break renders as like a paragraph end. A paragraph with a hard break
exported as two <p> blocks and a list item as two <li> items, and with the
new <br> escaping the first half gained a trailing <br>. Split on
paragraphRangeForRange: so the break stays in its block and becomes
<p>line one<br>line two</p>.

Tests are named by feature like #1015: ClipboardExportTests.mm and
ClipboardExportTest.kt, since both cover HTML and Markdown export. Added a
rendered hard-break case on iOS, the code block gate on Android, a run that
mixes escaped characters with a line break, and math nested in strong, on
both platforms.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@eszlamczyk
eszlamczyk merged commit c685fb3 into main Oct 16, 2026
14 checks passed
@eszlamczyk
eszlamczyk deleted the fix/html-clipboard-round-trips branch October 16, 2026 18:46
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.

Table copying loses cell line breaks and inline math delimiters

3 participants