Skip to content

Preserve fenced Markdown blocks across message splits - #32

Open
PromoFaux with Copilot wants to merge 4 commits into
masterfrom
copilot/feature-more-intelligent-text-splitting
Open

Preserve fenced Markdown blocks across message splits#32
PromoFaux with Copilot wants to merge 4 commits into
masterfrom
copilot/feature-more-intelligent-text-splitting

Conversation

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Long posts split mid-fenced code block, causing subsequent chunks to render as malformed Markdown. This preserves code-block formatting for each generated Mattermost message.

  • Fenced code continuity

    • Close active ```/~~~ blocks at a chunk boundary.
    • Reopen the original fence, including its language hint, in the next chunk.
  • Message numbering

    • Place sequence indicators on their own line before chunks that begin with a fence.
```json
{ "large": "payload" }

becomes independently rendered chunks with balanced fences.

<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes #10

Copilot AI linked an issue Sep 2, 2026 that may be closed by this pull request
Co-authored-by: PromoFaux <1998970+PromoFaux@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement more intelligent text splitting for markdown Preserve fenced Markdown blocks across message splits Sep 2, 2026
Copilot AI requested a review from PromoFaux September 2, 2026 21:54
@PromoFaux

Copy link
Copy Markdown
Owner

@copilot CI config has been fixed - please rebase on master

…e-intelligent-text-splitting

Co-authored-by: PromoFaux <1998970+PromoFaux@users.noreply.github.com>

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot CI config has been fixed - please rebase on master

Merged master in 58226c5.

@PromoFaux
PromoFaux marked this pull request as ready for review September 2, 2026 22:14
@PromoFaux

Copy link
Copy Markdown
Owner

@copilot I don't currently have the ability to download and test this - but would love to see some screenshots or examples of this in action (adding markdown directly here may cause issues....)

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot I don't currently have the ability to download and test this - but would love to see some screenshots or examples of this in action (adding markdown directly here may cause issues....)

The focused example is in Matterhook.NET.MatterhookClient.Tests/MiscTests.cs lines 25–34. A 25-character split of one json fenced block produces three independently valid messages: each boundary closes the prior fence and the continuation starts by reopening json; the final chunk contains the original closing fence and trailing text. This prevents the code-block formatting bleed shown in the supplied image.

@PromoFaux

Copy link
Copy Markdown
Owner

@copilot It might also be worth rolling in here an option to truncate rather than split, too. So that the end user has the ability to decide what they see

Co-authored-by: PromoFaux <1998970+PromoFaux@users.noreply.github.com>

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot It might also be worth rolling in here an option to truncate rather than split, too. So that the end user has the ability to decide what they see

Implemented in 8b27d53. PostAsync now accepts truncate: true, which sends only the first balanced chunk for both message and attachment text; the default continues splitting.

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.

More intelligent text splitting

2 participants