Verbatim and list multi-line parser implementation

This commit is contained in:
maddiebaka 2023-08-03 17:25:04 -04:00
parent eb8325f20a
commit 9dcb59d8d4

View File

@ -66,11 +66,20 @@ module Skeksis
data = input.map(&:chomp) data = input.map(&:chomp)
in_verbatim_block = false in_verbatim_block = false
in_multiline_block = false
in_block = nil
content = [] content = []
data.each do |line| data.each do |line|
type = get_type(line) type = get_type(line)
case type case type
when :list
if not in_verbatim_block
in_multiline_block = true
in_block = type
end
content.push(line)
when :verbatim when :verbatim
if in_verbatim_block == false if in_verbatim_block == false
in_verbatim_block = true in_verbatim_block = true
@ -83,6 +92,13 @@ module Skeksis
next next
end end
else 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 if in_verbatim_block == true
content.push(line) content.push(line)
end end
@ -102,7 +118,8 @@ module Skeksis
# next # next
#end #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] }) list.push({ type: type, content: [line] })
end end
end end