-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser_assigner.rb
More file actions
44 lines (39 loc) · 1.02 KB
/
parser_assigner.rb
File metadata and controls
44 lines (39 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require './paragraph_parser'
require './header_parser'
require './strong_parser'
require './emphasis_parser'
require './unordered_list_parser'
require './ordered_list_parser'
require 'pry'
class ParserAssigner
def assign_chunk(chunk)
chunk = outer_tags(chunk)
chunk = inner_tags(chunk)
end
def outer_tags(chunk)
if chunk[0] == "#"
head = HeaderParser.new(chunk)
chunk = head.header_parser
elsif chunk.start_with?("* ")
ulist= UnorderedListParser.new(chunk)
chunk = ulist.unordered_list_parser
elsif chunk.start_with?("1. ")
olist = OrderedListParser.new(chunk)
chunk = olist.ordered_list_parser
else
paragraph = ParagraphParser.new(chunk)
chunk = paragraph.paragraph_parser
end
end
def inner_tags(chunk)
if chunk.include?("**")
strong = StrongParser.new(chunk)
chunk = strong.strong_parser
elsif chunk.include?("*")
emphasis = EmphasisParser.new(chunk)
chunk = emphasis.emphasis_parser
else
chunk
end
end
end