Skip to content

Commit ddae963

Browse files
author
Judd
committed
fix handling of lines
1 parent 62c9d8c commit ddae963

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

bindings/main.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ proc chatllm_print(user_data: pointer, print_type: cint, utf8_str: cstring) {.cd
128128
of PRINT_CHAT_CHUNK:
129129
var ht = cast[ptr highlighter](user_data)
130130
var s: string = $utf8_str
131+
var n = 0
131132
for l in s.splitLines():
132-
receive_chunk(ht[], l)
133+
if n > 0: receive_chunk(ht[], "")
134+
n += 1
135+
if l != "":
136+
receive_chunk(ht[], l)
133137
else:
134138
if utf8_str != nil: echo utf8_str
135139
stdout.flushFile()

docs/binding.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ Examples:
141141

142142
* [main.nim](../bindings/main.nim), which highlights code snippets.
143143

144+
Build:
145+
146+
```
147+
nim c -d:Release -d:ssl main.nim
148+
```
149+
144150
![](code_highlight.png)
145151

146152
### Others

docs/code_highlight.png

9.5 KB
Loading

0 commit comments

Comments
 (0)