chat_sdk-telegram 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c7469e27cabb92ba6ed37a198b0b654bd28e41d6be5c6a7d2e869aa422ca242
4
- data.tar.gz: 6b6c66121c254a6ec4206130f6ff1001275ce84b202ec67995cfdafd2f38add8
3
+ metadata.gz: 872167584d75bda2b7103ed1caa694df242b4d70f3f95a1f5e257abc68b949c8
4
+ data.tar.gz: 9e41b3269dc1116e2bc7169b146770337e8f9bbb6020b85f7f36c575828cf678
5
5
  SHA512:
6
- metadata.gz: 6f13191588083d918d717038d6946270de24fc34b578120009045c27c4bc64d1800f444846af8db9734e80edf8ae03c9eb26f2e33a149f422ba59f469eaf22b1
7
- data.tar.gz: 61425a3e878f398cd1222d6827bee44a1e84ab035103c3606f734856fb8588b322c97945d274aaa23e59ab0f67602f09143a712c919174c4c9a56509eac2df2b
6
+ metadata.gz: 8b4cb75b87b4afa4f0bc20408f44e2486ddca60da0bb1eea2598f870b1be581e789c08367287b8c1a36428c8f1bb8b19e154103f776fee3d0219830d956a0234
7
+ data.tar.gz: 9843eee8e48fab1a345487035beac68a014bc558e343346dc1cfe6a170f7799b9170f9cff2e10d9bc8fdb738c4cc73fa118731558508baf8970509e54aeea3e2
@@ -4,7 +4,6 @@ module ChatSDK
4
4
  module Telegram
5
5
  class FormatConverter < ChatSDK::Format::Converter
6
6
  SPECIAL_CHARS = %w[_ * [ ] ( ) ~ \\ ` > # + - = | { } . !].freeze
7
- ESCAPE_RE = Regexp.union(SPECIAL_CHARS).freeze
8
7
 
9
8
  # Telegram MarkdownV2 → standard Markdown
10
9
  def to_markdown(platform_text)
@@ -30,18 +29,12 @@ module ChatSDK
30
29
  text = markdown.to_s
31
30
  return "" if text.empty?
32
31
 
33
- parts = split_code_segments(text)
32
+ parts = split_code_blocks(text)
34
33
  parts.map.with_index { |part, i| i.odd? ? part : escape_special_chars(part) }.join
35
34
  end
36
35
 
37
36
  private
38
37
 
39
- # Splits text into alternating [text, code, text, code, ...] segments.
40
- # Odd-indexed segments are code blocks/inline code and are NOT escaped.
41
- def split_code_segments(text)
42
- text.split(/(```[\s\S]*?```|`[^`]+`)/)
43
- end
44
-
45
38
  # Escape Telegram MarkdownV2 special chars outside of markdown syntax.
46
39
  # Preserves bold (**), italic (*), strikethrough (~~), links, etc.
47
40
  def escape_special_chars(text)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chat_sdk-telegram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quentin Rousseau