Skip to content

Port upstream code fence info string fix#68

Merged
Renakoni merged 2 commits into
mainfrom
sync/upstream-4846-code-fence-info
Jul 9, 2026
Merged

Port upstream code fence info string fix#68
Renakoni merged 2 commits into
mainfrom
sync/upstream-4846-code-fence-info

Conversation

@Renakoni

@Renakoni Renakoni commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Port upstream MarkText PR #4846 into the Android Muya copy.
  • Preserve full fenced code block info strings during markdown -> state -> markdown round trips.
  • Add regression coverage for Pandoc/RMarkdown attributes, language attributes, plain languages, language-less fences, and stale info after language edits.

Upstream Source

Android Relevance

This affects Android document saving. Android uses Muya's state import/export pipeline to edit and serialize markdown. Before this fix, fenced code block info strings were reduced to the first word when saved: for example ```js title="app.js" became ```js, and Pandoc/RMarkdown attribute blocks like ```{example, listing1-name} were truncated. That is data loss in Android-edited markdown files.

Change Details

  • Keep meta.lang as the first info-string word for highlighting and language class behavior.
  • Preserve the original full fenced info string additively in meta.info when it carries more than lang.
  • Serialize meta.info only while its first word still matches meta.lang; if the language is later edited, the edited language wins and stale attributes are not re-emitted.
  • Add codeFenceInfoString.spec.ts for the round-trip and stale-info cases.

Verification

  • pnpm --dir third_party/muya exec vitest run src/state/__tests__/codeFenceInfoString.spec.ts src/state/__tests__/codeFenceLength.spec.ts passed.
  • pnpm build passed.

@Renakoni Renakoni merged commit e1b474d into main Jul 9, 2026
4 checks passed
@Renakoni Renakoni deleted the sync/upstream-4846-code-fence-info branch July 9, 2026 01:29
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.

1 participant