Skip to content

Commit 6a6e941

Browse files
committed
Use {%math: ...%} instead of {%math ...%}
See ocaml/odoc#811 (comment)
1 parent fe410bc commit 6a6e941

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/lexer.mll

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ let raw_markup =
262262
let raw_markup_target =
263263
([^ ':' '%'] | '%'+ [^ ':' '%' '}'])* '%'*
264264

265-
let math_block = raw_markup
266-
267265
let language_tag_char =
268266
['a'-'z' 'A'-'Z' '0'-'9' '_' '-' ]
269267

@@ -366,19 +364,13 @@ rule token input = parse
366364
{ verbatim
367365
(Buffer.create 1024) None (Lexing.lexeme_start lexbuf) input lexbuf }
368366

369-
| "{%math" horizontal_space (raw_markup as s) ("%}" | eof as e)
370-
{ let token = `Math (true, s) in
371-
if e <> "%}" then
372-
warning
373-
input
374-
~start_offset:(Lexing.lexeme_end lexbuf)
375-
(Parse_error.not_allowed
376-
~what:(Token.describe `End)
377-
~in_what:(Token.describe token));
378-
emit input token }
379367
| "{%" ((raw_markup_target as target) ':')? (raw_markup as s)
380368
("%}" | eof as e)
381-
{ let token = `Raw_markup (target, s) in
369+
{ let token =
370+
match target with
371+
| Some "math" -> `Math (true, s)
372+
| _ -> `Raw_markup (target, s)
373+
in
382374
if e <> "%}" then
383375
warning
384376
input

test/test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5310,7 +5310,7 @@ let%expect_test _ =
53105310
let%expect_test _ =
53115311
let module Math = struct
53125312
let block =
5313-
test "{%math \\sum_{i=0}^n x^i%}";
5313+
test "{%math:\\sum_{i=0}^n x^i%}";
53145314
[%expect {|
53155315
((output
53165316
(((f.ml (1 0) (1 25))

0 commit comments

Comments
 (0)