From d87aa179ade758a02a9b1609dadc07bf842df635 Mon Sep 17 00:00:00 2001 From: adelon <22380201+adelon@users.noreply.github.com> Date: Tue, 21 May 2024 19:23:59 +0200 Subject: Allow line breaks via `\textbox`, handle `\left`/`\right` --- source/Syntax/Concrete/Keywords.hs | 4 ++-- source/Syntax/Token.hs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/Syntax') diff --git a/source/Syntax/Concrete/Keywords.hs b/source/Syntax/Concrete/Keywords.hs index e0f577e..135cdac 100644 --- a/source/Syntax/Concrete/Keywords.hs +++ b/source/Syntax/Concrete/Keywords.hs @@ -203,7 +203,7 @@ _haveIntro = _thus <|> _particularly <|> _have _colon :: Prod r Text (Located Token) SourcePos _colon = symbol ":" ? ":" _pipe :: Prod r Text (Located Token) SourcePos -_pipe = symbol "|" <|> command "mid" ? "\\mid" +_pipe = (optional (command "middle") *> symbol "|") <|> command "mid" ? "\\mid" _comma :: Prod r Text (Located Token) SourcePos _comma = symbol "," ? "," _commaAnd :: Prod r Text (Located Token) SourcePos @@ -219,4 +219,4 @@ _eq = symbol "=" ? "=" _in :: Prod r Text (Located Token) SourcePos _in = symbol "∈" <|> command "in" ? "\\in" _subseteq :: Prod r Text (Located Token) SourcePos -_subseteq = command "subseteq" ? ":" +_subseteq = command "subseteq" ? "\\subseteq" diff --git a/source/Syntax/Token.hs b/source/Syntax/Token.hs index eb0950f..65c02ca 100644 --- a/source/Syntax/Token.hs +++ b/source/Syntax/Token.hs @@ -228,7 +228,7 @@ mathToken = beginText :: Lexer (Located Token) beginText = lexeme do - Char.string "\\text{" + Char.string "\\text{" <|> Char.string "\\textbox{" setTextMode pure (BeginEnv "text") @@ -249,14 +249,14 @@ textToken = word <|> symbol <|> begin <|> end <|> textEnd <|> mathBegin <|> alig setMathMode pure (EndEnv "text") - opening' = lexeme (brace <|> group <|> paren <|> bracket) + opening' = lexeme (group <|> optional (Char.string "\\left") *> (brace <|> paren <|> bracket)) where brace = VisibleBraceL <$ lexeme (Char.string "\\{") group = InvisibleBraceL <$ lexeme (Char.char '{') <* modify' incrNesting paren = ParenL <$ lexeme (Char.char '(') bracket = BracketL <$ lexeme (Char.char '[') - closing' = lexeme (brace <|> group <|> paren <|> bracket) + closing' = lexeme (group <|> optional (Char.string "\\right") *> (brace <|> paren <|> bracket)) where brace = VisibleBraceR <$ lexeme (Char.string "\\}") group = InvisibleBraceR <$ lexeme (Char.char '}') <* modify' decrNesting -- cgit v1.2.3