mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 17:10:22 +03:00
feat(lexer): allows to use '`' inside law text
This commit is contained in:
parent
54067f337f
commit
4e6e532ce8
@ -554,7 +554,9 @@ let lex_law (lexbuf : lexbuf) : token =
|
||||
LAW_INCLUDE (Ast.PdfFile ((name, Pos.from_lpos pos), pages))
|
||||
else LAW_INCLUDE (Ast.CatalaFile (name, Pos.from_lpos pos))
|
||||
| Plus '#', Star white_space, Plus (Compl '\n'), Star white_space, '\n' -> get_law_heading lexbuf
|
||||
| Plus (Compl ('#' | '`' | '>')) -> LAW_TEXT (Utf8.lexeme lexbuf)
|
||||
| Plus (Compl ('#' | '`' | '>') | Rep ('`', 1 .. 2), Compl '`' | "```", (Plus white_space | '\n'))
|
||||
->
|
||||
LAW_TEXT (Utf8.lexeme lexbuf)
|
||||
| _ -> raise_lexer_error (Pos.from_lpos prev_pos) prev_lexeme
|
||||
|
||||
(** Entry point of the lexer, distributes to {!val: lex_code} or {!val: lex_law} depending of {!val:
|
||||
|
@ -0,0 +1,2 @@
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] literate_parsing_is_ok = true
|
26
tests/test_literate/good/test_spe_char.catala
Normal file
26
tests/test_literate/good/test_spe_char.catala
Normal file
@ -0,0 +1,26 @@
|
||||
## Law text should be able to contain '`'.
|
||||
|
||||
This is a block of law text containing `.
|
||||
This allows to:
|
||||
|
||||
* use `Markdown` code block inside `Catala` files,
|
||||
|
||||
* _escape_ special characters such as `#` or `>`,
|
||||
|
||||
* use Fenced Code Blocks:
|
||||
|
||||
```
|
||||
let () = print_endline "Hello world!"
|
||||
```
|
||||
|
||||
**Remark**: for Fenced Code Blocks, ``` must be followed by a space or a new line.
|
||||
|
||||
```catala
|
||||
new scope Test :
|
||||
param literate_parsing_is_ok content bool
|
||||
|
||||
scope Test :
|
||||
def literate_parsing_is_ok := true
|
||||
```
|
||||
|
||||
Even after `Catala` code block.
|
Loading…
Reference in New Issue
Block a user