Version 1.1.4
- simplified and cleaned up the mutable builder API
- removed a large amount of legacy duplicate methods
- added explicit
Clone()support for copy-style workflows - added fenced code block support, including language-tagged code blocks
- added additive support for nested text styles
- refactored the internals away from eager string serialization toward a segment-based model
- improved package documentation and migration guidance
Breaking changes
The builder now follows one rule:
Clone()is the only copy operation- all other instance methods mutate the receiver
Removed methods:
AppendThisAppendNormalAppendBoldAppendItalicAppendMonoAppendUnderlineAppendStrikeAppendHyperLinkAppendMentionAppendSpoilerReplaceMdThisReplaceMdThisNElThisSpaceThisTabThis
Behavior changes for existing methods:
AppendReplaceMdReplaceMdNReplaceToNewReplaceToNewNElSpaceTab
These methods still exist, but they now mutate the current markdown instead of implicitly cloning it.
Migration guide
Use the non-This methods directly for mutation.
If older code expected copy-style behavior, call Clone() first.
Examples:
md.AppendBold("x")->md.Clone().Bold("x")md.AppendBoldThis("x")->md.Bold("x")md.AppendThis(other)->md.Append(other)md.ReplaceMdThis(old, new)->md.ReplaceMd(old, new)md.ElThis()->md.El()
General rule:
- old:
md.SomeMethod(...)might clone - new:
md.SomeMethod(...)mutates - if you need a copy:
md.Clone().SomeMethod(...)
New features
Fenced code blocks
Added plain fenced code block support:
GetCodeBlock(text)md.CodeBlock(text)
Added language-tagged fenced code block support:
GetCodeBlockLang(lang, text)md.CodeBlockLang(lang, text)
These support secret replacement and the escaping required inside code blocks.
Nested text styles
Added additive nested style support:
GetStyled(text, styles...)md.Styled(text, styles...)
Supported style constants:
StyleBoldStyleItalicStyleUnderlineStyleStrikeStyleSpoiler
This makes officially supported Telegram style combinations possible, such as bold + italic, and includes MarkdownV2-safe handling for the italic + underline ambiguity case.
Internal improvements
Segment-based internals
The internal builder no longer stores only fully rendered MarkdownV2 strings after every mutation.
Instead, it now stores structured segments and renders them in ToString().
Benefits:
- less repeated escaping work
- cleaner support for future nested formatting
- better foundation for an eventual entity-based model
Dependency cleanup
Removed the previous dependency on github.com/ALiwoto/ssg and replaced the used pieces with standard-library code.
Secret handling improvements
- global secret storage is now concurrency-safe
- secret replacement still happens at append/build time, preserving legacy behavior
Documentation improvements
- expanded
WMarkDowninterface comments sogo docis more usable - updated the README usage examples
- added a public README section about Telegram’s officially documented nesting rules
- added a public README migration section for old versions
- added internal design notes for a future entity-based model
Telegram formatting notes
Telegram officially documents nested message entities in the Bot API.
Relevant references:
- Bot API formatting options: https://core.telegram.org/bots/api#formatting-options
- Bot API message entities: https://core.telegram.org/bots/api#messageentity
- Bot API changelog version 4.5: https://core.telegram.org/bots/api-changelog#version-4-5
Important takeaway:
- combined formatting is officially supported
- overlapping entities must be properly nested
bold,italic,underline,strike-through, andspoilercan participate in nesting with restrictionscodeandpreremain special cases