From 9dcb59d8d4e2bb0a9f7e4d68294fbbb3daf00522 Mon Sep 17 00:00:00 2001 From: maddiebaka Date: Thu, 3 Aug 2023 17:25:04 -0400 Subject: [PATCH] Verbatim and list multi-line parser implementation --- lib/skeksis/parser.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/skeksis/parser.rb b/lib/skeksis/parser.rb index 987411e..8ffa3ec 100644 --- a/lib/skeksis/parser.rb +++ b/lib/skeksis/parser.rb @@ -66,11 +66,20 @@ module Skeksis data = input.map(&:chomp) in_verbatim_block = false + in_multiline_block = false + in_block = nil content = [] + data.each do |line| type = get_type(line) case type + when :list + if not in_verbatim_block + in_multiline_block = true + in_block = type + end + content.push(line) when :verbatim if in_verbatim_block == false in_verbatim_block = true @@ -83,6 +92,13 @@ module Skeksis next end else + if in_multiline_block == true + #puts("in multiline block") + list.push({ type: in_block, content: content }) + in_multiline_block = false + content = [] + end + if in_verbatim_block == true content.push(line) end @@ -102,7 +118,8 @@ module Skeksis # next #end - if in_verbatim_block == false + if in_verbatim_block == false and in_multiline_block == false + #puts("catch-all push") list.push({ type: type, content: [line] }) end end