dashbitco / nimble_publisher

A minimal filesystem-based publishing engine with Markdown support and code highlighting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaks with current Earmark version

optikfluffel opened this issue · comments

commented

When you update Earmark (to 1.4.20 in my case) some of the tests fail:

  1) test does not require recompilation unless paths changed (NimblePublisherTest)
     test/nimble_publisher_test.exs:127
     ** (FunctionClauseError) no function clause matching in Earmark.Transform.make_postprocessor/1

     The following arguments were given to Earmark.Transform.make_postprocessor/1:
     
         # 1
         %{__struct__: Earmark.Options, breaks: false, code_class_prefix: nil, do_smartypants: nil, file: "<no file>", footnote_offset: 1, footnotes: false, gfm: true, gfm_tables: false, line: 1, mapper: &Earmark.pmap/2, mapper_with_timeout: &Earmark.pmap/3, messages: [], pedantic: false, pure_links: true, renderer: Earmark.HtmlRenderer, smartypants: true, timeout: nil}
     
     Attempted function clauses (showing 2 out of 2):
     
         def make_postprocessor(%{postprocessor: nil, registered_processors: rps})
         def make_postprocessor(%{postprocessor: pp, registered_processors: rps})
     
     code: defmodule Example do
     stacktrace:
       (earmark 1.4.20) lib/earmark/transform.ex:179: Earmark.Transform.make_postprocessor/1
       (earmark 1.4.20) lib/earmark/transform.ex:192: Earmark.Transform.postprocessed_ast/2
       (earmark 1.4.20) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
       (earmark 1.4.20) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:110: NimblePublisher.convert_body/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:48: anonymous fn/5 in NimblePublisher.__extract__/2
       (elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:41: NimblePublisher.__extract__/2
       test/nimble_publisher_test.exs:129: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:128: (test)



  2) test passes earmark options to earmark - smartypants on (NimblePublisherTest)
     test/nimble_publisher_test.exs:97
     Assertion with =~ failed
     code:  assert hd(@examples).body =~ "And inline code: <code class=\"inline\">IO.puts “syntax”</code>"
     left:  "<p>\nHere is no code highlight:</p>\n<pre><code>IO.puts &quot;syntax&quot;</code></pre>\n<p>\nAnd inline code: <code class=\"inline\">IO.puts &quot;syntax&quot;</code></p>\n<p>\n“Smartypants quotes without inline code”</p>\n"
     right: "And inline code: <code class=\"inline\">IO.puts “syntax”</code>"
     stacktrace:
       test/nimble_publisher_test.exs:107: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:98: (test)

....

  3) test converts to markdown (NimblePublisherTest)
     test/nimble_publisher_test.exs:40
     ** (FunctionClauseError) no function clause matching in Earmark.Transform.make_postprocessor/1

     The following arguments were given to Earmark.Transform.make_postprocessor/1:
     
         # 1
         %{__struct__: Earmark.Options, breaks: false, code_class_prefix: nil, do_smartypants: nil, file: "<no file>", footnote_offset: 1, footnotes: false, gfm: true, gfm_tables: false, line: 1, mapper: &Earmark.pmap/2, mapper_with_timeout: &Earmark.pmap/3, messages: [], pedantic: false, pure_links: true, renderer: Earmark.HtmlRenderer, smartypants: true, timeout: nil}
     
     Attempted function clauses (showing 2 out of 2):
     
         def make_postprocessor(%{postprocessor: nil, registered_processors: rps})
         def make_postprocessor(%{postprocessor: pp, registered_processors: rps})
     
     code: defmodule Example do
     stacktrace:
       (earmark 1.4.20) lib/earmark/transform.ex:179: Earmark.Transform.make_postprocessor/1
       (earmark 1.4.20) lib/earmark/transform.ex:192: Earmark.Transform.postprocessed_ast/2
       (earmark 1.4.20) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
       (earmark 1.4.20) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:110: NimblePublisher.convert_body/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:48: anonymous fn/5 in NimblePublisher.__extract__/2
       (elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:41: NimblePublisher.__extract__/2
       test/nimble_publisher_test.exs:42: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:41: (test)



  4) test builds all matching entries (NimblePublisherTest)
     test/nimble_publisher_test.exs:21
     ** (FunctionClauseError) no function clause matching in Earmark.Transform.make_postprocessor/1

     The following arguments were given to Earmark.Transform.make_postprocessor/1:
     
         # 1
         %{__struct__: Earmark.Options, breaks: false, code_class_prefix: nil, do_smartypants: nil, file: "<no file>", footnote_offset: 1, footnotes: false, gfm: true, gfm_tables: false, line: 1, mapper: &Earmark.pmap/2, mapper_with_timeout: &Earmark.pmap/3, messages: [], pedantic: false, pure_links: true, renderer: Earmark.HtmlRenderer, smartypants: true, timeout: nil}
     
     Attempted function clauses (showing 2 out of 2):
     
         def make_postprocessor(%{postprocessor: nil, registered_processors: rps})
         def make_postprocessor(%{postprocessor: pp, registered_processors: rps})
     
     code: defmodule Example do
     stacktrace:
       (earmark 1.4.20) lib/earmark/transform.ex:179: Earmark.Transform.make_postprocessor/1
       (earmark 1.4.20) lib/earmark/transform.ex:192: Earmark.Transform.postprocessed_ast/2
       (earmark 1.4.20) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
       (earmark 1.4.20) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:110: NimblePublisher.convert_body/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:48: anonymous fn/5 in NimblePublisher.__extract__/2
       (elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:41: NimblePublisher.__extract__/2
       test/nimble_publisher_test.exs:23: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:22: (test)



  5) test handles highlight blocks (NimblePublisherTest)
     test/nimble_publisher_test.exs:114
     ** (FunctionClauseError) no function clause matching in Earmark.Transform.make_postprocessor/1

     The following arguments were given to Earmark.Transform.make_postprocessor/1:
     
         # 1
         %{__struct__: Earmark.Options, breaks: false, code_class_prefix: nil, do_smartypants: nil, file: "<no file>", footnote_offset: 1, footnotes: false, gfm: true, gfm_tables: false, line: 1, mapper: &Earmark.pmap/2, mapper_with_timeout: &Earmark.pmap/3, messages: [], pedantic: false, pure_links: true, renderer: Earmark.HtmlRenderer, smartypants: true, timeout: nil}
     
     Attempted function clauses (showing 2 out of 2):
     
         def make_postprocessor(%{postprocessor: nil, registered_processors: rps})
         def make_postprocessor(%{postprocessor: pp, registered_processors: rps})
     
     code: defmodule Example do
     stacktrace:
       (earmark 1.4.20) lib/earmark/transform.ex:179: Earmark.Transform.make_postprocessor/1
       (earmark 1.4.20) lib/earmark/transform.ex:192: Earmark.Transform.postprocessed_ast/2
       (earmark 1.4.20) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
       (earmark 1.4.20) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:110: NimblePublisher.convert_body/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:48: anonymous fn/5 in NimblePublisher.__extract__/2
       (elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:41: NimblePublisher.__extract__/2
       test/nimble_publisher_test.exs:116: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:115: (test)

..

  6) test handles code blocks (NimblePublisherTest)
     test/nimble_publisher_test.exs:68
     ** (FunctionClauseError) no function clause matching in Earmark.Transform.make_postprocessor/1

     The following arguments were given to Earmark.Transform.make_postprocessor/1:
     
         # 1
         %{__struct__: Earmark.Options, breaks: false, code_class_prefix: nil, do_smartypants: nil, file: "<no file>", footnote_offset: 1, footnotes: false, gfm: true, gfm_tables: false, line: 1, mapper: &Earmark.pmap/2, mapper_with_timeout: &Earmark.pmap/3, messages: [], pedantic: false, pure_links: true, renderer: Earmark.HtmlRenderer, smartypants: true, timeout: nil}
     
     Attempted function clauses (showing 2 out of 2):
     
         def make_postprocessor(%{postprocessor: nil, registered_processors: rps})
         def make_postprocessor(%{postprocessor: pp, registered_processors: rps})
     
     code: defmodule Example do
     stacktrace:
       (earmark 1.4.20) lib/earmark/transform.ex:179: Earmark.Transform.make_postprocessor/1
       (earmark 1.4.20) lib/earmark/transform.ex:192: Earmark.Transform.postprocessed_ast/2
       (earmark 1.4.20) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
       (earmark 1.4.20) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:110: NimblePublisher.convert_body/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:48: anonymous fn/5 in NimblePublisher.__extract__/2
       (elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
       (nimble_publisher 0.1.1) lib/nimble_publisher.ex:41: NimblePublisher.__extract__/2
       test/nimble_publisher_test.exs:70: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:69: (test)



Finished in 0.2 seconds (0.2s async, 0.00s sync)
12 tests, 6 failures

Randomized with seed 761189

And I also start to get a compilation error in my project:

== Compilation error in file lib/website/blog.ex ==
** (FunctionClauseError) no function clause matching in MapSet.union/2    
    
    The following arguments were given to MapSet.union/2:
    
        # 1
        []
    
        # 2
        []
    
    Attempted function clauses (showing 2 out of 2):
    
        def union(%MapSet{map: map1, version: version} = map_set, %MapSet{map: map2, version: version})
        def union(%MapSet{map: map1}, %MapSet{map: map2})
    
    (elixir 1.13.1) lib/map_set.ex:372: MapSet.union/2
    (earmark_parser 1.4.19) lib/earmark_parser/context.ex:64: EarmarkParser.Context._merge_messages/2
    (earmark_parser 1.4.19) lib/earmark_parser/context.ex:55: EarmarkParser.Context._merge_contexts/2
    (earmark_parser 1.4.19) lib/earmark_parser/context.ex:36: EarmarkParser.Context.prepend/3
    (earmark_parser 1.4.19) lib/earmark_parser/ast_renderer.ex:24: EarmarkParser.AstRenderer._render/3
    (earmark_parser 1.4.19) lib/earmark_parser/ast_renderer.ex:189: EarmarkParser.AstRenderer.render_block/3
    (earmark_parser 1.4.19) lib/earmark_parser/ast_renderer.ex:23: EarmarkParser.AstRenderer._render/3
    (earmark_parser 1.4.19) lib/earmark_parser/ast_renderer.ex:167: EarmarkParser.AstRenderer.render_block/3
    (earmark_parser 1.4.19) lib/earmark_parser/ast_renderer.ex:23: EarmarkParser.AstRenderer._render/3
    (earmark_parser 1.4.19) lib/earmark_parser.ex:494: EarmarkParser.as_ast/2
    (earmark 1.4.19) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
    (earmark 1.4.19) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
    (nimble_publisher 0.1.2) lib/nimble_publisher.ex:44: anonymous fn/5 in NimblePublisher.__extract__/2
    (elixir 1.13.1) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
    (nimble_publisher 0.1.2) lib/nimble_publisher.ex:42: NimblePublisher.__extract__/2
    lib/website/blog.ex:8: (module)

@optikfluffel this is an Elixir bug. Remove _build and you should be good to go. I will investigate the rest. Thanks!

commented

@josevalim Thanks! After doing so only one failing test remains:

  1) test passes earmark options to earmark - smartypants on (NimblePublisherTest)
     test/nimble_publisher_test.exs:97
     Assertion with =~ failed
     code:  assert hd(@examples).body =~ "And inline code: <code class=\"inline\">IO.puts “syntax”</code>"
     left:  "<p>\nHere is no code highlight:</p>\n<pre><code>IO.puts &quot;syntax&quot;</code></pre>\n<p>\nAnd inline code: <code class=\"inline\">IO.puts &quot;syntax&quot;</code></p>\n<p>\n“Smartypants quotes without inline code”</p>\n"
     right: "And inline code: <code class=\"inline\">IO.puts “syntax”</code>"
     stacktrace:
       test/nimble_publisher_test.exs:107: (module)
       (elixir 1.13.1) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
       (elixir 1.13.1) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
       (elixir 1.13.1) src/elixir_module.erl:369: :elixir_module.eval_form/6
       (elixir 1.13.1) src/elixir_module.erl:105: :elixir_module.compile/5
       (elixir 1.13.1) src/elixir_lexical.erl:15: :elixir_lexical.run/3
       test/nimble_publisher_test.exs:98: (test)

Edit: When I also update ex_doc to 0.28.0 I get 7 failing tests, no matter if I delete the _build directory or not.

commented

Wow that was quick, seems fine to me with 0.1.2 now. 💜

I just updated my project to elixir 1.13.2-otp-24, erlang 24.2.1
My dependencies are

      {:earmark, "~> 1.4"},
      {:nimble_publisher, "~> 0.1"},
      {:makeup_elixir, ">= 0.0.0"},
      {:makeup_erlang, ">= 0.0.0"},

After rm -rf _build deps; mix deps.get; mix I get the same error as mentioned above

== Compilation error in file lib/web_client_web/controllers/blog_controller.ex ==
** (FunctionClauseError) no function clause matching in MapSet.union/2

    The following arguments were given to MapSet.union/2:

        # 1
        []

        # 2
        []

    Attempted function clauses (showing 2 out of 2):

        def union(%MapSet{map: map1, version: version} = map_set, %MapSet{map: map2, version: version})
        def union(%MapSet{map: map1}, %MapSet{map: map2})

    (elixir 1.13.2) lib/map_set.ex:372: MapSet.union/2
    (earmark_parser 1.4.19) lib/earmark_parser/context.ex:64: EarmarkParser.Context._merge_messages/2
    (earmark_parser 1.4.19) lib/earmark_parser/context.ex:55: EarmarkParser.Context._merge_contexts/2
    (earmark_parser 1.4.19) lib/earmark_parser/context.ex:36: EarmarkParser.Context.prepend/3
    (earmark_parser 1.4.19) lib/earmark_parser/ast_renderer.ex:24: EarmarkParser.AstRenderer._render/3
    (earmark_parser 1.4.19) lib/earmark_parser.ex:494: EarmarkParser.as_ast/2
    (earmark 1.4.19) lib/earmark/internal.ex:42: Earmark.Internal.as_html/2
    (earmark 1.4.19) lib/earmark/internal.ex:48: Earmark.Internal.as_html!/2
    (nimble_publisher 0.1.2) lib/nimble_publisher.ex:110: NimblePublisher.convert_body/3
    (nimble_publisher 0.1.2) lib/nimble_publisher.ex:48: anonymous fn/5 in NimblePublisher.__extract__/2
    (elixir 1.13.2) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
    (nimble_publisher 0.1.2) lib/nimble_publisher.ex:41: NimblePublisher.__extract__/2
    lib/web_client_web/controllers/blog_controller.ex:14: (module)
    (elixir 1.13.2) lib/kernel/parallel_compiler.ex:346: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/7

Still found no combination of versions that works for me. But using the main branch of each dependency works find aside some warnings.

    {:earmark, git: "git@github.com:pragdave/earmark.git", override: true},
    {:earmark_parser, git: "git@github.com:RobertDober/earmark_parser.git", override: true},
    {:nimble_publisher, git: "git@github.com:dashbitco/nimble_publisher.git", override: true},
    {:makeup_elixir, ">= 0.0.0"},
    {:makeup_erlang, ">= 0.0.0"},

Are you customizing the EarmarkOptions somehow? Or it is the default use?

Are you customizing the EarmarkOptions somehow? Or it is the default use?

all defaults

use NimblePublisher,
    build: Post,
    from: @posts_path,
    as: :posts,
    highlighters: [:makeup_elixir, :makeup_erlang]

  @posts Enum.sort_by(@posts, & &1.date, {:desc, Date})
         |> Post.normalize_tags()
         |> Post.generate_previews()
         |> Post.find_images()

  @tags @posts
        |> Enum.flat_map(& &1.tags)
        |> Enum.map(&String.downcase/1)
        |> Enum.uniq()
        |> Enum.sort()

  def all_posts, do: @posts
  def all_tags, do: @tags
commented

@iboard could you try if updating earmark_parser to 1.4.22 fixes this for you?

@optikfluffel thank you! The following versions and a mix deps.update --all did it.

    {:earmark, "~> 1.4"},
    {:earmark_parser, "~> 1.4.22"},
    {:nimble_publisher, "~> 0.1"},
    {:makeup_elixir, ">= 0.0.0"},
    {:makeup_erlang, ">= 0.0.0"},