Permalink
Browse files

Simple_markup: unescape \}} lines (in general, \\+}}$) in pre.

  • Loading branch information...
1 parent 538d18d commit c85767df931eb140de8521f986c1859dc27a0593 @mfp committed Jan 5, 2009
Showing with 14 additions and 2 deletions.
  1. +5 −1 simple_markup.ml
  2. +9 −1 test_simple_markup.ml
View
@@ -205,13 +205,17 @@ and read_list f is_item indent e =
and read_pre kind e =
let kind = match kind with "" -> None | s -> Some s in
+ let re = Str.regexp "^\\\\+}}$" in
+ let unescape = function
+ s when Str.string_match re s 0 -> String.slice ~first:1 s
+ | s -> s in
(* don't forget the last \n *)
let ret ls = Some (Pre (String.concat "\n" (List.rev ("" :: ls)), kind)) in
let rec read_until_end fstindent ls = match Enum.get e with
None | Some (_, "}}", _) -> ret ls
| Some (indentation, s, _) ->
let spaces = String.make (max 0 (indentation - fstindent)) ' ' in
- read_until_end fstindent ((spaces ^ s) :: ls)
+ read_until_end fstindent ((spaces ^ unescape s) :: ls)
in match Enum.get e with
None | Some (_, "}}", _) -> ret []
| Some (indentation, s, _) -> read_until_end indentation [s]
View
@@ -125,7 +125,15 @@ let test_read_pre () =
a
b
c
- }}"
+ }}";
+ check
+ [Pre("a\n }}\n \\}}\n }}}\n", None)]
+ "{{
+ a
+ \\}}
+ \\\\}}
+ }}}
+ }}"
let test_heading () =
for i = 1 to 6 do

0 comments on commit c85767d

Please sign in to comment.