Skip to content

feat(markdown): support Telegram ||spoiler|| syntax#1775

Merged
ernado merged 1 commit into
mainfrom
feat/markdown-spoiler
Jun 13, 2026
Merged

feat(markdown): support Telegram ||spoiler|| syntax#1775
ernado merged 1 commit into
mainfrom
feat/markdown-spoiler

Conversation

@ernado

@ernado ernado commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

The message/markdown parser is CommonMark (goldmark) and had no spoiler
construct, so Telegram's MarkdownV2 ||text|| was emitted as literal text
instead of a spoiler entity.

This adds a goldmark inline parser for the ||...|| delimiter (exactly two
pipes), mapping it onto the messageEntitySpoiler entity. It's modeled on the
existing strikethrough delimiter parser.

Changes

  • spoiler.goNewSpoilerParser() inline parser + spoiler AST node /
    delimiter processor (trigger |, requires a run of exactly 2).
  • parser.go — register the parser (priority 500) and render the node via
    entity.Spoiler().
  • markdown.go — document ||text|| spoiler in the package overview.
  • parser_test.go — a Spoiler test group: basic, mid-text, nested
    (||spoiler with *italic*||), single-pipe-stays-literal, and escaped pipes.

Behavior

||spoiler||              -> spoiler entity over "spoiler"
before ||hidden|| after  -> spoiler over "hidden"
a | b                    -> plain text (single pipe is not a delimiter)
\|\|x\|\|                -> literal "||x||"

All telegram/message/... tests pass; go vet and gofmt clean.

🤖 Generated with Claude Code

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

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.18519% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.19%. Comparing base (5bd59ff) to head (de06034).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
telegram/message/markdown/spoiler.go 83.33% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ernado ernado merged commit dd45993 into main Jun 13, 2026
14 checks passed
@ernado ernado deleted the feat/markdown-spoiler branch June 13, 2026 20:56
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