Switch to case-implementation of parser
This commit is contained in:
parent
1e2dba2630
commit
eb8325f20a
@ -10,7 +10,7 @@ module Skeksis
|
|||||||
extend self
|
extend self
|
||||||
|
|
||||||
def htmlize(data)
|
def htmlize(data)
|
||||||
puts Skeksis::Parser.parse(data).htmlize
|
#puts Skeksis::Parser.parse(data).htmlize
|
||||||
Skeksis::Parser.parse(data).htmlize
|
Skeksis::Parser.parse(data).htmlize
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -59,7 +59,7 @@ module Skeksis
|
|||||||
extend self
|
extend self
|
||||||
|
|
||||||
def parse(input)
|
def parse(input)
|
||||||
#puts("##### PARSING STARTED #####")
|
puts("##### PARSING STARTED #####")
|
||||||
|
|
||||||
list = IR.new
|
list = IR.new
|
||||||
|
|
||||||
@ -69,18 +69,38 @@ module Skeksis
|
|||||||
content = []
|
content = []
|
||||||
data.each do |line|
|
data.each do |line|
|
||||||
type = get_type(line)
|
type = get_type(line)
|
||||||
if type == :verbatim and in_verbatim_block == false
|
|
||||||
in_verbatim_block = true
|
case type
|
||||||
content.push(line)
|
when :verbatim
|
||||||
elsif type != :verbatim and in_verbatim_block == true
|
if in_verbatim_block == false
|
||||||
content.push(line)
|
in_verbatim_block = true
|
||||||
elsif type == :verbatim and in_verbatim_block == true
|
content.push(line)
|
||||||
in_verbatim_block = false
|
elsif in_verbatim_block == true
|
||||||
content.push(line)
|
in_verbatim_block = false
|
||||||
list.push({ type: :verbatim, content: content })
|
content.push(line)
|
||||||
content = []
|
list.push({ type: :verbatim, content: content })
|
||||||
next
|
content = []
|
||||||
|
next
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if in_verbatim_block == true
|
||||||
|
content.push(line)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#if type == :verbatim and in_verbatim_block == false
|
||||||
|
# in_verbatim_block = true
|
||||||
|
# content.push(line)
|
||||||
|
#elsif type != :verbatim and in_verbatim_block == true
|
||||||
|
# content.push(line)
|
||||||
|
#elsif type == :verbatim and in_verbatim_block == true
|
||||||
|
# in_verbatim_block = false
|
||||||
|
# content.push(line)
|
||||||
|
# list.push({ type: :verbatim, content: content })
|
||||||
|
# content = []
|
||||||
|
# next
|
||||||
|
#end
|
||||||
|
|
||||||
if in_verbatim_block == false
|
if in_verbatim_block == false
|
||||||
list.push({ type: type, content: [line] })
|
list.push({ type: type, content: [line] })
|
||||||
@ -88,9 +108,9 @@ module Skeksis
|
|||||||
end
|
end
|
||||||
|
|
||||||
list.strip_markers!
|
list.strip_markers!
|
||||||
#puts list
|
puts list
|
||||||
#puts strip_markers(list)
|
#puts strip_markers(list)
|
||||||
#puts("##### PARSING FINISHED #####")
|
puts("##### PARSING FINISHED #####")
|
||||||
|
|
||||||
list
|
list
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user