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
1 changed files with 18 additions and 1 deletions

View File

@ -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