Skip to content

Commit 9fd1f72

Browse files
committed
Work around for elm/core bug
elm/core#1137
1 parent f9427c9 commit 9fd1f72

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/MarkdownAst.elm

+6-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,12 @@ normalizePlainText rawStr =
343343

344344
hasLastSpace =
345345
String.right 1 rawStr
346-
|> String.any isWhiteSpace
346+
-- `|> String.any isWhiteSpace` may cause infinite loop
347+
|> String.foldl
348+
(\c acc ->
349+
acc || isWhiteSpace c
350+
)
351+
False
347352

348353
words =
349354
case normalizedWords rawStr of

src/Sample.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ myMarkdown =
2828
{ ordered = False
2929
, items =
3030
[ { content =
31-
[ Ast.PlainText "List Item 1"
31+
[ Ast.PlainText "List Item 1😈"
3232
]
3333
, children =
3434
[ Ast.ListBlock

tests/MarkdownAstSuite.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Markdown AST represents *Markdown* AST.
1818
1919
## Section
2020
21-
* List Item 1
21+
* List Item 1😈
2222
1. Child item
2323
* List Item 2
2424

0 commit comments

Comments
 (0)