From 0e5d85ff051a522ef310662e5772ab6bbe6800ab Mon Sep 17 00:00:00 2001 From: Alula <6276139+alula@users.noreply.github.com> Date: Sun, 27 Jun 2021 04:24:01 +0200 Subject: [PATCH] fix #29 --- src/text_script.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/text_script.rs b/src/text_script.rs index fc8f1a0..790a6a6 100644 --- a/src/text_script.rs +++ b/src/text_script.rs @@ -1870,7 +1870,14 @@ impl TextScript { } b'<' => { allow_next_event = false; + if !char_buf.is_empty() { + if let Some(&c) = char_buf.last() { + if c == b'\n' { + let _ = char_buf.pop(); + } + } + TextScript::put_string(&mut char_buf, &mut bytecode, encoding); } @@ -1906,6 +1913,10 @@ impl TextScript { } fn put_string(buffer: &mut Vec, out: &mut Vec, encoding: TextScriptEncoding) { + if buffer.len() == 0 { + return; + } + let mut cursor: Cursor<&Vec> = Cursor::new(buffer); let mut tmp_buf = Vec::new(); let mut remaining = buffer.len() as u32;