File tree Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ let ends_by_semi_semi c =
219219 match List. rev c with
220220 | h :: _ ->
221221 let len = String. length h in
222- len > 2 && h.[len - 1 ] = ';' && h.[len - 2 ] = ';'
222+ len > 2 && Astring.String. is_suffix ~affix: " ;; " h
223223 | _ -> false
224224
225225let pp_line_directive ppf (file , line ) = Fmt. pf ppf " #%d %S" line file
Original file line number Diff line number Diff line change @@ -159,3 +159,7 @@ val executable_contents : syntax:Syntax.t -> t -> string list
159159 (e.g. the phrase result is discarded). *)
160160
161161val is_active : ?section : string -> t -> bool
162+
163+ (* * {2 Helpers} *)
164+
165+ val ends_by_semi_semi : string list -> bool
Original file line number Diff line number Diff line change @@ -141,15 +141,10 @@ module Phrase = struct
141141 let endpos = lexbuf.Lexing. lex_curr_p in
142142 { doc = { lexbuf; contents }; startpos; endpos; parsed }
143143
144- let ends_by_semi_semi c =
145- match List. rev c with
146- | h :: _ ->
147- let len = String. length h in
148- len > 2 && h.[len - 1 ] = ';' && h.[len - 2 ] = ';'
149- | _ -> false
150-
151144 let parse lines =
152- let lines = if ends_by_semi_semi lines then lines else lines @ [ " ;;" ] in
145+ let lines =
146+ if Mdx.Block. ends_by_semi_semi lines then lines else lines @ [ " ;;" ]
147+ in
153148 match parse lines with exception End_of_file -> None | t -> Some t
154149
155150 (* * Returns the name of the toplevel directive or [None] if the given phrase
@@ -394,13 +389,9 @@ let rtrim l = List.rev (ltrim (List.rev l))
394389let trim l = ltrim (rtrim (List. map trim_line l))
395390
396391let cut_into_sentences l =
397- let ends_by_semi_semi h =
398- let len = String. length h in
399- len > 2 && h.[len - 1 ] = ';' && h.[len - 2 ] = ';'
400- in
401392 let rec aux acc sentence = function
402393 | [] -> List. rev (List. rev sentence :: acc)
403- | h :: t when ends_by_semi_semi h ->
394+ | h :: t when Mdx.Block. ends_by_semi_semi [ h ] ->
404395 aux (List. rev (h :: sentence) :: acc) [] t
405396 | h :: t -> aux acc (h :: sentence) t
406397 in
You can’t perform that action at this time.
0 commit comments