diff --git a/src/MarkdownAst.elm b/src/MarkdownAst.elm index 5ceb5d1..80107cb 100644 --- a/src/MarkdownAst.elm +++ b/src/MarkdownAst.elm @@ -343,7 +343,12 @@ normalizePlainText rawStr = hasLastSpace = String.right 1 rawStr - |> String.any isWhiteSpace + -- `|> String.any isWhiteSpace` may cause infinite loop + |> String.foldl + (\c acc -> + acc || isWhiteSpace c + ) + False words = case normalizedWords rawStr of diff --git a/src/Sample.elm b/src/Sample.elm index 7b18432..d04518f 100644 --- a/src/Sample.elm +++ b/src/Sample.elm @@ -28,7 +28,7 @@ myMarkdown = { ordered = False , items = [ { content = - [ Ast.PlainText "List Item 1" + [ Ast.PlainText "List Item 1😈" ] , children = [ Ast.ListBlock diff --git a/tests/MarkdownAstSuite.elm b/tests/MarkdownAstSuite.elm index ea75ba8..0e511fb 100644 --- a/tests/MarkdownAstSuite.elm +++ b/tests/MarkdownAstSuite.elm @@ -18,7 +18,7 @@ Markdown AST represents *Markdown* AST. ## Section -* List Item 1 +* List Item 1😈 1. Child item * List Item 2