mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-07-03 00:25:29 +00:00
Move rich markdown and html bodies into companion objects
For every RichText and RichBlock type the markdown and html rendering now lives in companion-object functions taking the relevant fields, and the property overrides are plain value initializers that reuse those functions (e.g. RichTextEmailAddress.markdown(text, emailAddress)). Class-specific render helpers (list, table, map, block quotation, details open attribute) move into the matching companions; helpers shared across several types (credit cite, media and media container rendering) stay internal top-level functions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -34510,6 +34510,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockAnchor$$seria
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAnchor$Companion {
|
||||
public final fun html (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34546,6 +34548,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockAnimation$$se
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAnimation$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/files/AnimationFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/files/AnimationFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34580,6 +34584,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockAudio$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAudio$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/files/AudioFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/files/AudioFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34614,6 +34620,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockBlockQuotatio
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockBlockQuotation$Companion {
|
||||
public final fun html (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34678,6 +34686,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockCollage$$seri
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockCollage$Companion {
|
||||
public final fun html (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34714,6 +34724,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockDetails$$seri
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockDetails$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/util/List;Ljava/lang/Boolean;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/util/List;Ljava/lang/Boolean;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34741,6 +34753,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockDivider$$seri
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockDivider$Companion {
|
||||
public final fun html ()Ljava/lang/String;
|
||||
public final fun markdown ()Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34772,6 +34786,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockFooter$$seria
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockFooter$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34810,6 +34826,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockList$$seriali
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockList$Companion {
|
||||
public final fun html (Ljava/util/List;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/util/List;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34896,6 +34914,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockMap$$serializ
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockMap$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/location/StaticLocation;ILdev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/location/StaticLocation;ILdev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34927,6 +34947,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockMathematicalE
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockMathematicalExpression$Companion {
|
||||
public final fun html (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34958,6 +34980,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockParagraph$$se
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockParagraph$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -34994,6 +35018,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockPhoto$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockPhoto$Companion {
|
||||
public final fun html-OKnyJrA (Ljava/util/List;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown-ACrxq0Q (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35028,6 +35054,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockPreformatted$
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockPreformatted$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35062,6 +35090,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockPullQuotation
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockPullQuotation$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35095,6 +35125,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockSectionHeadin
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockSectionHeading$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;I)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;I)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35133,6 +35165,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockSlideshow$$se
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockSlideshow$Companion {
|
||||
public final fun html (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/util/List;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35171,6 +35205,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockTable$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockTable$Companion {
|
||||
public final fun html (Ljava/util/List;Ljava/lang/Boolean;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/util/List;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35240,6 +35276,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockThinking$$ser
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockThinking$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35276,6 +35314,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockVideo$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockVideo$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/files/VideoFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/files/VideoFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35310,6 +35350,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichBlockVoiceNote$$se
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockVoiceNote$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/files/VoiceFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/files/VoiceFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35380,6 +35422,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextAnchor$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextAnchor$Companion {
|
||||
public final fun html (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35413,6 +35457,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextAnchorLink$$se
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextAnchorLink$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35446,6 +35492,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextBankCardNumber
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextBankCardNumber$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35477,6 +35525,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextBold$$serializ
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextBold$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35510,6 +35560,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextBotCommand$$se
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextBotCommand$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35598,6 +35650,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextCashtag$$seria
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextCashtag$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35629,6 +35683,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextCode$$serializ
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextCode$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35662,6 +35718,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextCustomEmoji$$s
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextCustomEmoji$Companion {
|
||||
public final fun html-R1fjqgo (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown-R1fjqgo (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35697,6 +35755,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextDateTime$$seri
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextDateTime$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;JLjava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;JLjava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35740,6 +35800,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextEmailAddress$$
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextEmailAddress$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35789,6 +35851,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextGroup$$seriali
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextGroup$Companion {
|
||||
public final fun html (Ljava/util/List;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/util/List;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35822,6 +35886,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextHashtag$$seria
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextHashtag$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35883,6 +35949,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextItalic$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextItalic$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35914,6 +35982,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextMarked$$serial
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextMarked$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35945,6 +36015,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextMathematicalEx
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextMathematicalExpression$Companion {
|
||||
public final fun html (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -35978,6 +36050,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextMention$$seria
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextMention$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36011,6 +36085,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextPhoneNumber$$s
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextPhoneNumber$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36040,6 +36116,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextPlain$$seriali
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextPlain$Companion {
|
||||
public final fun html (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36073,6 +36151,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextReference$$ser
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextReference$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36106,6 +36186,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextReferenceLink$
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextReferenceLink$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36146,6 +36228,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextSpoiler$$seria
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextSpoiler$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36177,6 +36261,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextStrikethrough$
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextStrikethrough$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36208,6 +36294,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextSubscript$$ser
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextSubscript$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36239,6 +36327,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextSuperscript$$s
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextSuperscript$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36272,6 +36362,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextTextMention$$s
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextTextMention$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ldev/inmo/tgbotapi/types/chat/User;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ldev/inmo/tgbotapi/types/chat/User;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36303,6 +36395,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextUnderline$$ser
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextUnderline$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
@@ -36336,6 +36430,8 @@ public final synthetic class dev/inmo/tgbotapi/types/rich/RichTextUrl$$serialize
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichTextUrl$Companion {
|
||||
public final fun html (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun markdown (Ldev/inmo/tgbotapi/types/rich/RichText;Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,49 +28,10 @@ val RichTextInfo.markdown: String
|
||||
val RichTextInfo.html: String
|
||||
get() = blocks.toRichHtml()
|
||||
|
||||
internal fun richOpenAttribute(isOpen: Boolean?): String = if (isOpen == true) " open" else ""
|
||||
|
||||
internal fun creditCiteMarkdown(credit: RichText?): String = credit?.let { "<cite>${it.markdown}</cite>" } ?: ""
|
||||
|
||||
internal fun creditCiteHtml(credit: RichText?): String = credit?.let { "<cite>${it.html}</cite>" } ?: ""
|
||||
|
||||
internal fun richBlockListMarkdown(list: RichBlockList): String =
|
||||
list.items.mapIndexed { index, item ->
|
||||
val marker = when {
|
||||
item.hasCheckbox == true -> if (item.isChecked == true) "- [x] " else "- [ ] "
|
||||
item.labelType != null -> "${item.value ?: (index + 1)}. "
|
||||
else -> "- "
|
||||
}
|
||||
item.blocks.toRichMarkdown().lineSequence().mapIndexed { lineIndex, line ->
|
||||
if (lineIndex == 0) "$marker$line" else " $line"
|
||||
}.joinToString(separator = "\n")
|
||||
}.joinToString(separator = "\n")
|
||||
|
||||
internal fun richBlockListHtml(list: RichBlockList): String {
|
||||
val ordered = list.items.any { it.labelType != null }
|
||||
val tag = if (ordered) "ol" else "ul"
|
||||
val items = list.items.joinToString(separator = "") { item ->
|
||||
val attributes = buildString {
|
||||
item.value?.let { append(" value=\"$it\"") }
|
||||
item.labelType?.let { append(" type=\"$it\"") }
|
||||
}
|
||||
val checkbox = if (item.hasCheckbox == true) {
|
||||
"<input type=\"checkbox\"${if (item.isChecked == true) " checked" else ""}>"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
"<li$attributes>$checkbox${item.blocks.toRichHtml()}</li>"
|
||||
}
|
||||
return "<$tag>$items</$tag>"
|
||||
}
|
||||
|
||||
internal fun richBlockQuotationMarkdown(blocks: List<RichBlock>, credit: RichText?): String {
|
||||
val quoted = blocks.toRichMarkdown().lineSequence().joinToString(separator = "\n") { line ->
|
||||
if (line.isEmpty()) ">" else "> $line"
|
||||
}
|
||||
return quoted + (credit?.let { "\n> ${creditCiteMarkdown(it)}" } ?: "")
|
||||
}
|
||||
|
||||
internal fun richMediaContainerMarkdown(tag: String, blocks: List<RichBlock>, caption: RichBlockCaption?): String {
|
||||
val media = blocks.joinToString(separator = "\n") { it.markdown }
|
||||
val captionPart = caption?.let { "\n<figcaption>${it.text.markdown}${creditCiteMarkdown(it.credit)}</figcaption>" } ?: ""
|
||||
@@ -91,54 +52,3 @@ internal fun richMediaHtml(tag: String, source: String, spoiler: Boolean, selfCl
|
||||
val element = if (selfClosing) "<$tag src=\"$source\"$spoilerAttribute/>" else "<$tag src=\"$source\"$spoilerAttribute></$tag>"
|
||||
return caption?.let { "<figure>$element<figcaption>${it.text.html}${creditCiteHtml(it.credit)}</figcaption></figure>" } ?: element
|
||||
}
|
||||
|
||||
internal fun richBlockMapMarkdown(map: RichBlockMap): String {
|
||||
val element = "<tg-map lat=\"${map.location.latitude}\" long=\"${map.location.longitude}\" zoom=\"${map.zoom}\"/>"
|
||||
return map.caption?.let { "<figure>$element<figcaption>${it.text.markdown}${creditCiteMarkdown(it.credit)}</figcaption></figure>" } ?: element
|
||||
}
|
||||
|
||||
internal fun richBlockMapHtml(map: RichBlockMap): String {
|
||||
val element = "<tg-map lat=\"${map.location.latitude}\" long=\"${map.location.longitude}\" zoom=\"${map.zoom}\"/>"
|
||||
return map.caption?.let { "<figure>$element<figcaption>${it.text.html}${creditCiteHtml(it.credit)}</figcaption></figure>" } ?: element
|
||||
}
|
||||
|
||||
internal fun richBlockTableMarkdown(table: RichBlockTable): String {
|
||||
if (table.cells.isEmpty()) return ""
|
||||
fun renderRow(row: List<RichBlockTableCell>): String =
|
||||
row.joinToString(separator = " | ", prefix = "| ", postfix = " |") { it.text?.markdown ?: "" }
|
||||
fun alignment(cell: RichBlockTableCell): String = when (cell.align) {
|
||||
"left" -> ":---"
|
||||
"center" -> ":--:"
|
||||
"right" -> "---:"
|
||||
else -> "---"
|
||||
}
|
||||
val header = table.cells.first()
|
||||
val lines = mutableListOf(
|
||||
renderRow(header),
|
||||
header.joinToString(separator = " | ", prefix = "| ", postfix = " |") { alignment(it) }
|
||||
)
|
||||
table.cells.drop(1).forEach { lines.add(renderRow(it)) }
|
||||
return lines.joinToString(separator = "\n")
|
||||
}
|
||||
|
||||
internal fun richBlockTableHtml(table: RichBlockTable): String {
|
||||
val attributes = buildString {
|
||||
if (table.isBordered == true) append(" bordered")
|
||||
if (table.isStriped == true) append(" striped")
|
||||
}
|
||||
val caption = table.caption?.let { "<caption>${it.html}</caption>" } ?: ""
|
||||
val rows = table.cells.joinToString(separator = "") { row ->
|
||||
val cells = row.joinToString(separator = "") { cell ->
|
||||
val tag = if (cell.isHeader == true) "th" else "td"
|
||||
val cellAttributes = buildString {
|
||||
cell.colspan?.let { append(" colspan=\"$it\"") }
|
||||
cell.rowspan?.let { append(" rowspan=\"$it\"") }
|
||||
append(" align=\"${cell.align}\"")
|
||||
append(" valign=\"${cell.valign}\"")
|
||||
}
|
||||
"<$tag$cellAttributes>${cell.text?.html ?: ""}</$tag>"
|
||||
}
|
||||
"<tr>$cells</tr>"
|
||||
}
|
||||
return "<table$attributes>$caption$rows</table>"
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ data class RichBlockParagraph(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = text.markdown
|
||||
override val html: String
|
||||
get() = "<p>${text.html}</p>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "paragraph"
|
||||
fun markdown(text: RichText): String = text.markdown
|
||||
fun html(text: RichText): String = "<p>${text.html}</p>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,13 +78,13 @@ data class RichBlockSectionHeading(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "#".repeat(size) + " " + text.markdown
|
||||
override val html: String
|
||||
get() = "<h$size>${text.html}</h$size>"
|
||||
override val markdown: String = markdown(text, size)
|
||||
override val html: String = html(text, size)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "heading"
|
||||
fun markdown(text: RichText, size: Int): String = "#".repeat(size) + " " + text.markdown
|
||||
fun html(text: RichText, size: Int): String = "<h$size>${text.html}</h$size>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,14 @@ data class RichBlockPreformatted(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "```" + (language ?: "") + "\n" + text.source + "\n```"
|
||||
override val html: String
|
||||
get() = language?.let { "<pre><code class=\"language-$it\">${text.html}</code></pre>" } ?: "<pre>${text.html}</pre>"
|
||||
override val markdown: String = markdown(text, language)
|
||||
override val html: String = html(text, language)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "pre"
|
||||
fun markdown(text: RichText, language: String?): String = "```" + (language ?: "") + "\n" + text.source + "\n```"
|
||||
fun html(text: RichText, language: String?): String =
|
||||
language?.let { "<pre><code class=\"language-$it\">${text.html}</code></pre>" } ?: "<pre>${text.html}</pre>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,13 +129,13 @@ data class RichBlockFooter(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<footer>${text.markdown}</footer>"
|
||||
override val html: String
|
||||
get() = "<footer>${text.html}</footer>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "footer"
|
||||
fun markdown(text: RichText): String = "<footer>${text.markdown}</footer>"
|
||||
fun html(text: RichText): String = "<footer>${text.html}</footer>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,10 +150,8 @@ class RichBlockDivider : RichBlock {
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "---"
|
||||
override val html: String
|
||||
get() = "<hr/>"
|
||||
override val markdown: String = markdown()
|
||||
override val html: String = html()
|
||||
|
||||
override fun equals(other: Any?): Boolean = other is RichBlockDivider
|
||||
|
||||
@@ -162,6 +161,8 @@ class RichBlockDivider : RichBlock {
|
||||
|
||||
companion object {
|
||||
const val TYPE = "divider"
|
||||
fun markdown(): String = "---"
|
||||
fun html(): String = "<hr/>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,13 +180,13 @@ data class RichBlockMathematicalExpression(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "\$\$" + expression + "\$\$"
|
||||
override val html: String
|
||||
get() = "<tg-math-block>$expression</tg-math-block>"
|
||||
override val markdown: String = markdown(expression)
|
||||
override val html: String = html(expression)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "mathematical_expression"
|
||||
fun markdown(expression: String): String = "\$\$" + expression + "\$\$"
|
||||
fun html(expression: String): String = "<tg-math-block>$expression</tg-math-block>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,13 +204,13 @@ data class RichBlockAnchor(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<a name=\"$name\"></a>"
|
||||
override val html: String
|
||||
get() = "<a name=\"$name\"></a>"
|
||||
override val markdown: String = markdown(name)
|
||||
override val html: String = html(name)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "anchor"
|
||||
fun markdown(name: String): String = "<a name=\"$name\"></a>"
|
||||
fun html(name: String): String = "<a name=\"$name\"></a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,13 +228,40 @@ data class RichBlockList(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richBlockListMarkdown(this)
|
||||
override val html: String
|
||||
get() = richBlockListHtml(this)
|
||||
override val markdown: String = markdown(items)
|
||||
override val html: String = html(items)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "list"
|
||||
fun markdown(items: List<RichBlockListItem>): String =
|
||||
items.mapIndexed { index, item ->
|
||||
val marker = when {
|
||||
item.hasCheckbox == true -> if (item.isChecked == true) "- [x] " else "- [ ] "
|
||||
item.labelType != null -> "${item.value ?: (index + 1)}. "
|
||||
else -> "- "
|
||||
}
|
||||
item.blocks.toRichMarkdown().lineSequence().mapIndexed { lineIndex, line ->
|
||||
if (lineIndex == 0) "$marker$line" else " $line"
|
||||
}.joinToString(separator = "\n")
|
||||
}.joinToString(separator = "\n")
|
||||
|
||||
fun html(items: List<RichBlockListItem>): String {
|
||||
val ordered = items.any { it.labelType != null }
|
||||
val tag = if (ordered) "ol" else "ul"
|
||||
val renderedItems = items.joinToString(separator = "") { item ->
|
||||
val attributes = buildString {
|
||||
item.value?.let { append(" value=\"$it\"") }
|
||||
item.labelType?.let { append(" type=\"$it\"") }
|
||||
}
|
||||
val checkbox = if (item.hasCheckbox == true) {
|
||||
"<input type=\"checkbox\"${if (item.isChecked == true) " checked" else ""}>"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
"<li$attributes>$checkbox${item.blocks.toRichHtml()}</li>"
|
||||
}
|
||||
return "<$tag>$renderedItems</$tag>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,13 +281,20 @@ data class RichBlockBlockQuotation(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richBlockQuotationMarkdown(blocks, credit)
|
||||
override val html: String
|
||||
get() = "<blockquote>${blocks.toRichHtml()}${creditCiteHtml(credit)}</blockquote>"
|
||||
override val markdown: String = markdown(blocks, credit)
|
||||
override val html: String = html(blocks, credit)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "blockquote"
|
||||
fun markdown(blocks: List<RichBlock>, credit: RichText?): String {
|
||||
val quoted = blocks.toRichMarkdown().lineSequence().joinToString(separator = "\n") { line ->
|
||||
if (line.isEmpty()) ">" else "> $line"
|
||||
}
|
||||
return quoted + (credit?.let { "\n> ${creditCiteMarkdown(it)}" } ?: "")
|
||||
}
|
||||
|
||||
fun html(blocks: List<RichBlock>, credit: RichText?): String =
|
||||
"<blockquote>${blocks.toRichHtml()}${creditCiteHtml(credit)}</blockquote>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,13 +314,13 @@ data class RichBlockPullQuotation(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<aside>${text.markdown}${creditCiteMarkdown(credit)}</aside>"
|
||||
override val html: String
|
||||
get() = "<aside>${text.html}${creditCiteHtml(credit)}</aside>"
|
||||
override val markdown: String = markdown(text, credit)
|
||||
override val html: String = html(text, credit)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "pullquote"
|
||||
fun markdown(text: RichText, credit: RichText?): String = "<aside>${text.markdown}${creditCiteMarkdown(credit)}</aside>"
|
||||
fun html(text: RichText, credit: RichText?): String = "<aside>${text.html}${creditCiteHtml(credit)}</aside>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,13 +340,15 @@ data class RichBlockCollage(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaContainerMarkdown("tg-collage", blocks, caption)
|
||||
override val html: String
|
||||
get() = richMediaContainerHtml("tg-collage", blocks, caption)
|
||||
override val markdown: String = markdown(blocks, caption)
|
||||
override val html: String = html(blocks, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "collage"
|
||||
fun markdown(blocks: List<RichBlock>, caption: RichBlockCaption?): String =
|
||||
richMediaContainerMarkdown("tg-collage", blocks, caption)
|
||||
fun html(blocks: List<RichBlock>, caption: RichBlockCaption?): String =
|
||||
richMediaContainerHtml("tg-collage", blocks, caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,13 +368,15 @@ data class RichBlockSlideshow(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaContainerMarkdown("tg-slideshow", blocks, caption)
|
||||
override val html: String
|
||||
get() = richMediaContainerHtml("tg-slideshow", blocks, caption)
|
||||
override val markdown: String = markdown(blocks, caption)
|
||||
override val html: String = html(blocks, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "slideshow"
|
||||
fun markdown(blocks: List<RichBlock>, caption: RichBlockCaption?): String =
|
||||
richMediaContainerMarkdown("tg-slideshow", blocks, caption)
|
||||
fun html(blocks: List<RichBlock>, caption: RichBlockCaption?): String =
|
||||
richMediaContainerHtml("tg-slideshow", blocks, caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,13 +400,51 @@ data class RichBlockTable(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richBlockTableMarkdown(this)
|
||||
override val html: String
|
||||
get() = richBlockTableHtml(this)
|
||||
override val markdown: String = markdown(cells)
|
||||
override val html: String = html(cells, isBordered, isStriped, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "table"
|
||||
fun markdown(cells: List<List<RichBlockTableCell>>): String {
|
||||
if (cells.isEmpty()) return ""
|
||||
fun renderRow(row: List<RichBlockTableCell>): String =
|
||||
row.joinToString(separator = " | ", prefix = "| ", postfix = " |") { it.text?.markdown ?: "" }
|
||||
fun alignment(cell: RichBlockTableCell): String = when (cell.align) {
|
||||
"left" -> ":---"
|
||||
"center" -> ":--:"
|
||||
"right" -> "---:"
|
||||
else -> "---"
|
||||
}
|
||||
val header = cells.first()
|
||||
val lines = mutableListOf(
|
||||
renderRow(header),
|
||||
header.joinToString(separator = " | ", prefix = "| ", postfix = " |") { alignment(it) }
|
||||
)
|
||||
cells.drop(1).forEach { lines.add(renderRow(it)) }
|
||||
return lines.joinToString(separator = "\n")
|
||||
}
|
||||
|
||||
fun html(cells: List<List<RichBlockTableCell>>, isBordered: Boolean?, isStriped: Boolean?, caption: RichText?): String {
|
||||
val attributes = buildString {
|
||||
if (isBordered == true) append(" bordered")
|
||||
if (isStriped == true) append(" striped")
|
||||
}
|
||||
val captionPart = caption?.let { "<caption>${it.html}</caption>" } ?: ""
|
||||
val rows = cells.joinToString(separator = "") { row ->
|
||||
val renderedCells = row.joinToString(separator = "") { cell ->
|
||||
val tag = if (cell.isHeader == true) "th" else "td"
|
||||
val cellAttributes = buildString {
|
||||
cell.colspan?.let { append(" colspan=\"$it\"") }
|
||||
cell.rowspan?.let { append(" rowspan=\"$it\"") }
|
||||
append(" align=\"${cell.align}\"")
|
||||
append(" valign=\"${cell.valign}\"")
|
||||
}
|
||||
"<$tag$cellAttributes>${cell.text?.html ?: ""}</$tag>"
|
||||
}
|
||||
"<tr>$renderedCells</tr>"
|
||||
}
|
||||
return "<table$attributes>$captionPart$rows</table>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,13 +466,20 @@ data class RichBlockDetails(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<details${richOpenAttribute(isOpen)}><summary>${summary.markdown}</summary>\n\n${blocks.toRichMarkdown()}\n\n</details>"
|
||||
override val html: String
|
||||
get() = "<details${richOpenAttribute(isOpen)}><summary>${summary.html}</summary>${blocks.toRichHtml()}</details>"
|
||||
override val markdown: String = markdown(summary, blocks, isOpen)
|
||||
override val html: String = html(summary, blocks, isOpen)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "details"
|
||||
fun markdown(summary: RichText, blocks: List<RichBlock>, isOpen: Boolean?): String {
|
||||
val open = if (isOpen == true) " open" else ""
|
||||
return "<details$open><summary>${summary.markdown}</summary>\n\n${blocks.toRichMarkdown()}\n\n</details>"
|
||||
}
|
||||
|
||||
fun html(summary: RichText, blocks: List<RichBlock>, isOpen: Boolean?): String {
|
||||
val open = if (isOpen == true) " open" else ""
|
||||
return "<details$open><summary>${summary.html}</summary>${blocks.toRichHtml()}</details>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,13 +508,20 @@ data class RichBlockMap(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richBlockMapMarkdown(this)
|
||||
override val html: String
|
||||
get() = richBlockMapHtml(this)
|
||||
override val markdown: String = markdown(location, zoom, caption)
|
||||
override val html: String = html(location, zoom, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "map"
|
||||
fun markdown(location: StaticLocation, zoom: Int, caption: RichBlockCaption?): String {
|
||||
val element = "<tg-map lat=\"${location.latitude}\" long=\"${location.longitude}\" zoom=\"$zoom\"/>"
|
||||
return caption?.let { "<figure>$element<figcaption>${it.text.markdown}${creditCiteMarkdown(it.credit)}</figcaption></figure>" } ?: element
|
||||
}
|
||||
|
||||
fun html(location: StaticLocation, zoom: Int, caption: RichBlockCaption?): String {
|
||||
val element = "<tg-map lat=\"${location.latitude}\" long=\"${location.longitude}\" zoom=\"$zoom\"/>"
|
||||
return caption?.let { "<figure>$element<figcaption>${it.text.html}${creditCiteHtml(it.credit)}</figcaption></figure>" } ?: element
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,13 +543,15 @@ data class RichBlockAnimation(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaMarkdown(animation.fileId.fileId, caption)
|
||||
override val html: String
|
||||
get() = richMediaHtml("video", animation.fileId.fileId, hasSpoiler == true, selfClosing = false, caption = caption)
|
||||
override val markdown: String = markdown(animation, caption)
|
||||
override val html: String = html(animation, hasSpoiler, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "animation"
|
||||
fun markdown(animation: AnimationFile, caption: RichBlockCaption?): String =
|
||||
richMediaMarkdown(animation.fileId.fileId, caption)
|
||||
fun html(animation: AnimationFile, hasSpoiler: Boolean?, caption: RichBlockCaption?): String =
|
||||
richMediaHtml("video", animation.fileId.fileId, hasSpoiler == true, selfClosing = false, caption = caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,13 +571,15 @@ data class RichBlockAudio(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaMarkdown(audio.fileId.fileId, caption)
|
||||
override val html: String
|
||||
get() = richMediaHtml("audio", audio.fileId.fileId, spoiler = false, selfClosing = false, caption = caption)
|
||||
override val markdown: String = markdown(audio, caption)
|
||||
override val html: String = html(audio, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "audio"
|
||||
fun markdown(audio: AudioFile, caption: RichBlockCaption?): String =
|
||||
richMediaMarkdown(audio.fileId.fileId, caption)
|
||||
fun html(audio: AudioFile, caption: RichBlockCaption?): String =
|
||||
richMediaHtml("audio", audio.fileId.fileId, spoiler = false, selfClosing = false, caption = caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,13 +601,15 @@ data class RichBlockPhoto(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaMarkdown(photo.fileId.fileId, caption)
|
||||
override val html: String
|
||||
get() = richMediaHtml("img", photo.fileId.fileId, hasSpoiler == true, selfClosing = true, caption = caption)
|
||||
override val markdown: String = markdown(photo, caption)
|
||||
override val html: String = html(photo, hasSpoiler, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "photo"
|
||||
fun markdown(photo: PhotoFile, caption: RichBlockCaption?): String =
|
||||
richMediaMarkdown(photo.fileId.fileId, caption)
|
||||
fun html(photo: PhotoFile, hasSpoiler: Boolean?, caption: RichBlockCaption?): String =
|
||||
richMediaHtml("img", photo.fileId.fileId, hasSpoiler == true, selfClosing = true, caption = caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,13 +631,15 @@ data class RichBlockVideo(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaMarkdown(video.fileId.fileId, caption)
|
||||
override val html: String
|
||||
get() = richMediaHtml("video", video.fileId.fileId, hasSpoiler == true, selfClosing = false, caption = caption)
|
||||
override val markdown: String = markdown(video, caption)
|
||||
override val html: String = html(video, hasSpoiler, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "video"
|
||||
fun markdown(video: VideoFile, caption: RichBlockCaption?): String =
|
||||
richMediaMarkdown(video.fileId.fileId, caption)
|
||||
fun html(video: VideoFile, hasSpoiler: Boolean?, caption: RichBlockCaption?): String =
|
||||
richMediaHtml("video", video.fileId.fileId, hasSpoiler == true, selfClosing = false, caption = caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,13 +659,15 @@ data class RichBlockVoiceNote(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = richMediaMarkdown(voiceNote.fileId.fileId, caption)
|
||||
override val html: String
|
||||
get() = richMediaHtml("audio", voiceNote.fileId.fileId, spoiler = false, selfClosing = false, caption = caption)
|
||||
override val markdown: String = markdown(voiceNote, caption)
|
||||
override val html: String = html(voiceNote, caption)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "voice_note"
|
||||
fun markdown(voiceNote: VoiceFile, caption: RichBlockCaption?): String =
|
||||
richMediaMarkdown(voiceNote.fileId.fileId, caption)
|
||||
fun html(voiceNote: VoiceFile, caption: RichBlockCaption?): String =
|
||||
richMediaHtml("audio", voiceNote.fileId.fileId, spoiler = false, selfClosing = false, caption = caption)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,12 +685,12 @@ data class RichBlockThinking(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<tg-thinking>${text.markdown}</tg-thinking>"
|
||||
override val html: String
|
||||
get() = "<tg-thinking>${text.html}</tg-thinking>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "thinking"
|
||||
fun markdown(text: RichText): String = "<tg-thinking>${text.markdown}</tg-thinking>"
|
||||
fun html(text: RichText): String = "<tg-thinking>${text.html}</tg-thinking>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,13 @@ sealed interface RichText {
|
||||
data class RichTextPlain(
|
||||
val text: String
|
||||
) : RichText {
|
||||
override val markdown: String
|
||||
get() = text.escapeRichMarkdown()
|
||||
override val html: String
|
||||
get() = text.toHtml()
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
fun markdown(text: String): String = text.escapeRichMarkdown()
|
||||
fun html(text: String): String = text.toHtml()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,10 +54,13 @@ data class RichTextPlain(
|
||||
data class RichTextGroup(
|
||||
val parts: List<RichText>
|
||||
) : RichText {
|
||||
override val markdown: String
|
||||
get() = parts.joinToString(separator = "") { it.markdown }
|
||||
override val html: String
|
||||
get() = parts.joinToString(separator = "") { it.html }
|
||||
override val markdown: String = markdown(parts)
|
||||
override val html: String = html(parts)
|
||||
|
||||
companion object {
|
||||
fun markdown(parts: List<RichText>): String = parts.joinToString(separator = "") { it.markdown }
|
||||
fun html(parts: List<RichText>): String = parts.joinToString(separator = "") { it.html }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,13 +41,13 @@ data class RichTextBold(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "**${text.markdown}**"
|
||||
override val html: String
|
||||
get() = "<b>${text.html}</b>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "bold"
|
||||
fun markdown(text: RichText): String = "**${text.markdown}**"
|
||||
fun html(text: RichText): String = "<b>${text.html}</b>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ data class RichTextItalic(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "*${text.markdown}*"
|
||||
override val html: String
|
||||
get() = "<i>${text.html}</i>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "italic"
|
||||
fun markdown(text: RichText): String = "*${text.markdown}*"
|
||||
fun html(text: RichText): String = "<i>${text.html}</i>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,13 +89,13 @@ data class RichTextUnderline(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<u>${text.markdown}</u>"
|
||||
override val html: String
|
||||
get() = "<u>${text.html}</u>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "underline"
|
||||
fun markdown(text: RichText): String = "<u>${text.markdown}</u>"
|
||||
fun html(text: RichText): String = "<u>${text.html}</u>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,13 +113,13 @@ data class RichTextStrikethrough(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "~~${text.markdown}~~"
|
||||
override val html: String
|
||||
get() = "<s>${text.html}</s>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "strikethrough"
|
||||
fun markdown(text: RichText): String = "~~${text.markdown}~~"
|
||||
fun html(text: RichText): String = "<s>${text.html}</s>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,13 +137,13 @@ data class RichTextSpoiler(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "||${text.markdown}||"
|
||||
override val html: String
|
||||
get() = "<tg-spoiler>${text.html}</tg-spoiler>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "spoiler"
|
||||
fun markdown(text: RichText): String = "||${text.markdown}||"
|
||||
fun html(text: RichText): String = "<tg-spoiler>${text.html}</tg-spoiler>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,13 +161,13 @@ data class RichTextSubscript(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<sub>${text.markdown}</sub>"
|
||||
override val html: String
|
||||
get() = "<sub>${text.html}</sub>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "subscript"
|
||||
fun markdown(text: RichText): String = "<sub>${text.markdown}</sub>"
|
||||
fun html(text: RichText): String = "<sub>${text.html}</sub>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,13 +185,13 @@ data class RichTextSuperscript(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<sup>${text.markdown}</sup>"
|
||||
override val html: String
|
||||
get() = "<sup>${text.html}</sup>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "superscript"
|
||||
fun markdown(text: RichText): String = "<sup>${text.markdown}</sup>"
|
||||
fun html(text: RichText): String = "<sup>${text.html}</sup>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,13 +209,13 @@ data class RichTextMarked(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "==${text.markdown}=="
|
||||
override val html: String
|
||||
get() = "<mark>${text.html}</mark>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "marked"
|
||||
fun markdown(text: RichText): String = "==${text.markdown}=="
|
||||
fun html(text: RichText): String = "<mark>${text.html}</mark>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,13 +233,13 @@ data class RichTextCode(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "`${text.source}`"
|
||||
override val html: String
|
||||
get() = "<code>${text.html}</code>"
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "code"
|
||||
fun markdown(text: RichText): String = "`${text.source}`"
|
||||
fun html(text: RichText): String = "<code>${text.html}</code>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,13 +261,15 @@ data class RichTextDateTime(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = ""
|
||||
override val html: String
|
||||
get() = "<tg-time unix=\"$unixTime\" format=\"$dateTimeFormat\">${text.html}</tg-time>"
|
||||
override val markdown: String = markdown(text, unixTime, dateTimeFormat)
|
||||
override val html: String = html(text, unixTime, dateTimeFormat)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "date_time"
|
||||
fun markdown(text: RichText, unixTime: Long, dateTimeFormat: String): String =
|
||||
""
|
||||
fun html(text: RichText, unixTime: Long, dateTimeFormat: String): String =
|
||||
"<tg-time unix=\"$unixTime\" format=\"$dateTimeFormat\">${text.html}</tg-time>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,13 +289,15 @@ data class RichTextTextMention(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "[${text.markdown}]($internalUserLinkBeginning${user.id.chatId.long})"
|
||||
override val html: String
|
||||
get() = "<a href=\"$internalUserLinkBeginning${user.id.chatId.long}\">${text.html}</a>"
|
||||
override val markdown: String = markdown(text, user)
|
||||
override val html: String = html(text, user)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "text_mention"
|
||||
fun markdown(text: RichText, user: User): String =
|
||||
"[${text.markdown}]($internalUserLinkBeginning${user.id.chatId.long})"
|
||||
fun html(text: RichText, user: User): String =
|
||||
"<a href=\"$internalUserLinkBeginning${user.id.chatId.long}\">${text.html}</a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,13 +317,15 @@ data class RichTextCustomEmoji(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = ""
|
||||
override val html: String
|
||||
get() = "<tg-emoji emoji-id=\"${customEmojiId.string}\">${alternativeText.toHtml()}</tg-emoji>"
|
||||
override val markdown: String = markdown(customEmojiId, alternativeText)
|
||||
override val html: String = html(customEmojiId, alternativeText)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "custom_emoji"
|
||||
fun markdown(customEmojiId: CustomEmojiId, alternativeText: String): String =
|
||||
""
|
||||
fun html(customEmojiId: CustomEmojiId, alternativeText: String): String =
|
||||
"<tg-emoji emoji-id=\"${customEmojiId.string}\">${alternativeText.toHtml()}</tg-emoji>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,13 +343,13 @@ data class RichTextMathematicalExpression(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "\$$expression\$"
|
||||
override val html: String
|
||||
get() = "<tg-math>$expression</tg-math>"
|
||||
override val markdown: String = markdown(expression)
|
||||
override val html: String = html(expression)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "mathematical_expression"
|
||||
fun markdown(expression: String): String = "\$$expression\$"
|
||||
fun html(expression: String): String = "<tg-math>$expression</tg-math>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,13 +369,13 @@ data class RichTextUrl(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "[${text.markdown}]($url)"
|
||||
override val html: String
|
||||
get() = "<a href=\"$url\">${text.html}</a>"
|
||||
override val markdown: String = markdown(text, url)
|
||||
override val html: String = html(text, url)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "url"
|
||||
fun markdown(text: RichText, url: String): String = "[${text.markdown}]($url)"
|
||||
fun html(text: RichText, url: String): String = "<a href=\"$url\">${text.html}</a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,13 +395,13 @@ data class RichTextEmailAddress(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "[${text.markdown}](mailto:$emailAddress)"
|
||||
override val html: String
|
||||
get() = "<a href=\"mailto:$emailAddress\">${text.html}</a>"
|
||||
override val markdown: String = markdown(text, emailAddress)
|
||||
override val html: String = html(text, emailAddress)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "email_address"
|
||||
fun markdown(text: RichText, emailAddress: String): String = "[${text.markdown}](mailto:$emailAddress)"
|
||||
fun html(text: RichText, emailAddress: String): String = "<a href=\"mailto:$emailAddress\">${text.html}</a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,13 +421,13 @@ data class RichTextPhoneNumber(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "[${text.markdown}](tel:$phoneNumber)"
|
||||
override val html: String
|
||||
get() = "<a href=\"tel:$phoneNumber\">${text.html}</a>"
|
||||
override val markdown: String = markdown(text, phoneNumber)
|
||||
override val html: String = html(text, phoneNumber)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "phone_number"
|
||||
fun markdown(text: RichText, phoneNumber: String): String = "[${text.markdown}](tel:$phoneNumber)"
|
||||
fun html(text: RichText, phoneNumber: String): String = "<a href=\"tel:$phoneNumber\">${text.html}</a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,13 +447,13 @@ data class RichTextBankCardNumber(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = text.markdown
|
||||
override val html: String
|
||||
get() = text.html
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "bank_card_number"
|
||||
fun markdown(text: RichText): String = text.markdown
|
||||
fun html(text: RichText): String = text.html
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,13 +473,13 @@ data class RichTextMention(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = text.markdown
|
||||
override val html: String
|
||||
get() = text.html
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "mention"
|
||||
fun markdown(text: RichText): String = text.markdown
|
||||
fun html(text: RichText): String = text.html
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,13 +499,13 @@ data class RichTextHashtag(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = text.markdown
|
||||
override val html: String
|
||||
get() = text.html
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "hashtag"
|
||||
fun markdown(text: RichText): String = text.markdown
|
||||
fun html(text: RichText): String = text.html
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,13 +525,13 @@ data class RichTextCashtag(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = text.markdown
|
||||
override val html: String
|
||||
get() = text.html
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "cashtag"
|
||||
fun markdown(text: RichText): String = text.markdown
|
||||
fun html(text: RichText): String = text.html
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,13 +551,13 @@ data class RichTextBotCommand(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = text.markdown
|
||||
override val html: String
|
||||
get() = text.html
|
||||
override val markdown: String = markdown(text)
|
||||
override val html: String = html(text)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "bot_command"
|
||||
fun markdown(text: RichText): String = text.markdown
|
||||
fun html(text: RichText): String = text.html
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,13 +575,13 @@ data class RichTextAnchor(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<a name=\"$name\"></a>"
|
||||
override val html: String
|
||||
get() = "<a name=\"$name\"></a>"
|
||||
override val markdown: String = markdown(name)
|
||||
override val html: String = html(name)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "anchor"
|
||||
fun markdown(name: String): String = "<a name=\"$name\"></a>"
|
||||
fun html(name: String): String = "<a name=\"$name\"></a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,13 +601,13 @@ data class RichTextAnchorLink(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "[${text.markdown}](#$anchorName)"
|
||||
override val html: String
|
||||
get() = "<a href=\"#$anchorName\">${text.html}</a>"
|
||||
override val markdown: String = markdown(text, anchorName)
|
||||
override val html: String = html(text, anchorName)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "anchor_link"
|
||||
fun markdown(text: RichText, anchorName: String): String = "[${text.markdown}](#$anchorName)"
|
||||
fun html(text: RichText, anchorName: String): String = "<a href=\"#$anchorName\">${text.html}</a>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,13 +627,13 @@ data class RichTextReference(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "<tg-reference name=\"$name\">${text.markdown}</tg-reference>"
|
||||
override val html: String
|
||||
get() = "<tg-reference name=\"$name\">${text.html}</tg-reference>"
|
||||
override val markdown: String = markdown(text, name)
|
||||
override val html: String = html(text, name)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "reference"
|
||||
fun markdown(text: RichText, name: String): String = "<tg-reference name=\"$name\">${text.markdown}</tg-reference>"
|
||||
fun html(text: RichText, name: String): String = "<tg-reference name=\"$name\">${text.html}</tg-reference>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,12 +653,12 @@ data class RichTextReferenceLink(
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String
|
||||
get() = "[${text.markdown}](#$referenceName)"
|
||||
override val html: String
|
||||
get() = "<a href=\"#$referenceName\">${text.html}</a>"
|
||||
override val markdown: String = markdown(text, referenceName)
|
||||
override val html: String = html(text, referenceName)
|
||||
|
||||
companion object {
|
||||
const val TYPE = "reference_link"
|
||||
fun markdown(text: RichText, referenceName: String): String = "[${text.markdown}](#$referenceName)"
|
||||
fun html(text: RichText, referenceName: String): String = "<a href=\"#$referenceName\">${text.html}</a>"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user