Send composer markdown to Mattermost as typed #271
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-composer-markdown-round-trip"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two tiptap-markdown serializer artefacts were reaching Mattermost verbatim. Both were pinned in
markdown-mm-compat.tsas accepted deviations; on inspection one of them is a functional defect, not a cosmetic one.Channel links were escaped into plain text
~town-squarewas sent as\~town-square. tiptap-markdown escapes every~because GFM uses~~for strikethrough.Mattermost's
autolinkChannelMentionsruns on the rendered text with/\B(~([a-z0-9.\-_]*))/gi, so the escape stopped the channel resolving. The old fixture comment claimed MM "renders\~town-squarethe same as~town-square" — that is true for the visible text (MM's marked fork does have~in its escape class) but says nothing about the autolink, which is the point of typing~channel.unescapeLoneTildedrops the backslash from a lone tilde. A doubled~~keeps its escapes — that one really is markdown — and a lookbehind protects an escaped backslash the user typed in front of a tilde.Task lists were sent as loose lists
The serializer puts a blank line between task-list items, which makes it a loose list; Mattermost then renders each item in its own paragraph with extra spacing.
tightenTaskListsremoves a blank line only when a task item sits on both sides — a blank line between paragraphs, or between a task item and anything else, is untouched.Left alone: the hard-break deviation
The third documented deviation (a two-space hard break serialising to a plain
\n) is unchanged. I could not establish that it is a defect: MM's marked fork defaults tobreaks: falseand the webapp does not visibly set it, which would suggest a lost line break, but MM plainly does render single newlines as breaks in practice, so something else in that path accounts for it. Changing deliberate, tested behaviour on an unverified premise is not worth it; settling it needs a test against a real Mattermost.Tests
Unit tests for both helpers, including the guards that make them safe: three-item runs, nested items, task-item-next-to-paragraph, ordinary bullet lists,
\~\~, and a user-typed\~. Each guard was verified to fail with the guard removed.The two fixtures now pin the corrected output. Full suite: 96 files, 714 tests green; typecheck and pre-commit clean.
d2f48f7be6c79da70912robbertbos referenced this pull request2026-08-09 21:53:09 +00:00