Browse Source

Newline after config def is now consumed

Fix #9.
Chris Konstad 4 years ago
parent
commit
4881f5ccc7
4 changed files with 10 additions and 5 deletions
  1. 10 2
      lib/parser.ml
  2. 0 1
      test/test1.md
  3. 0 1
      test/test2.md
  4. 0 1
      test/test3.md

+ 10 - 2
lib/parser.ml

@ -33,11 +33,19 @@ let rec parse text =
33 33
        []
34 34
    ) else
35 35
      let var_length = var_end - var_start + (String.length var_end_string) in
36
      let consume_newline =
37
        try
38
          if text.[var_end + (String.length var_end_string)] = '\n' then 1 else 0
39
        with
40
        (* if character past end of string *)
41
        | _ -> 0
42
      in
36 43
      Text(String.sub text 0 var_start) ::
44
      let next_start = var_start + var_length + consume_newline in
37 45
      let next = parse (String.sub
38 46
                          text
39
                          (var_start + var_length)
40
                          ((String.length text) - (var_start + var_length))) in
47
                          next_start
48
                          ((String.length text) - next_start)) in
41 49
      let name = String.sub text var_start var_length in
42 50
      let name_length = (String.length name) -
43 51
                        (String.length var_start_string) -

+ 0 - 1
test/test1.md

@ -1,2 +1 @@
1

													
2 1
I like apple pie with vanilla ice cream.

+ 0 - 1
test/test2.md

@ -1,2 +1 @@
1

													
2 1
I like apple pie with vanilla ice cream.

+ 0 - 1
test/test3.md

@ -1,2 +1 @@
1

													
2 1
I like apple pie with vanilla ice cream.