name string
markdown string
text string
- entities []botEntity
+ entities []TelegramEntity
}{
{
name: "double asterisks give bold",
markdown: "a **b** c",
text: "a b c",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "bold",
Offset: 2,
name: "double underscores give bold",
markdown: "__bold__",
text: "bold",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "bold",
Offset: 0,
name: "single asterisk gives italic",
markdown: "an *odd* word",
text: "an odd word",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "italic",
Offset: 3,
name: "single underscore gives italic",
markdown: "an _odd_ word",
text: "an odd word",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "italic",
Offset: 3,
name: "double tildes give strikethrough",
markdown: "~~old~~ new",
text: "old new",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "strikethrough",
Offset: 0,
name: "backticks give inline code with no entity inside",
markdown: "run `go **test**` now",
text: "run go **test** now",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "code",
Offset: 4,
name: "double backticks hold a backtick",
markdown: "``a ` b``",
text: "a ` b",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "code",
Offset: 0,
name: "link gives a text link",
markdown: "see [the docs](https://example.com/a_b) here",
text: "see the docs here",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "text_link",
Offset: 4,
name: "bold inside a link nests",
markdown: "[a **b** c](https://example.com)",
text: "a b c",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "text_link",
Offset: 0,
name: "code block with a language gives pre with the language",
markdown: "Commit:\n```text\nFix the **bug**\n\nBody\n```\nDone.",
text: "Commit:\nFix the **bug**\n\nBody\nDone.",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "pre",
Offset: 8,
name: "code block without a language gives pre",
markdown: "```\nls -l\n```",
text: "ls -l",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "pre",
Offset: 0,
name: "heading becomes bold with its inline marks",
markdown: "## The `plan`\nnext",
text: "The plan\nnext",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "bold",
Offset: 0,
name: "asterisk of a list item with italic later stays",
markdown: "* item with *stress*",
text: "* item with stress",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "italic",
Offset: 12,
name: "character outside the BMP moves the offset by two",
markdown: "\U0001F600 **b**",
text: "\U0001F600 b",
- entities: []botEntity{
+ entities: []TelegramEntity{
{
Type: "bold",
Offset: 3,
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- text, entities := markdownEntities(tc.markdown)
+ text, entities := telegramMarkdownEntities(tc.markdown)
require.Equal(t, tc.text, text)
require.Equal(t, tc.entities, entities)
})