streamd 0.1.2 → 0.1.3

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: 909a60cb7c94a3be4bfc208411b4a7810cbea58c4df421199df8ed6c0f18c8e5
4
- data.tar.gz: b823befe344739cca97ac12c1fc8c91691f459909579075f3c4ccafa4659f002
3
+ metadata.gz: 25a907b94c4d5bc5c28062160e1fb8967d88d4dc798e1f4c8eaf06df48031288
4
+ data.tar.gz: d8017f6a892f0a61d5d3430d25c91e0a9df3b2ed4741c84c1aafa0cebee44f3b
5
5
  SHA512:
6
- metadata.gz: 23b3bb576c8831349e680764ef425c5768ed11a4334a27f4cf36fcdedd6a8d96266c84b8b5efae9387b35df0867d299733cb432caf268963f9635bd1dfb777a2
7
- data.tar.gz: 7dc597b74da4ee53e38c1ae9b93f575ab5faa7e0c93c2c81806f98d8aee5b33e5271e3621f9ef3fcfa78f13b8516c51d9e112655237ac8e95856f146e6530e77
6
+ metadata.gz: 5bd48d7ed57f1c808e4074d3d27679242f05fec87d50160e85d810ed1eaabe3a66bec4f8d86bdc4af64d10f25f704a4874baa1e5685ed3512da8b3380a629af0
7
+ data.tar.gz: 1e85ec7551214fa870569e6566e1fcf9f49b41bc5fd9fd2569563951ed5b457f14bf6fd368ec9bf78b93944a563b73341458cd8f2511005bbfbb50249998a4ae
@@ -1,3 +1,3 @@
1
1
  module Streamd
2
- VERSION = "0.1.2"
3
- end
2
+ VERSION = "0.1.3"
3
+ end
data/lib/streamd.rb CHANGED
@@ -14,8 +14,18 @@ module Streamd
14
14
  curr = ""
15
15
  chunk.each_char do |char|
16
16
  whole << char
17
- if whole =~ /\n`{3}[^`]\z/
18
- in_code_block = !in_code_block
17
+ if whole =~ /\n[\s\t]*`{3}\w*\n\z/
18
+ in_code_block = whole.scan(/\n[\s\t]*`{3}\w*\n/).size.odd?
19
+ curr << char
20
+ if in_code_block
21
+ code_sign = curr.index(/[\s\t]*`{3}\w*\n\z/)
22
+ e << [curr[0...code_sign], true]
23
+ curr = curr[code_sign..-1]
24
+ else
25
+ e << [curr, true]
26
+ curr = ""
27
+ end
28
+ next
19
29
  end
20
30
  if whole =~ /\n[\n\s\t]*\n[^\n]\z/ && !in_code_block
21
31
  e << [curr, true]
@@ -32,6 +42,8 @@ module Streamd
32
42
  current = ""
33
43
  enum.each do |chunk, neo|
34
44
  current << chunk
45
+ next if current.strip.empty?
46
+
35
47
  styled =
36
48
  if current =~ /^\|/
37
49
  renderer.render(current)
@@ -41,7 +53,7 @@ module Streamd
41
53
 
42
54
  styled =
43
55
  case
44
- when current =~ /\A```/
56
+ when current =~ /\A[\s\t]*`{3}/
45
57
  " " + styled.gsub(/\A[\s\n]*(\e\[[0-9;]*m[\s\n]*\e\[0m[\s\n]*)+/m, '').gsub(/(\e\[[0-9;]*m[\s\n]*\e\[0m[\s\n]*)+[\s\n]*\Z/m, '').strip
46
58
  when current =~ /\A\*\*\*/ || current =~ /\A---/ || current =~ /\A___/
47
59
  styled.gsub(/\e\[[0-9;]*m[\s\n]*\e\[0m/m, '').strip
@@ -51,13 +63,12 @@ module Streamd
51
63
  " " + styled.gsub(/\e\[[0-9;]*m[\s\n]*\e\[0m/m, '').strip
52
64
  end
53
65
 
54
-
55
- # File.open("/tmp/streamd.#{name}.txt", 'w'){|f| f.puts styled}
66
+ # File.open("/tmp/streamd.current.#{name}.txt", 'w'){|f| f.puts current}
56
67
  live.update(styled)
57
68
  if neo
58
69
  # name += 1
59
70
  puts "\n\n"
60
- live = TTY::Live.new
71
+ live = TTY::Live.new
61
72
  current.clear
62
73
  end
63
74
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - c
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-03-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: glamour
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.6.9
99
+ rubygems_version: 3.6.3
100
100
  specification_version: 4
101
101
  summary: Render markdown is stream
102
102
  test_files: []