Skip to content

Commit

Permalink
fix: parse whitespace as text even if not followed by non-whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen committed Dec 7, 2023
1 parent d9c12fd commit 298600e
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/leandoc/LeanDoc/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ mutual
nodeFn ``text <|
nodeFn strLitKind <|
asStringFn (unescape := true) (quoted := true) <|
atomicFn (manyFn (chFn ' ') >> inlineTextChar) >>
manyFn inlineTextChar
many1Fn inlineTextChar
partial def link (ctxt : InlineCtxt) :=
nodeFn ``link <|
Expand Down Expand Up @@ -1196,7 +1195,7 @@ structure BlockCtxt where
inLists : List InList := []
deriving Inhabited, Repr
def fakeAtom (str : String) : ParserFn := fun c s =>
def fakeAtom (str : String) : ParserFn := fun _c s =>
let atom := mkAtom SourceInfo.none str
s.pushSyntax atom
Expand Down Expand Up @@ -2345,3 +2344,37 @@ All input consumed.
-/
#guard_msgs in
#eval directive {} |>.test! " ::: multiPara\n foo\n\n * List item \n :::"
/--
info: Success! Final stack:
(LeanDoc.Syntax.text (str "\" \""))
Remaining:
"[\\[link\\]](https://link.com)"
-/
#guard_msgs in
#eval text |>.test! " [\\[link\\]](https://link.com)"
/--
info: Success! Final stack:
[(LeanDoc.Syntax.para
[(LeanDoc.Syntax.link
"["
[(LeanDoc.Syntax.text (str "\"[link A]\""))]
"]"
(LeanDoc.Syntax.url
"("
(str "\"https://example.com\"")
")"))
(LeanDoc.Syntax.text (str "\" \""))
(LeanDoc.Syntax.link
"["
[(LeanDoc.Syntax.text (str "\"[link B]\""))]
"]"
(LeanDoc.Syntax.url
"("
(str "\"https://more.example.com\"")
")"))])]
All input consumed.
-/
#guard_msgs in
#eval blocks {} |>.test! "[\\[link A\\]](https://example.com) [\\[link B\\]](https://more.example.com)"

0 comments on commit 298600e

Please sign in to comment.