chat_sdk-x 0.7.0 → 0.8.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: d4625c1b778c0e928f63220a262746f6e0f936324f04227d6089b90aef2b4f4e
4
- data.tar.gz: 51c114854c79621bdd093b06bc0d1f7a040533ea38f943ce7f6b9bfae056b51c
3
+ metadata.gz: 0cc78776461860e0f234747c168059eba9e1af62401e97752f9b0e9c9c60fe62
4
+ data.tar.gz: c158cf5c06608dc12c5b238ec0653c6e25a62dc77e50dba0cc07ca6ba4a4bda2
5
5
  SHA512:
6
- metadata.gz: 2efbc539d669d2b631cd7c1200a8f1fe5defc9f2e8288669d49ca0dd4d872b7fc0976b8251f685ae7c32ce6b6a540823b9918a45aca80f8f767297619c7a2209
7
- data.tar.gz: 7665fbb3b51567a21a4abf0007853845ed13a902f3cf1483e4b08eba2c5f23408e31001ebbb16f870f09af5d5de99ae8d01e113932bd977bd634802acd8809e2
6
+ metadata.gz: 559ab2ada28ef4a7dfeea3224dc4c2fd2645352d902f1d52758a2f2eb3d07b3fe723de14f6f4e7c229758f5024a1bdfc8f83e0661c402b88679a41ebee4c037e
7
+ data.tar.gz: bfc0a4e918126c31492a0e3ad54ffdea98792b3452934b222a052439f6a9ac71856127366ce1bd92708b412466c3e332144c13c0dd5380aef7c9663c39da1861
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChatSDK
4
+ module X
5
+ class FormatConverter < ChatSDK::Format::Converter
6
+ # X (Twitter) → Markdown (pass-through, X posts are plain text)
7
+ def to_markdown(platform_text)
8
+ platform_text.to_s
9
+ end
10
+
11
+ # Markdown → X (strip all formatting to plain text)
12
+ def from_markdown(markdown)
13
+ text = markdown.to_s
14
+ return "" if text.empty?
15
+
16
+ strip_markdown(text)
17
+ end
18
+
19
+ private
20
+
21
+ def strip_markdown(text)
22
+ result = text
23
+
24
+ # Remove fenced code blocks but keep content
25
+ result = result.gsub(/```\w*\n?([\s\S]*?)```/, '\1')
26
+
27
+ # Remove inline code markers
28
+ result = result.gsub(/`([^`]+)`/, '\1')
29
+
30
+ # Convert links: [text](url) → text (url)
31
+ result = result.gsub(/\[([^\]]+)\]\(([^)]+)\)/, '\1 (\2)')
32
+
33
+ # Remove bold markers: **text** → text
34
+ result = result.gsub(/\*\*(.+?)\*\*/m, '\1')
35
+
36
+ # Remove italic markers: *text* → text
37
+ result = result.gsub(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/m, '\1')
38
+
39
+ # Remove strikethrough markers: ~~text~~ → text
40
+ result.gsub(/~~(.+?)~~/m, '\1')
41
+ end
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chat_sdk-x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quentin Rousseau
@@ -48,6 +48,7 @@ files:
48
48
  - lib/chat_sdk/x/adapter.rb
49
49
  - lib/chat_sdk/x/api_client.rb
50
50
  - lib/chat_sdk/x/event_parser.rb
51
+ - lib/chat_sdk/x/format_converter.rb
51
52
  homepage: https://github.com/rootlyhq/chat-sdk
52
53
  licenses:
53
54
  - MIT