File: error_plugin.ex

package info (click to toggle)
elixir-earmark-parser 1.4.44-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,148 kB
  • sloc: makefile: 9
file content (24 lines) | stat: -rw-r--r-- 509 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
defmodule Support.ErrorPlugin do
  def as_html(lines) do
    if Enum.all?(lines, &correct?/1) do
      "<strong>correct</strong>\n"
    else
      {for line <- lines, correct?(line) do
         "<strong>correct</strong>"
       end,
       for line <- lines, !correct?(line) do
         make_error(line)
       end}
    end
  end

  defp correct?({line, _}) do
    line == "correct"
  end

  defp make_error({_, lnb}) do
    {:error, lnb, "that is incorrect"}
  end
end

# SPDX-License-Identifier: Apache-2.0