From 04015a9fd39f61e34ebf3f71b5f74dcc9f33db68 Mon Sep 17 00:00:00 2001
From: Yura Slinkin <jurij.jurich@gmail.com>
Date: Sat, 5 Sep 2020 00:36:25 +0200
Subject: [PATCH] Added MarkdownV2 parse mode support

---
 .../main/scala/canoe/models/ParseMode.scala   | 30 ++-----------------
 .../models/outgoing/MessageContent.scala      | 19 ++++++++++--
 2 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/core/shared/src/main/scala/canoe/models/ParseMode.scala b/core/shared/src/main/scala/canoe/models/ParseMode.scala
index 2d631c9d..2d1c26a2 100644
--- a/core/shared/src/main/scala/canoe/models/ParseMode.scala
+++ b/core/shared/src/main/scala/canoe/models/ParseMode.scala
@@ -3,37 +3,11 @@ package canoe.models
 import io.circe.Encoder
 
 /**
-  * Formatting options.
-  * The Bot API supports basic formatting for messages.
-  * You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages.
-  * Telegram clients will render them accordingly. You can use either markdown-style or HTML-style formatting.
-  * Note that Telegram clients will display an alert to the user before opening an inline link ('Open this link?' together with the full URL).
-  *
-  * Markdown style.
-  * To use this mode, pass Markdown in the parse_mode field when using sendMessage. Use the following syntax in your message:
-  * *bold text*
-  * _italic text_
-  * [text](URL)
-  * `inline fixed-width code`
-  * ```pre-formatted fixed-width code block```
-  *
-  * HTML style.
-  * To use this mode, pass HTML in the parse_mode field when using sendMessage. The following tags are currently supported:
-  * <b>bold</b>, <strong>bold</strong>
-  * <i>italic</i>, <em>italic</em>
-  * <a href="URL">inline URL</a>
-  * <code>inline fixed-width code</code>
-  * <pre>pre-formatted fixed-width code block</pre>
-  *
-  * Please note:
-  * Only the tags mentioned above are currently supported.
-  * Tags must not be nested.
-  * All <, > and & symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (< with &lt;, > with &gt; and & with &amp;).
-  * All numerical HTML entities are supported.
-  * The API currently supports only the following named HTML entities: &lt;, &gt;, &amp; and &quot;.
+  * Telegram supported formatting options.
   */
 object ParseMode extends Enumeration {
   type ParseMode = Value
+  val MarkdownV2: ParseMode = Value("MarkdownV2")
   val Markdown: ParseMode = Value("Markdown")
   val HTML: ParseMode = Value("HTML")
 
diff --git a/core/shared/src/main/scala/canoe/models/outgoing/MessageContent.scala b/core/shared/src/main/scala/canoe/models/outgoing/MessageContent.scala
index ad988bdd..e42f01ba 100644
--- a/core/shared/src/main/scala/canoe/models/outgoing/MessageContent.scala
+++ b/core/shared/src/main/scala/canoe/models/outgoing/MessageContent.scala
@@ -72,12 +72,25 @@ final case class TextContent(text: String,
 ) extends MessageContent[TextMessage] {
 
   /**
-    * @return Text content with markdown parse mode.
+    * Text content with markdown parse mode.
+    *
+    * Markdown formatting applied according to MarkdownV2 style.
+    * Examples and additional information can be found [[https://core.telegram.org/bots/api#markdownv2-style here]].
     */
-  def markdown: TextContent = copy(parseMode = Some(ParseMode.Markdown))
+  def markdown: TextContent = copy(parseMode = Some(ParseMode.MarkdownV2))
 
   /**
-    * @return Text content with HTML parse mode.
+    * Text content with legacy markdown parse mode.
+    *
+    * Markdown formatting applied according to Markdown style.
+    * Examples and additional information can be found [[https://core.telegram.org/bots/api#markdown-style here]].
+    */
+  def markdownOld: TextContent = copy(parseMode = Some(ParseMode.Markdown))
+
+  /**
+    * Text content with HTML parse mode.
+    *
+    * Examples and additional information can be found [[https://core.telegram.org/bots/api#html-style here]].
     */
   def html: TextContent = copy(parseMode = Some(ParseMode.HTML))
 }