smartdown 0.11.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/lib/smartdown/api/date_question.rb +10 -4
  2. data/lib/smartdown/api/node.rb +2 -1
  3. data/lib/smartdown/api/question.rb +2 -1
  4. data/lib/smartdown/engine/interpolator.rb +1 -1
  5. data/lib/smartdown/model/element/{markdown_paragraph.rb → markdown_line.rb} +1 -1
  6. data/lib/smartdown/model/elements.rb +51 -0
  7. data/lib/smartdown/model/node.rb +14 -7
  8. data/lib/smartdown/parser/base.rb +1 -1
  9. data/lib/smartdown/parser/element/conditional.rb +9 -8
  10. data/lib/smartdown/parser/element/front_matter.rb +7 -1
  11. data/lib/smartdown/parser/element/markdown_blank_line.rb +14 -0
  12. data/lib/smartdown/parser/element/markdown_line.rb +14 -0
  13. data/lib/smartdown/parser/node_parser.rb +10 -7
  14. data/lib/smartdown/parser/node_transform.rb +21 -4
  15. data/lib/smartdown/version.rb +1 -1
  16. data/spec/acceptance/parsing_spec.rb +7 -0
  17. data/spec/api/node_spec.rb +4 -4
  18. data/spec/api/question_spec.rb +3 -3
  19. data/spec/engine/conditional_resolver_spec.rb +8 -8
  20. data/spec/engine/interpolator_spec.rb +11 -11
  21. data/spec/engine_spec.rb +12 -12
  22. data/spec/fixtures/acceptance/animal-example-multiple/animal-example-multiple.txt +2 -0
  23. data/spec/fixtures/acceptance/animal-example-simple/animal-example-simple.txt +2 -0
  24. data/spec/fixtures/acceptance/cover-sheet/cover-sheet.txt +5 -0
  25. data/spec/fixtures/acceptance/snippet/snippet.txt +2 -0
  26. data/spec/model/node_spec.rb +1 -1
  27. data/spec/parser/base_spec.rb +2 -2
  28. data/spec/parser/element/conditional_spec.rb +144 -30
  29. data/spec/parser/element/front_matter_spec.rb +3 -3
  30. data/spec/parser/element/markdown_line_spec.rb +28 -0
  31. data/spec/parser/integration/cover_sheet_spec.rb +2 -0
  32. data/spec/parser/node_parser_spec.rb +55 -27
  33. data/spec/support/model_builder.rb +3 -3
  34. data/spec/support_specs/model_builder_spec.rb +12 -12
  35. metadata +25 -23
  36. data/lib/smartdown/parser/element/markdown_paragraph.rb +0 -19
  37. data/spec/parser/element/markdown_paragraph_spec.rb +0 -28
@@ -4,21 +4,27 @@ module Smartdown
4
4
  module Api
5
5
  class DateQuestion < Question
6
6
  extend Forwardable
7
- DEFAULT_START_YEAR = Time.now.year - 1
8
- DEFAULT_END_YEAR = Time.now.year + 3
9
7
 
10
8
  def start_year
11
- parse_date(from) || DEFAULT_START_YEAR
9
+ parse_date(from) || default_start_year
12
10
  end
13
11
 
14
12
  def end_year
15
- parse_date(to) || DEFAULT_END_YEAR
13
+ parse_date(to) || default_end_year
16
14
  end
17
15
 
18
16
  private
19
17
 
20
18
  delegate [:to, :from] => :question_element
21
19
 
20
+ def default_start_year
21
+ Time.now.year - 1
22
+ end
23
+
24
+ def default_end_year
25
+ Time.now.year + 3
26
+ end
27
+
22
28
  def question_element
23
29
  @question_element ||= elements.find{|element| element.is_a? Smartdown::Model::Element::Question::Date}
24
30
  end
@@ -45,7 +45,8 @@ module Smartdown
45
45
  private
46
46
 
47
47
  def markdown_element?(element)
48
- (element.is_a? Smartdown::Model::Element::MarkdownParagraph) || (element.is_a? Smartdown::Model::Element::MarkdownHeading)
48
+ (element.is_a? Smartdown::Model::Element::MarkdownLine) ||
49
+ (element.is_a? Smartdown::Model::Element::MarkdownHeading)
49
50
  end
50
51
 
51
52
  def next_node_element?(element)
@@ -36,7 +36,8 @@ module Smartdown
36
36
  attr_reader :elements
37
37
 
38
38
  def markdown_element?(element)
39
- (element.is_a? Smartdown::Model::Element::MarkdownParagraph) || (element.is_a? Smartdown::Model::Element::MarkdownHeading)
39
+ (element.is_a? Smartdown::Model::Element::MarkdownLine) ||
40
+ (element.is_a? Smartdown::Model::Element::MarkdownHeading)
40
41
  end
41
42
 
42
43
  def smartdown_element?(element)
@@ -63,7 +63,7 @@ module Smartdown
63
63
  end
64
64
 
65
65
  INTERPOLATOR_CONFIG = {
66
- Smartdown::Model::Element::MarkdownParagraph => ElementContentInterpolator,
66
+ Smartdown::Model::Element::MarkdownLine => ElementContentInterpolator,
67
67
  Smartdown::Model::Element::MarkdownHeading => ElementContentInterpolator
68
68
  }
69
69
 
@@ -1,7 +1,7 @@
1
1
  module Smartdown
2
2
  module Model
3
3
  module Element
4
- MarkdownParagraph = Struct.new(:content)
4
+ MarkdownLine = Struct.new(:content)
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,51 @@
1
+ module Smartdown
2
+ module Model
3
+ =begin
4
+ We had to create this Struct for storing multiple Smartdown::Model elements due
5
+ to the syntax used in parsing.
6
+
7
+ In the parsing rule below:
8
+ ```
9
+ rule(:markdown_elements) {
10
+ markdown_element.repeat(1, 1) >>
11
+ (newline.repeat(1).as(:blank_line) >> markdown_element.as(:element)).repeat
12
+ }
13
+ ```
14
+
15
+ the `(newline.repeat(1).as(:blank_line) >> markdown_element.as(:element)).repeat` snippet creates
16
+ a hash with two key/value pairs to transform.
17
+
18
+ In order to avoid too much verbosity in the NodeTransform, using the markup "element" instead
19
+ of relying on the naming given by the markdown element parsing itself means we can catch all those cases
20
+ in one generic transform rule:
21
+
22
+ ```
23
+ rule(blank_line: simple(:blank_line), element: subtree(:element)) {
24
+ Smartdown::Model::Elements.new(
25
+ [
26
+ Smartdown::Model::Element::MarkdownLine.new(blank_line.to_s),
27
+ element,
28
+ ]
29
+ )
30
+ }
31
+ ```
32
+
33
+ The other alternative would have been to have to add a new rule for every specific kind of markdown element.
34
+ This `Elements` Struct was created to avoid that much verbosity and brittleness in the transform (we would
35
+ have needed to add another `rule (blank_line...., xxxxx....)` every time we add a new type of markdown element)
36
+
37
+ Last but not least, we couldn't just cast newlines as just any markdown element:
38
+
39
+ ```
40
+ rule(:markdown_elements) {
41
+ markdown_element.repeat(1, 1) >>
42
+ (markdown_element).repeat
43
+ }
44
+ ```
45
+ was not an option since we needed to differentiate between newlines that so happened to be inside broader blocks like
46
+ frontmatter, rules or conditionals, and newlines that separated plain markdown text...
47
+
48
+ =end
49
+ Elements = Struct.new(:elements)
50
+ end
51
+ end
@@ -4,7 +4,14 @@ module Smartdown
4
4
  module Model
5
5
  Node = Struct.new(:name, :elements, :front_matter) do
6
6
  def initialize(name, elements, front_matter = nil)
7
- super(name, elements, front_matter || Smartdown::Model::FrontMatter.new)
7
+ all_elements = elements.map do |element|
8
+ if element.is_a?(Smartdown::Model::Elements)
9
+ element.elements
10
+ else
11
+ element
12
+ end
13
+ end.flatten
14
+ super(name, all_elements, front_matter || Smartdown::Model::FrontMatter.new)
8
15
  end
9
16
 
10
17
  def title
@@ -12,11 +19,11 @@ module Smartdown
12
19
  end
13
20
 
14
21
  def body
15
- markdown_blocks_before_question.map { |block| as_markdown(block) }.compact.join("\n")
22
+ markdown_blocks_before_question.map { |block| as_markdown(block) }.compact.join
16
23
  end
17
24
 
18
25
  def post_body
19
- markdown_blocks_after_question.map { |block| as_markdown(block) }.compact.join("\n")
26
+ markdown_blocks_after_question.map { |block| as_markdown(block) }.compact.join
20
27
  end
21
28
 
22
29
  def questions
@@ -50,14 +57,14 @@ module Smartdown
50
57
  def markdown_blocks_before_question
51
58
  elements.take_while { |e|
52
59
  e.is_a?(Smartdown::Model::Element::MarkdownHeading) ||
53
- e.is_a?(Smartdown::Model::Element::MarkdownParagraph)
60
+ e.is_a?(Smartdown::Model::Element::MarkdownLine)
54
61
  }[1..-1]
55
62
  end
56
63
 
57
64
  def markdown_blocks_after_question
58
65
  elements.reverse.take_while { |e|
59
66
  e.is_a?(Smartdown::Model::Element::MarkdownHeading) ||
60
- e.is_a?(Smartdown::Model::Element::MarkdownParagraph)
67
+ e.is_a?(Smartdown::Model::Element::MarkdownLine)
61
68
  }.reverse
62
69
  end
63
70
 
@@ -73,8 +80,8 @@ module Smartdown
73
80
  def as_markdown(block)
74
81
  case block
75
82
  when Smartdown::Model::Element::MarkdownHeading
76
- "# #{block.content}\n"
77
- when Smartdown::Model::Element::MarkdownParagraph
83
+ "# #{block.content}"
84
+ when Smartdown::Model::Element::MarkdownLine
78
85
  block.content
79
86
  else
80
87
  raise "Unknown markdown block type '#{block.class.to_s}'"
@@ -7,7 +7,7 @@ module Smartdown
7
7
  rule(:ws_char) { space_char | str("\t") }
8
8
  rule(:space_char) { str(" ") }
9
9
  rule(:non_ws_char) { match('\S') }
10
- rule(:carriage_return) { str("\r\n") | str("\n\r") | str("\n") | str("\r") }
10
+ rule(:carriage_return) { str("\n") | str("\r") }
11
11
  rule(:newline) { optional_space >> carriage_return }
12
12
  rule(:line_ending) { eof | newline }
13
13
 
@@ -14,7 +14,7 @@ module Smartdown
14
14
 
15
15
  rule(:markdown_block_inside_conditional) {
16
16
  dollar_keywords = [dollar_if, dollar_else, dollar_elseif, dollar_endif]
17
- dollar_keywords.map(&:absent?).reduce(:>>) >> NodeParser.new.markdown_block
17
+ dollar_keywords.map(&:absent?).reduce(:>>) >> NodeParser.new.markdown_element
18
18
  }
19
19
 
20
20
  rule(:conditional_body_block) {
@@ -22,18 +22,19 @@ module Smartdown
22
22
  }
23
23
 
24
24
  rule(:blocks_inside_conditional) {
25
- conditional_body_block.repeat(1,1) >> (newline.repeat(1) >> conditional_body_block).repeat
25
+ conditional_body_block.repeat(1,1) >> (conditional_body_block).repeat
26
26
  }
27
27
 
28
28
  rule(:else_clause) {
29
- dollar_else >> optional_space >> newline.repeat(2) >>
30
- (blocks_inside_conditional.as(:false_case) >> newline).maybe
29
+ dollar_else >>
30
+ optional_space >> newline.repeat(1) >>
31
+ (blocks_inside_conditional.as(:false_case)).maybe
31
32
  }
32
33
 
33
34
  rule(:elseif_clause) {
34
35
  dollar_elseif >> (Predicates.new.as(:predicate) >>
35
- optional_space >> newline.repeat(2) >>
36
- (blocks_inside_conditional.as(:true_case) >> newline).maybe >>
36
+ optional_space >> newline.repeat(1) >>
37
+ (blocks_inside_conditional.as(:true_case)).maybe >>
37
38
  ((elseif_clause | else_clause).maybe)).as(:conditional).repeat(1,1).as(:false_case)
38
39
  }
39
40
 
@@ -41,8 +42,8 @@ module Smartdown
41
42
  (
42
43
  dollar_if >>
43
44
  Predicates.new.as(:predicate) >>
44
- optional_space >> newline.repeat(2) >>
45
- (blocks_inside_conditional.as(:true_case) >> newline).maybe >>
45
+ optional_space >> newline.repeat(1) >>
46
+ (blocks_inside_conditional.as(:true_case)).maybe >>
46
47
  (else_clause | elseif_clause).maybe >>
47
48
  dollar_endif >> optional_space >> line_ending
48
49
  ).as(:conditional)
@@ -4,11 +4,17 @@ module Smartdown
4
4
  module Parser
5
5
  module Element
6
6
  class FrontMatter < Base
7
+ rule(:front_matter_delimiter) {
8
+ str("---") >> newline
9
+ }
7
10
  rule(:front_matter_line) {
8
11
  identifier.as(:name) >> str(":") >> ws >> whitespace_terminated_string.as(:value) >> line_ending
9
12
  }
10
13
  rule(:front_matter) {
11
- front_matter_line.repeat(1).as(:front_matter)
14
+ front_matter_delimiter >>
15
+ front_matter_line.repeat(1).as(:front_matter) >>
16
+ front_matter_delimiter >>
17
+ newline.repeat
12
18
  }
13
19
  root(:front_matter)
14
20
  end
@@ -0,0 +1,14 @@
1
+ require 'smartdown/parser/base'
2
+
3
+ module Smartdown
4
+ module Parser
5
+ module Element
6
+ class MarkdownBlankLine < Base
7
+ rule(:markdown_blank_line) {
8
+ (line_ending).as(:blank)
9
+ }
10
+ root(:markdown_blank_line)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'smartdown/parser/base'
2
+
3
+ module Smartdown
4
+ module Parser
5
+ module Element
6
+ class MarkdownLine < Base
7
+ rule(:markdown_line) {
8
+ (optional_space >> whitespace_terminated_string >> optional_space).as(:line)
9
+ }
10
+ root(:markdown_line)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -9,14 +9,15 @@ require 'smartdown/parser/element/text_question'
9
9
  require 'smartdown/parser/element/country_question'
10
10
  require 'smartdown/parser/element/postcode_question'
11
11
  require 'smartdown/parser/element/markdown_heading'
12
- require 'smartdown/parser/element/markdown_paragraph'
12
+ require 'smartdown/parser/element/markdown_line'
13
+ require 'smartdown/parser/element/markdown_blank_line'
13
14
  require 'smartdown/parser/element/conditional'
14
15
  require 'smartdown/parser/element/next_steps'
15
16
 
16
17
  module Smartdown
17
18
  module Parser
18
19
  class NodeParser < Base
19
- rule(:markdown_block) {
20
+ rule(:markdown_element) {
20
21
  Element::Conditional.new |
21
22
  Element::MarkdownHeading.new |
22
23
  Element::MultipleChoiceQuestion.new |
@@ -28,19 +29,21 @@ module Smartdown
28
29
  Rules.new |
29
30
  Element::StartButton.new |
30
31
  Element::NextSteps.new |
31
- Element::MarkdownParagraph.new
32
+ Element::MarkdownLine.new |
33
+ Element::MarkdownBlankLine.new
32
34
  }
33
35
 
34
- rule(:markdown_blocks) {
35
- markdown_block.repeat(1, 1) >> (newline.repeat(1) >> markdown_block).repeat
36
+ rule(:markdown_elements) {
37
+ markdown_element.repeat(1, 1) >>
38
+ (newline.repeat(1).as(:blank_line) >> markdown_element.as(:element)).repeat
36
39
  }
37
40
 
38
41
  rule(:body) {
39
- markdown_blocks.as(:body) >> newline.repeat
42
+ markdown_elements.as(:body)
40
43
  }
41
44
 
42
45
  rule(:flow) {
43
- Element::FrontMatter.new >> newline.repeat(1) >> body |
46
+ Element::FrontMatter.new >> body |
44
47
  Element::FrontMatter.new |
45
48
  ws >> body
46
49
  }
@@ -2,6 +2,7 @@ require 'parslet/transform'
2
2
  require 'smartdown/parser/option_pairs_transform'
3
3
  require 'smartdown/model/node'
4
4
  require 'smartdown/model/front_matter'
5
+ require 'smartdown/model/elements'
5
6
  require 'smartdown/model/rule'
6
7
  require 'smartdown/model/nested_rule'
7
8
  require 'smartdown/model/next_node_rules'
@@ -13,7 +14,7 @@ require 'smartdown/model/element/question/text'
13
14
  require 'smartdown/model/element/question/postcode'
14
15
  require 'smartdown/model/element/start_button'
15
16
  require 'smartdown/model/element/markdown_heading'
16
- require 'smartdown/model/element/markdown_paragraph'
17
+ require 'smartdown/model/element/markdown_line'
17
18
  require 'smartdown/model/element/conditional'
18
19
  require 'smartdown/model/element/next_steps'
19
20
  require 'smartdown/model/predicate/equality'
@@ -38,12 +39,29 @@ module Smartdown
38
39
  )
39
40
  }
40
41
 
42
+ rule(blank_line: simple(:blank_line), element: subtree(:element)) {
43
+ Smartdown::Model::Elements.new(
44
+ [
45
+ Smartdown::Model::Element::MarkdownLine.new(blank_line.to_s),
46
+ element,
47
+ ]
48
+ )
49
+ }
50
+
41
51
  rule(h1: simple(:content)) {
42
52
  Smartdown::Model::Element::MarkdownHeading.new(content.to_s)
43
53
  }
44
54
 
45
- rule(p: simple(:content)) {
46
- Smartdown::Model::Element::MarkdownParagraph.new(content.to_s)
55
+ rule(:line => simple(:content)) {
56
+ Smartdown::Model::Element::MarkdownLine.new(content.to_s)
57
+ }
58
+
59
+ rule(:blank => simple(:content)) {
60
+ Smartdown::Model::Element::MarkdownLine.new(content.to_s)
61
+ }
62
+
63
+ rule(:blank_line => simple(:content)) {
64
+ Smartdown::Model::Element::MarkdownLine.new(content.to_s)
47
65
  }
48
66
 
49
67
  rule(:start_button => simple(:start_node)) {
@@ -70,7 +88,6 @@ module Smartdown
70
88
  [url.to_s, label.to_s]
71
89
  }
72
90
 
73
-
74
91
  rule(:multiple_choice => {identifier: simple(:identifier), :option_pairs => subtree(:option_pairs), options: subtree(:choices)}) {
75
92
  Smartdown::Model::Element::Question::MultipleChoice.new(
76
93
  identifier.to_s,
@@ -1,3 +1,3 @@
1
1
  module Smartdown
2
- VERSION = "0.11.4"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -48,6 +48,7 @@ describe "Smartdown.parse" do
48
48
 
49
49
  it "has a body" do
50
50
  expect(coversheet.body).to eq(<<-EXPECTED)
51
+
51
52
  This is the body markdown.
52
53
 
53
54
  It has many paragraphs
@@ -57,6 +58,9 @@ of text.
57
58
  * can
58
59
  * have
59
60
  * lists
61
+
62
+
63
+ And handles multiple new lines
60
64
  EXPECTED
61
65
  end
62
66
  end
@@ -80,15 +84,18 @@ EXPECTED
80
84
 
81
85
  it "has two body paras" do
82
86
  expect(question_node.body).to eq(<<-EXPECTED)
87
+
83
88
  Body text line 1.
84
89
 
85
90
  Body text
86
91
  para 2.
92
+
87
93
  EXPECTED
88
94
  end
89
95
 
90
96
  it "has a post body" do
91
97
  expect(question_node.post_body).to eq(<<-EXPECTED)
98
+
92
99
  Text after the question.
93
100
  EXPECTED
94
101
  end
@@ -6,7 +6,7 @@ require 'smartdown/model/front_matter'
6
6
  require 'smartdown/model/next_node_rules'
7
7
  require 'smartdown/model/element/question/date'
8
8
  require 'smartdown/model/element/markdown_heading'
9
- require 'smartdown/model/element/markdown_paragraph'
9
+ require 'smartdown/model/element/markdown_line'
10
10
 
11
11
  describe Smartdown::Api::Node do
12
12
 
@@ -44,17 +44,17 @@ describe Smartdown::Api::Node do
44
44
 
45
45
  let(:body_content) { "I <3 bodyshopping" }
46
46
  let(:body_element) {
47
- Smartdown::Model::Element::MarkdownParagraph.new(body_content)
47
+ Smartdown::Model::Element::MarkdownLine.new(body_content)
48
48
  }
49
49
 
50
50
  let(:post_body_content) { "hur hur such content" }
51
51
  let(:post_body_element) {
52
- Smartdown::Model::Element::MarkdownParagraph.new(post_body_content)
52
+ Smartdown::Model::Element::MarkdownLine.new(post_body_content)
53
53
  }
54
54
 
55
55
  let(:other_post_body_content) { "Postman Pat and his black and white cat" }
56
56
  let(:other_post_body_element) {
57
- Smartdown::Model::Element::MarkdownParagraph.new(other_post_body_content)
57
+ Smartdown::Model::Element::MarkdownLine.new(other_post_body_content)
58
58
  }
59
59
 
60
60
 
@@ -2,7 +2,7 @@ require 'smartdown/api/question'
2
2
  require 'smartdown/api/date_question'
3
3
  require 'smartdown/model/element/question/date'
4
4
  require 'smartdown/model/element/markdown_heading'
5
- require 'smartdown/model/element/markdown_paragraph'
5
+ require 'smartdown/model/element/markdown_line'
6
6
 
7
7
  describe Smartdown::Api::Question do
8
8
 
@@ -22,12 +22,12 @@ describe Smartdown::Api::Question do
22
22
 
23
23
  let(:body_content) { 'I <3 bodyshopping' }
24
24
  let(:body_element) {
25
- Smartdown::Model::Element::MarkdownParagraph.new(body_content)
25
+ Smartdown::Model::Element::MarkdownLine.new(body_content)
26
26
  }
27
27
 
28
28
  let(:post_body_content) { 'hur hur such content' }
29
29
  let(:post_body_element) {
30
- Smartdown::Model::Element::MarkdownParagraph.new(post_body_content)
30
+ Smartdown::Model::Element::MarkdownLine.new(post_body_content)
31
31
  }
32
32
 
33
33
 
@@ -10,10 +10,10 @@ describe Smartdown::Engine::ConditionalResolver do
10
10
  conditional do
11
11
  named_predicate "pred?"
12
12
  true_case do
13
- paragraph("True case")
13
+ line("True case")
14
14
  end
15
15
  false_case do
16
- paragraph("False case")
16
+ line("False case")
17
17
  end
18
18
  end
19
19
  end
@@ -29,7 +29,7 @@ describe Smartdown::Engine::ConditionalResolver do
29
29
 
30
30
  let(:expected_node_after_presentation) {
31
31
  model_builder.node("outcome_no_visa_needed") do
32
- paragraph("True case")
32
+ line("True case")
33
33
  end
34
34
  }
35
35
 
@@ -48,7 +48,7 @@ describe Smartdown::Engine::ConditionalResolver do
48
48
 
49
49
  let(:expected_node_after_presentation) {
50
50
  model_builder.node("outcome_no_visa_needed") do
51
- paragraph("False case")
51
+ line("False case")
52
52
  end
53
53
  }
54
54
 
@@ -63,13 +63,13 @@ describe Smartdown::Engine::ConditionalResolver do
63
63
  conditional do
64
64
  named_predicate "pred1?"
65
65
  true_case do
66
- paragraph("True case")
66
+ line("True case")
67
67
  end
68
68
  false_case do
69
69
  conditional do
70
70
  named_predicate "pred2?"
71
71
  true_case do
72
- paragraph("False True case")
72
+ line("False True case")
73
73
  end
74
74
  end
75
75
  end
@@ -88,7 +88,7 @@ describe Smartdown::Engine::ConditionalResolver do
88
88
 
89
89
  let(:expected_node_after_presentation) {
90
90
  model_builder.node("outcome_no_visa_needed") do
91
- paragraph("True case")
91
+ line("True case")
92
92
  end
93
93
  }
94
94
 
@@ -110,7 +110,7 @@ describe Smartdown::Engine::ConditionalResolver do
110
110
 
111
111
  let(:expected_node_after_presentation) {
112
112
  model_builder.node("outcome_no_visa_needed") do
113
- paragraph("False True case")
113
+ line("False True case")
114
114
  end
115
115
  }
116
116
 
@@ -37,14 +37,14 @@ describe Smartdown::Engine::Interpolator do
37
37
  let(:node) {
38
38
  model_builder.node("example") do
39
39
  heading("a heading")
40
- paragraph("some_stuff")
40
+ line("some_stuff")
41
41
  conditional do
42
42
  named_predicate "pred?"
43
43
  true_case do
44
- paragraph("True case")
44
+ line("True case")
45
45
  end
46
46
  false_case do
47
- paragraph("False case")
47
+ line("False case")
48
48
  end
49
49
  end
50
50
  multiple_choice("example", {})
@@ -58,7 +58,7 @@ describe Smartdown::Engine::Interpolator do
58
58
  end
59
59
 
60
60
  context "a node with a paragraph containing an interpolation" do
61
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('Hello %{name}')] }
61
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('Hello %{name}')] }
62
62
 
63
63
  it "interpolates the name into the paragraph content" do
64
64
  expect(interpolated_node.elements.first.content).to eq("Hello #{example_name}")
@@ -74,7 +74,7 @@ describe Smartdown::Engine::Interpolator do
74
74
  end
75
75
 
76
76
  context "a paragraph containing function call" do
77
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{double(number)}')] }
77
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{double(number)}')] }
78
78
  let(:state) {
79
79
  Smartdown::Engine::State.new(
80
80
  current_node: node.name,
@@ -88,7 +88,7 @@ describe Smartdown::Engine::Interpolator do
88
88
  end
89
89
 
90
90
  context "a paragraph containing function call with two arguments" do
91
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{multiply(number other_number)}')] }
91
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{multiply(number other_number)}')] }
92
92
  let(:state) {
93
93
  Smartdown::Engine::State.new(
94
94
  current_node: node.name,
@@ -103,7 +103,7 @@ describe Smartdown::Engine::Interpolator do
103
103
  end
104
104
 
105
105
  context "a paragraph containing a date answer" do
106
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{date_answer}')] }
106
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{date_answer}')] }
107
107
  let(:state) {
108
108
  Smartdown::Engine::State.new(
109
109
  current_node: node.name,
@@ -116,7 +116,7 @@ describe Smartdown::Engine::Interpolator do
116
116
  end
117
117
 
118
118
  context "a paragraph containing a money answer" do
119
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{money_answer}')] }
119
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{money_answer}')] }
120
120
  let(:state) {
121
121
  Smartdown::Engine::State.new(
122
122
  current_node: node.name,
@@ -129,7 +129,7 @@ describe Smartdown::Engine::Interpolator do
129
129
  end
130
130
 
131
131
  context "a paragraph containing a text answer" do
132
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{text_answer}')] }
132
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{text_answer}')] }
133
133
  let(:state) {
134
134
  Smartdown::Engine::State.new(
135
135
  current_node: node.name,
@@ -142,7 +142,7 @@ describe Smartdown::Engine::Interpolator do
142
142
  end
143
143
 
144
144
  context "a paragraph containing a multuple-choice answer" do
145
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{multiple_choice_answer}')] }
145
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{multiple_choice_answer}')] }
146
146
  let(:choices) { { 'dog' => 'Dog', 'growlithe' => 'Growlithe', 'arcanine' => 'Arcanine' } }
147
147
  let(:question) { Smartdown::Model::Element::Question::MultipleChoice.new('arcanine', choices) }
148
148
  let(:state) {
@@ -157,7 +157,7 @@ describe Smartdown::Engine::Interpolator do
157
157
  end
158
158
 
159
159
  context "a paragraph containing a country answer" do
160
- let(:elements) { [Smartdown::Model::Element::MarkdownParagraph.new('%{country_answer}')] }
160
+ let(:elements) { [Smartdown::Model::Element::MarkdownLine.new('%{country_answer}')] }
161
161
  let(:country_hash) { { 'united-kingdom' => 'United Kingdom' } }
162
162
  let(:question) { Smartdown::Model::Element::Question::Country.new('united-kingdom', country_hash) }
163
163
  let(:state) {