Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing html with unquoted attrs #343

Closed
maartenvanvliet opened this issue Jun 5, 2020 · 2 comments
Closed

Error parsing html with unquoted attrs #343

maartenvanvliet opened this issue Jun 5, 2020 · 2 comments
Assignees
Labels
Milestone

Comments

@maartenvanvliet
Copy link

See this commit for reproduction maartenvanvliet@b6ee420

    test "parses unquoted attrs" do
      markdown = "<div class=my-div>\nline<div>"
      ast      = [{"div", [{"class", "my-div"}], ["line"], @verbatim}]
      messages = []

      assert as_ast(markdown) == {:ok, ast, messages}
    end

It results in

  1) test multiple tags in closing line parses unquoted attrs (Acceptance.Ast.Html.BlockTest)
     test/acceptance/ast/html/block_test.exs:198
     ** (FunctionClauseError) no function clause matching in Earmark.Context.prepend/3

     The following arguments were given to Earmark.Context.prepend/3:
     
         # 1
         ["<div class=my-div>", "line<div>"]
     
         # 2
         []
     
         # 3
         []
     
     Attempted function clauses (showing 1 out of 1):
     
         def prepend(%Earmark.Context{value: value} = ctx, prep, messages)
     
     code: assert as_ast(markdown) == {:ok, ast, messages}
     stacktrace:
       (earmark 1.4.4) lib/earmark/context.ex:41: Earmark.Context.prepend/3
       (earmark 1.4.4) lib/earmark/ast_renderer.ex:27: Earmark.AstRenderer._render/3
       (earmark 1.4.4) lib/earmark.ex:380: Earmark.as_ast/2
       test/acceptance/ast/html/block_test.exs:203: (test)

I've narrowed it down to the attributes in the html without quotes. It works when the quotes are added.

@RobertDober
Copy link
Collaborator

Thank you for reporting this, I'll have a look at it ASAP, BTW do we agree that the quotes are needed?
That said the input still must be accepted and render something meaningful, as e.g.

[{"p", [], "&lt;div class=my-diff>.....&lt;div>", %{}}] # N.B.. This is 1.4.6/1.5 format

@maartenvanvliet
Copy link
Author

Ignoring the unquoted attributes is fine. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants