From 3c0900c115d15cb73b99faf7d7e966ef44109e40 Mon Sep 17 00:00:00 2001 From: Peter Nerlich Date: Tue, 17 Nov 2020 23:44:58 +0100 Subject: [PATCH] don't swallow multiple spaces (only at line breaks) --- lcd.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lcd.lua b/lcd.lua index 8cee9b7..8f0dd2b 100644 --- a/lcd.lua +++ b/lcd.lua @@ -34,7 +34,7 @@ local create_lines = function(text) local line = "" local line_num = 1 local tab = {} - for word in string.gmatch(text, "%S+") do + for word in string.gmatch(text, "%S*") do if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then if line ~= "" then line = line.." "..word @@ -43,7 +43,9 @@ local create_lines = function(text) end else table.insert(tab, line) - if word ~= "|" then + if word == " " then + -- don't at the space since we have a line break + elseif word ~= "|" then line = word else line = ""