chat_sdk 0.8.0 → 0.8.1
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 +4 -4
- data/lib/chat_sdk/format/converter.rb +21 -0
- data/lib/chat_sdk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72dfd997ec76dcc51b3011fc0edb53b6533c608aa5223a68cfcb7fe318888510
|
|
4
|
+
data.tar.gz: ee5e004f7f3b78b1992c919d4dede58c99ec76b8fff44f7e68395006766cf82f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46fc7791048625ce5896e90dc5dbd7ec85ca81291cd0092def6e5779d28167c6f71c4076e30f79aaa265a65e5bf9a296978448e0b3d774d25c82afcc47fd0398
|
|
7
|
+
data.tar.gz: 1980014a0cf584ef9913293c716d3140cd6026e797d57c97bbef945c7e002674b10f4ee311d8d214d51fa0bd2c124f62737a1e94cacb4cba18d866173d54fd94
|
|
@@ -24,6 +24,27 @@ module ChatSDK
|
|
|
24
24
|
def render_html(node)
|
|
25
25
|
node.to_html
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def split_code_blocks(text)
|
|
31
|
+
text.split(/(```[\s\S]*?```|`[^`]+`)/)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def strip_markdown(text)
|
|
35
|
+
result = text.gsub(/```\w*\n?([\s\S]*?)```/, '\1')
|
|
36
|
+
result = result.gsub(/`([^`]+)`/, '\1')
|
|
37
|
+
result = result.gsub(/\[([^\]]+)\]\(([^)]+)\)/, '\1 (\2)')
|
|
38
|
+
result = result.gsub(/\*\*(.+?)\*\*/, '\1')
|
|
39
|
+
result = result.gsub(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/, '\1')
|
|
40
|
+
result.gsub(/~~(.+?)~~/, '\1')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def convert_bold_and_italic_from_md(text, bold_char: "*", italic_char: "_")
|
|
44
|
+
result = text.gsub(/\*\*(.+?)\*\*/, "\x00BOLD\\1BOLD\x00")
|
|
45
|
+
result = result.gsub(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/, "#{italic_char}\\1#{italic_char}")
|
|
46
|
+
result.gsub(/\x00BOLD(.+?)BOLD\x00/, "#{bold_char}\\1#{bold_char}")
|
|
47
|
+
end
|
|
27
48
|
end
|
|
28
49
|
end
|
|
29
50
|
end
|
data/lib/chat_sdk/version.rb
CHANGED