GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(mobile): iOS Copy as Markdown keeps bold spans whole by juliusmarminge · Pull Request #29020 · pingdotgg/t3code Conversation
|
| Selection | Before (05c0ed7) | After (353af61) |
|---|---|---|
| R1: What at the start of a list item (the report) | - **W****hat** |
- **What** |
| R2: What: something happen (partial first item) | - **W****hat**: something happen |
- **What**: something happen |
| R3: Why: see docs for details (bold lead-in and link) | - **W****hy**: see [docs](https://example.com/docs) for details |
- **Why**: see [docs](https://example.com/docs) for details |
| R4: bold inside a paragraph (control) | **bold** |
**bold** |
Clipboard as iOS shows it in the keyboard paste bar, per row:
The paste bar cuts off R3's long value. Here is R3 pasted into the composer, which wraps the full string:
agent-device clipboard read transcript, with the installed app bundles:
The rendered message is byte-identical before and after (same crops), so a rendering diff proves nothing here; the clipboard strings are the proof. In R3 and R4 the iOS edit menu covers part of the message above the selection; the selected text stays visible.
Before (05c0ed7):
After (353af61):
- **What**. The text was pasted into the composer (adb cannot read the clipboard on API 36); the capture is from a forked copy of the same thread. Android was not affected and its code is unchanged.#!/usr/bin/env bash # Seeds one thread whose assistant reply has a bold list lead-in, a link, and inline bold. # Run from a t3code checkout with `T3CODE_DEV_SEED=0 vp run dev --host 0.0.0.0` running. set -euo pipefail base="$PWD/.t3"; proj="$(mktemp -d)"; git -C "$proj" init -q; echo "# demo" > "$proj/README.md" cd apps/server node src/bin.ts project add --base-dir "$base" --title "Copy markdown demo" "$proj" node src/bin.ts thread start --base-dir "$base" --title "Bold lead-in" --provider claudeAgent --model claude-sonnet-5-5 --wait "$proj" - <<'P' Reply with exactly the following markdown, verbatim, and nothing else. Do not use any tools. - **What**: something happened - **Why**: see [docs](https://example.com/docs) for details Plain paragraph with **bold words** inside. P
# drive-open.sh #!/usr/bin/env bash # Opens T3 Code Dev against Metro, pairs with the dev server, and opens the seeded "Bold lead-in" thread. set -euo pipefail s="$1"; repo=/home/ubuntu/wt/issue-29012 agent-device open com.t3tools.t3code.dev "t3code-dev://expo-development-client/?url=http%3A%2F%2Ffs-43.tail131df4.ts.net%3A8081&disableAutoLaunch=1&disableFab=1" --session "$s" >/dev/null agent-device wait 3000 --session "$s" >/dev/null agent-device press 275 474 --session "$s" >/dev/null # iOS "Open in T3 Code Dev?" -> Open agent-device wait 45000 --session "$s" >/dev/null (cd "$repo" && .agents/skills/test-t3-mobile/scripts/pair-client.sh 15590 "$repo/.t3" http://fs-43.tail131df4.ts.net:15590 agent-device --session "$s") agent-device wait 8000 --session "$s" >/dev/null
# drive-rows.sh #!/usr/bin/env bash # Usage: drive-rows.sh <session> <label> <outdir> # For each row: select text in the seeded reply, Copy as Markdown, log `agent-device clipboard read`, # then focus the composer so the iOS keyboard's "Paste from T3 Code Dev" suggestion shows the clipboard. set -euo pipefail s="$1"; label="$2"; out="$3"; mkdir -p "$out"; log="$out/clipboard-$label.txt" ad() { agent-device "$@" --session "$s" >/dev/null; } reset() { ad press 36 84; ad wait 2500; ad press 90 237; ad wait 4000; } # back to the list, reopen "Bold lead-in" row() { local name="$1" menuY="$2" ad wait 1000; agent-device screenshot "$out/$label-$name-selection.png" --session "$s" >/dev/null ad press 169 "$menuY"; ad wait 800 printf '%s\t%s\t' "$label" "$name" >> "$log"; agent-device clipboard read --session "$s" | tail -1 >> "$log" ad press 180 809; ad wait 1500 agent-device screenshot "$out/$label-$name-clipboard.png" --session "$s" >/dev/null reset } date -u '+# %Y-%m-%dT%H:%M:%SZ' >> "$log" reset ad longpress 56 664; ad wait 1200; row R1-what 616 ad longpress 56 664; ad wait 1200; ad gesture pan 77 683 220 4 900; ad wait 1000; ad gesture pan 242 683 -20 24 900; row R2-partial 616 ad longpress 40 688; ad wait 1200; ad gesture pan 70 705 160 2 900; row R3-why-link 638 ad longpress 195 719; ad wait 1200; row R4-inline-bold 670 cat "$log"
From c000d6ba8fdd4c87e60323c953656e9ddf7b580b Mon Sep 17 00:00:00 2001 From: Dan Sanduleac <[email protected]> Date: Mon, 2 Nov 2026 10:11:59 +0800 Subject: [PATCH] fix(ios): Copy as Markdown no longer splits bold after the first character Copying a selection like **What** from a list item gave **W****hat**: the extractor wrapped each attribute run separately, and runs also split on attributes with no inline meaning, such as the list-marker anchor on an item's first grapheme. Runs with the same inline delimiters as the segment that still ends the output now extend that span. Co-Authored-By: Claude Opus 5.5 <[email protected]> --- .../ios/ENRMMarkdownExtractorTests.mm | 52 +++++++++++++ .../ios/utils/MarkdownExtractor.m | 75 ++++++++++++++----- 2 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 packages/react-native-enriched-markdown/__tests__/ios/ENRMMarkdownExtractorTests.mm diff --git a/packages/react-native-enriched-markdown/__tests__/ios/ENRMMarkdownExtractorTests.mm b/packages/react-native-enriched-markdown/__tests__/ios/ENRMMarkdownExtractorTests.mm new file mode 100644 index 00000000..19b87273 --- /dev/null +++ b/packages/react-native-enriched-markdown/__tests__/ios/ENRMMarkdownExtractorTests.mm @@ -0,0 +1,52 @@ +#import "ListItemRenderer.h" +#import "MarkdownExtractor.h" +#import <XCTest/XCTest.h> + +@interface ENRMMarkdownExtractorTests : XCTestCase +@end + +@implementation ENRMMarkdownExtractorTests + +- (UIFont *)enrmExtractorBoldFont +{ + return [UIFont boldSystemFontOfSize:16]; +} + +- (void)testBoldSplitAcrossAttributeRunsCopiesAsOneSpan +{ + NSMutableAttributedString *text = + [[NSMutableAttributedString alloc] initWithString:@"What" + attributes:@{NSFontAttributeName : [self enrmExtractorBoldFont]}]; + // Any attribute without inline meaning splits the run after the first character. + [text addAttribute:@"ENRMTestUnrelatedAttribute" value:@YES range:NSMakeRange(0, 1)]; + + XCTAssertEqualObjects(extractMarkdownFromAttributedString(text, NSMakeRange(0, text.length)), @"**What**"); +} + +- (void)testBoldAtListItemStartCopiesAsOneSpan +{ + NSDictionary *listAttrs = @{ + ListDepthAttribute : @0, + ListTypeAttribute : @0, + ListItemNumberAttribute : @1, + }; + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"What: next" + attributes:listAttrs]; + [text addAttribute:NSFontAttributeName value:[self enrmExtractorBoldFont] range:NSMakeRange(0, 4)]; + [text addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(4, 6)]; + // ListItemRenderer anchors the bullet marker on the item's first grapheme. + [text addAttribute:ListItemMarkerStartAttribute value:@[] range:NSMakeRange(0, 1)]; + + XCTAssertEqualObjects(extractMarkdownFromAttributedString(text, NSMakeRange(0, text.length)), @"- **What**: next"); +} + +- (void)testAdjacentRunsWithDifferentFormattingStayWrappedSeparately +{ + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"ab"]; + [text addAttribute:NSFontAttributeName value:[self enrmExtractorBoldFont] range:NSMakeRange(0, 1)]; + [text addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:16] range:NSMakeRange(1, 1)]; + + XCTAssertEqualObjects(extractMarkdownFromAttributedString(text, NSMakeRange(0, text.length)), @"**a***b*"); +} + +@end diff --git a/packages/react-native-enriched-markdown/ios/utils/MarkdownExtractor.m b/packages/react-native-enriched-markdown/ios/utils/MarkdownExtractor.m index 90c84501..9eabb232 100644 --- a/packages/react-native-enriched-markdown/ios/utils/MarkdownExtractor.m +++ b/packages/react-native-enriched-markdown/ios/utils/MarkdownExtractor.m @@ -83,42 +83,55 @@ static void extractFontTraits(NSDictionary *attrs, BOOL *isBold, BOOL *isItalic, } } -static NSString *applyInlineFormatting(NSString *text, BOOL isBold, BOOL isItalic, BOOL isMonospace, - BOOL isStrikethrough, BOOL isUnderline, BOOL isSuperscript, BOOL isSubscript, - BOOL isHighlight, NSString *linkURL) +/// Builds the opening and closing Markdown delimiters for one run's inline formatting. +/// The run's text goes between them. Both are empty when the run has no inline formatting. +static void buildInlineDelimiters(BOOL isBold, BOOL isItalic, BOOL isMonospace, BOOL isStrikethrough, BOOL isUnderline, + BOOL isSuperscript, BOOL isSubscript, BOOL isHighlight, NSString *linkURL, + NSString **outOpen, NSString **outClose) { - NSMutableString *result = [NSMutableString stringWithString:text]; + NSMutableString *open = [NSMutableString string]; + NSMutableString *close = [NSMutableString string]; // Innermost first if (isMonospace && !linkURL) { - result = [NSMutableString stringWithFormat:@"`%@`", result]; + [open insertString:@"`" atIndex:0]; + [close appendString:@"`"]; } if (isStrikethrough) { - result = [NSMutableString stringWithFormat:@"~~%@~~", result]; + [open insertString:@"~~" atIndex:0]; + [close appendString:@"~~"]; } if (isSubscript) { - result = [NSMutableString stringWithFormat:@"~%@~", result]; + [open insertString:@"~" atIndex:0]; + [close appendString:@"~"]; } if (isSuperscript) { - result = [NSMutableString stringWithFormat:@"^%@^", result]; + [open insertString:@"^" atIndex:0]; + [close appendString:@"^"]; } if (isUnderline && !linkURL) { - result = [NSMutableString stringWithFormat:@"<u>%@</u>", result]; + [open insertString:@"<u>" atIndex:0]; + [close appendString:@"</u>"]; } if (isItalic) { - result = [NSMutableString stringWithFormat:@"*%@*", result]; + [open insertString:@"*" atIndex:0]; + [close appendString:@"*"]; } if (isBold) { - result = [NSMutableString stringWithFormat:@"**%@**", result]; + [open insertString:@"**" atIndex:0]; + [close appendString:@"**"]; } if (linkURL) { - result = [NSMutableString stringWithFormat:@"[%@](%@)", result, linkURL]; + [open insertString:@"[" atIndex:0]; + [close appendFormat:@"](%@)", linkURL]; } if (isHighlight) { - result = [NSMutableString stringWithFormat:@"==%@==", result]; + [open insertString:@"==" atIndex:0]; + [close appendString:@"=="]; } - return result; + *outOpen = open; + *outClose = close; } #pragma mark - Main Extraction Function @@ -139,6 +152,14 @@ NSString *_Nullable extractMarkdownFromAttributedString(NSAttributedString *attr __block NSMutableString *headingContent = nil; __block ExtractionState state = {.blockquoteDepth = -1, .listDepth = -1, .needsBlankLine = NO}; + // The last formatted inline segment appended to `result`, so the next run can extend it. + // Attribute runs split on attributes that carry no inline formatting (e.g. the list-marker + // anchor on an item's first character), and wrapping each run on its own would turn + // **What** into **W****hat**. + __block NSString *lastInlineOpen = nil; + __block NSString *lastInlineClose = nil; + __block NSUInteger lastInlineEnd = NSNotFound; + void (^flushHeading)(void) = ^{ if (!currentHeadingType || headingContent.length == 0) return; @@ -318,9 +339,26 @@ NSString *_Nullable extractMarkdownFromAttributedString(NSAttributedString *attr BOOL isHighlight = [attrs[HighlightAttributeName] boolValue]; NSString *linkURL = recognizedLink ? nil : attrs[NSLinkAttributeName]; - NSString *segment = - applyInlineFormatting(text, isBold, isItalic, isMonospace, isStrikethrough, isUnderline, - isSuperscript, isSubscript, isHighlight, linkURL); + NSString *inlineOpen = nil; + NSString *inlineClose = nil; + buildInlineDelimiters(isBold, isItalic, isMonospace, isStrikethrough, isUnderline, + isSuperscript, isSubscript, isHighlight, linkURL, &inlineOpen, + &inlineClose); + + // Same formatting as the segment that still ends `result`: move its closing + // delimiters past this run's text instead of opening a new span. + if (inlineClose.length > 0 && result.length == lastInlineEnd && !state.needsBlankLine && + [inlineOpen isEqualToString:lastInlineOpen] && + [inlineClose isEqualToString:lastInlineClose]) { + [result deleteCharactersInRange:NSMakeRange(result.length - inlineClose.length, + inlineClose.length)]; + [result appendString:text]; + [result appendString:inlineClose]; + lastInlineEnd = result.length; + return; + } + + NSString *segment = [NSString stringWithFormat:@"%@%@%@", inlineOpen, text, inlineClose]; // Add block prefixes at line start if (isAtLineStart(result)) { @@ -354,6 +392,9 @@ NSString *_Nullable extractMarkdownFromAttributedString(NSAttributedString *attr } [result appendString:segment]; + lastInlineOpen = inlineOpen; + lastInlineClose = inlineClose; + lastInlineEnd = result.length; }]; // Flush remaining heading -- 2.43.0
Created with Claude Opus 5.5 in Claude Code (T3 Code issue flow).
🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Copying a bold lead-in such as "- **What**: ..." on iOS put "- **W****hat**" on the clipboard: the vendored Enriched Markdown extractor wrapped each attribute run on its own, and the list-marker anchor splits a list item's first character into its own run. Bump the vendored tarball to 29ddd424 plus pingdotgg/enriched-markdown#12, which extends the previous span when the next run has identical inline delimiters. Fixes #29012 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The dependency update keeps identically formatted iOS text runs together when copying Markdown. Source inspection and reported simulator verification support a narrowly scoped clipboard-formatting fix, with Android and JavaScript unchanged. You can add or adjust custom eligibility rules. Learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Update the enriched Markdown fork apps/mobile/package.json, pnpm-workspace.yaml, apps/mobile/deps/README.md |
The mobile dependency and workspace build permission now reference the c000d6ba tarball. The README adds the iOS Copy as Markdown fix to the fork changes. |
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: yash-singh1, t3dotgg
9478dThe dependency update is internally consistent and targets the reported iOS Markdown-copy issue.
Explanation
The title "fix(mobile): iOS Copy as Markdown keeps bold spans whole" is a conventional commit that names the main change: the iOS Copy as Markdown bold-span fix. The changeset is a vendored dependency tarball bump (react-native-enriched-markdown from 29ddd424 to c000d6ba) that carries the extractor fix, plus a README note and matching path updates in package.json and pnpm-workspace.yaml. The title reflects the user-visible result of that bump, so it is related to the main change.
Explanation
Issue [#29012] requires the iOS Markdown extractor to keep bold and linked spans intact across attribute runs and to update the vendored tarball. The PR updates the tarball to c000d6ba, whose MarkdownExtractor.m extends a prior span when inline delimiters match. The included XCTest cases cover split bold text, list-item bold text, and separate formatting runs. The reported iOS result changes - **W****hat** to - **What**, and the link case is included in the verification matrix.
Explanation
The changes are limited to the vendored dependency update, its package and workspace references, the dependency README, and the lockfile update described by the PR. These changes support issue [#29012] by selecting and documenting the extractor fix. The reported Android and rendering behavior remains unchanged.
Explanation
The pull request includes complete Problem, Change, Scope and approval, and Verification sections. It explains the defect, implementation, issue reference, test results, manual before-and-after evidence, platform coverage, and known limitations.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing as superseded: this fix is already on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
iOS "Copy as Markdown" inserts "****" after the first character of bold text
There was an error while loading. Please reload this page.