//! Latex Parser item = _{ SOI ~ line* ~ EOI } line = _{ para | text | string | other } other = ${ ANY } WHITESPACE = @{ " " | "\t" | NEWLINE } /// Other text text = @{ (!para ~ ANY)+ } /// String string = ${ "{" ~ fn_name* ~ (string_bracket | inner_string) ~ "}" } string_bracket = ${ "(" ~ string ~ ")" } inner_string = @{ (!("}" | ")") ~ ANY)* } /// Paragraph para = ${ function | comment } /// Function fn_name = @{ "\\" ~ ASCII_ALPHA+ ~ ("[" ~ " "* ~ "]")* ~ " "* } function = ${ fn_name ~ (function | string) } comment = @{ "%" ~ (!NEWLINE ~ ANY)+ }