Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web,mobile): match GitHub strikethrough parsing #9021

Closedahalekelly(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/9021/headopened View on GitHub

🤖 Generated by Claude Code

What

Chat markdown strikes through single-tilde pairs. GitHub only recognizes ~~double tildes~~, so GFM-shaped agent output renders wrong — most often when a reply contains several ~-prefixed estimates or ~/ paths. Real production example, before and after this fix:

BeforeAfter
beforeafter

(~$45B senior/~$30–35B junior → $45B senior/ gets struck through.)

Why it happens

  • Web: remark-gfm's strikethrough extension defaults to singleTilde: true — micromark matches the cmark-gfm library, but github.com itself only strikes double tildes. ChatMarkdown.tsx passes the plugin bare.

  • iOS: react-native-nitro-markdown vendors md4c, which also accepts single tildes — and with looser pairing rules than micromark, so iOS strikes far more often. md4c qualifies a closer by the character after the tilde (punctuation counts), micromark by the character before it (must be non-space). Measured against the vendored md4c with a standalone driver:

    InputwebiOS
    ~$0.48 vs ~$0.65 per runokstrikes $0.48 vs
    files in ~/foo and ~/barokstrikes /foo and
    takes ~50ms and ~2sokok
    drifted to ~$45B senior/~$30-35B juniorstrikesstrikes

    ~$ and ~/ are the two most common tilde patterns in agent output (cost estimates, home paths), so the mobile renderer hits this constantly.

Changes

  • Web: pass { singleTilde: false } to remark-gfm in both chat plugin arrays (exported so the test exercises the real config).
  • Regression test: asserts the production string above does strike under plain remark-gfm defaults and does not with the chat config; double-tilde strikethrough stays covered.
  • iOS: pnpm patch on react-native-nitro-markdown@0.5.8 restricting md4c's tilde mark collection to runs of exactly 2; $/$$ LaTeX spans share that code path and are unchanged. With the patch, every row in the table above renders literally and ~~x~~ still produces strikethrough (verified with the same driver). Long-term this belongs upstream in nitro-markdown/md4c; the patch keeps both renderers consistent with GitHub now.

All 160 existing web markdown tests pass; typecheck, lint, and format clean.

Aside

apps/mobile/package.json has a package-local overrides entry pointing at deps/react-native-nitro-markdown-0.5.0.tgz, but pnpm resolves 0.5.8 from the registry (package-local overrides don't apply in workspaces) — so the vendored tarball appears unused. Left untouched here; happy to file it separately.

Fixes #16105

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. @@ -0,0 +1,5 @@
      1+diff --git a/cpp/md4c/md4c.c b/cpp/md4c/md4c.c
      2+index b5316606ff6974d0217f4cdd4fa0241a6a542c5b..8c96839ee24705e5b530424d9e0fd3927b870b73 100644
      3+--- a/cpp/md4c/md4c.c
      4++++ b/cpp/md4c/md4c.c
      5+@@ -3308 +3308 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium patches/react-native-nitro-markdown@0.5.8.patch:6

      Tilde runs longer than two characters are rejected, so valid GFM input such as ~~~text~~~ renders as plain text instead of matching the strikethrough content. The exact tmp - off == 2 check must accept runs with at least two tildes, leaving any extras literal.

      Suggested change
      5-@@ -3308 +3308 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
      5+ if((ch == _T('$') && tmp - off <= 2) || (ch == _T('~') && tmp - off >= 2)) {
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @patches/react-native-nitro-markdown@0.5.8.patch around line 6:
      
      Tilde runs longer than two characters are rejected, so valid GFM input such as `~~~text~~~` renders as plain text instead of matching the strikethrough content. The exact `tmp - off == 2` check must accept runs with at least two tildes, leaving any extras literal.

      🤖 Generated by Claude Code

      ~~~text~~~ is not valid GFM strikethrough — the GFM spec defines strikethrough as text wrapped in one or two tildes, and cmark-gfm rejects longer delimiter runs, so github.com renders ~~~text~~~ as literal text. Try it in any GitHub comment.

      This patch also doesn't change that case: the original md4c condition tmp - off <= 2 never collected runs of 3+ tildes either, so they rendered literally before and after. Verified by compiling all three variants and parsing a ~~~three tildes~~~ b:

      Parserresult
      vanilla md4c (currently shipped)literal, no MD_SPAN_DEL
      patched md4c (this PR)literal, no MD_SPAN_DEL
      remark-gfm (web, default and singleTilde: false)literal, no <del>
      github.com (cmark-gfm)literal

      The suggested >= 2 would introduce a new divergence — striking three-tilde runs that GitHub, the current iOS renderer, and the web renderer all leave literal.

      Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    3. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR changes the default rendering behavior of existing web and mobile Markdown paths, so it falls under the requirement for human review of product-default changes. The native parser patch also has an unresolved Medium finding concerning longer tilde runs.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 🤖 Generated by Claude Code

      A follow-up worth spelling out after noticing the bug fires far more often on mobile than web: the two renderers don't just share the single-tilde default — they disagree on when a single-tilde pair strikes, because their delimiter rules differ. micromark (web) requires a closing ~ to have a non-space character before it; md4c (mobile) instead qualifies a closer by what comes after it, and punctuation counts. Measured on the shipped parsers:

      InputWeb todayMobile today
      ~$0.48 vs ~$0.65 per runokstrikes $0.48 vs
      files in ~/foo and ~/barokstrikes /foo and
      takes ~50ms and ~2sokok
      drifted to ~$45B senior/~$30-35B juniorstrikesstrikes

      Since ~$ (cost estimates) and ~/ (paths) dominate real agent output, mobile hits this constantly while web needs a rarer punctuation coincidence. This applies to both mobile platforms: iOS parses through the native t3-markdown-text module and Android through react-native-nitro-markdown's <Markdown> component, but both call the same vendored md4c parser, so they behave identically (and the patch in this PR fixes both).

      Alternative if you'd prefer not to touch web behavior: scope this down to a mobile-only patch that implements micromark's tilde flanking rules in md4c (~10 patch lines instead of 1). That makes mobile exactly match web's current rendering — ~$/~/ estimate pairs stop striking, while properly-flanked single-tilde pairs like the screenshot example still strike on both platforms, as they do on web today. We think the PR as written (both renderers ~~-only, matching github.com) is the better end state since agents write GFM, but happy to rescope to the consistency-only version if that's preferred.

    5. Note

      This comment is posted by Julius' dot

      The screenshots show the unwanted strike-through, and the parser checks explain the mobile mismatch. The remaining question is product direction: should both clients stop recognizing single-tilde formatting, or should mobile first match the existing web rules as the author proposes? Please have a maintainer confirm which behavior and scope to pursue.

    6. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 6ebc94bd-f16a-4b49-8edf-219fa915d48f
      📥 Commits

      Reviewing files that changed from the base of the PR and between f21d6da51c9aa78ea12e7f13a378f55f1e63cb38 and 372ebbe2c6af092d35ba5e0de3de9865ba43b670.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (3)
      • apps/web/src/chat-markdown-strikethrough.test.tsx
      • apps/web/src/components/ChatMarkdown.tsx
      • patches/react-native-nitro-markdown@0.5.8.patch

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


      📝 Walkthrough

      Walkthrough

      The web ChatMarkdown plugin sets disable single-tilde GFM strikethrough and retain double-tilde strikethrough. Rendering tests cover both plugin sets. A mobile markdown patch changes the span condition for tilde marks.

      Changes

      Single-Tilde Strikethrough Parsing

      Layer / File(s)Summary
      Web markdown configuration and tests
      apps/web/src/components/ChatMarkdown.tsx, apps/web/src/chat-markdown-strikethrough.test.tsx
      Both ChatMarkdown plugin sets configure remarkGfm with singleTilde: false. Tests check that single tildes do not create strikethrough and double tildes still do.
      Mobile markdown mark condition
      patches/react-native-nitro-markdown@0.5.8.patch
      The patch uses an exact two-character span condition for ~ marks. It retains the at-most-two-character condition for $ marks.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: yash-singh1

      Merge Risk: ⚪ Minimal · up to 372eb

      The changed rendering behavior matches the stated single- and double-tilde behavior, with no actionable merge-blocking issue identified.

      🚥 Pre-merge checks | ✅ 3 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Description check⚠️ WarningThe description explains the problem, the web and mobile changes, and the reported verification results. It links issue #16105, but does not provide explicit maintainer approval for the scope, especia…Add the maintainer’s explicit approval and explain why the mobile changes are within the approved scope. If approval is not available, narrow the changes to the scope approved in issue #16105 or link a discussion that approves the broader s…
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the main change: web and mobile Markdown rendering will no longer treat single tildes as strikethrough markers.
      Linked Issues check✅ Passed[ #16105 ] The issue requires rich-composer user messages to show single-tilde pairs literally in the web timeline and to preserve double-tilde strikethrough. ChatMarkdown.tsx configures both chat r…
      Out of Scope Changes check✅ PassedThe mobile md4c patch is outside #16105's web/desktop scope, but it changes the same chat strikethrough behavior to match the web configuration. The supplied change summary shows no changes unrelated …
      Full details: Description check

      Explanation

      The description explains the problem, the web and mobile changes, and the reported verification results. It links issue #16105, but does not provide explicit maintainer approval for the scope, especially the mobile changes that extend beyond the issue’s stated web and desktop scope.

      Resolution

      Add the maintainer’s explicit approval and explain why the mobile changes are within the approved scope. If approval is not available, narrow the changes to the scope approved in issue #16105 or link a discussion that approves the broader scope.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    7. Rebased to the latest version, with the V2 orchestrator

    8. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description.

    9. maria-rcks closed this

    10. 🤖 Generated with Claude Opus 5.5

      Correction to this PR's description: it says github.com only strikes double tildes, so web's remark-gfm default didn't match GitHub. That was wrong. GitHub documents strikethrough as ~~ ~~ or ~ ~, and its renderer agrees with web on every case I checked, including this PR's own example:

      InputGitHub and web
      ~solo~strikes solo
      drifted to ~$45B senior/~$30-35B juniorstrikes $45B senior/
      ~$0.48 vs ~$0.65 per runplain
      a~~b~~cstrikes b

      So the web half of this PR was a product change (stop striking single tildes, as #23216 now does for user messages), not a GitHub-compatibility fix. The mobile half was right: mobile's md4c is out of line with both, which #18156 follows up.

Sign in to join this conversation.