From 2b1dac71b2886ede9950f4ef91e7a0eb7b3e5ed5 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 26 Dec 2021 23:50:12 +0100 Subject: Basic content type implementation --- src/render/rendertext.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/render') diff --git a/src/render/rendertext.nim b/src/render/rendertext.nim index 4c6b56ec..b5054e7b 100644 --- a/src/render/rendertext.nim +++ b/src/render/rendertext.nim @@ -16,9 +16,8 @@ proc renderPlainText*(text: string): FlexibleGrid = while i < text.len: case text[i] of '\n': - if i != text.len - 1: - add_format - result.addLine() + add_format + result.addLine() of '\r': discard of '\t': add_format @@ -35,6 +34,9 @@ proc renderPlainText*(text: string): FlexibleGrid = result[^1].str &= text[i] inc i + if result.len > 1 and result[^1].str.len == 0 and result[^1].formats.len == 0: + discard result.pop() + proc renderStream*(stream: Stream): FlexibleGrid = var format = newFormatting() template add_format() = @@ -64,3 +66,6 @@ proc renderStream*(stream: Stream): FlexibleGrid = else: add_format result[^1].str &= c + + if result.len > 1 and result[^1].str.len == 0 and result[^1].formats.len == 0: + discard result.pop() -- cgit 1.4.1-2-gfad0