feat(markdown): support Telegram ||spoiler|| syntax#1775
Merged
Conversation
The CommonMark parser had no spoiler construct, so ||text|| was emitted as literal text. Add a goldmark inline parser for the Telegram MarkdownV2 spoiler delimiter (exactly "||"), mapping it onto the spoiler message entity, modeled on the strikethrough parser. Single pipes and escaped pipes stay literal. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1775 +/- ##
==========================================
+ Coverage 71.10% 71.19% +0.08%
==========================================
Files 501 503 +2
Lines 23501 23574 +73
==========================================
+ Hits 16711 16783 +72
+ Misses 5569 5564 -5
- Partials 1221 1227 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
message/markdownparser is CommonMark (goldmark) and had no spoilerconstruct, so Telegram's MarkdownV2
||text||was emitted as literal textinstead of a spoiler entity.
This adds a goldmark inline parser for the
||...||delimiter (exactly twopipes), mapping it onto the
messageEntitySpoilerentity. It's modeled on theexisting strikethrough delimiter parser.
Changes
spoiler.go—NewSpoilerParser()inline parser +spoilerAST node /delimiter processor (trigger
|, requires a run of exactly 2).parser.go— register the parser (priority 500) and render the node viaentity.Spoiler().markdown.go— document||text|| spoilerin the package overview.parser_test.go— aSpoilertest group: basic, mid-text, nested(
||spoiler with *italic*||), single-pipe-stays-literal, and escaped pipes.Behavior
All
telegram/message/...tests pass;go vetandgofmtclean.🤖 Generated with Claude Code