<commit_before>defmodule CmarkTest do
  use ExUnit.Case, async: true

  @cmark_specs "test/cmark_specs.json" |> File.read! |> Poison.decode!(keys: :atoms)

  for %{
        section: section,
        example: example,
        markdown: markdown,
        html: html,
        start_line: start_line,
        end_line: end_line
      } <- @cmark_specs do
    test "Section: »#{section}«, Example: #{example}, Lines: #{start_line}-#{end_line}" do
      real_markdown = unquote(markdown)
      actual_html   = Cmark.to_html(real_markdown)
      expected_html = unquote(html)
      error_message = """
      MARKDOWN: #{inspect real_markdown}
      ACTUAL:   #{inspect actual_html}
      EXPECTED: #{inspect expected_html}
      """
      assert actual_html == expected_html, error_message
    end
  end

  @cmark_smart_punct "test/cmark_smart_punct.json" |> File.read! |> Poison.decode!(keys: :atoms)

  for %{
        section: section,
        example: example,
        markdown: markdown,
        html: html,
        start_line: start_line,
        end_line: end_line
      } <- @cmark_smart_punct do
    test "Section: »#{section}«, Example: #{example}, Lines: #{start_line}-#{end_line}" do
      real_markdown = unquote(markdown)
      actual_html   = Cmark.to_html(real_markdown, [:smart])
      expected_html = unquote(html)
      error_message = """
      MARKDOWN: #{inspect real_markdown}
      ACTUAL:   #{inspect actual_html}
      EXPECTED: #{inspect expected_html}
      """
      assert actual_html == expected_html, error_message
    end
  end
end
<commit_msg>Add a regression test for #20 Correct the flag constant for :safe<commit_after>defmodule CmarkTest do
  use ExUnit.Case, async: true

  @cmark_specs "test/cmark_specs.json" |> File.read! |> Poison.decode!(keys: :atoms)

  for %{
        section: section,
        example: example,
        markdown: markdown,
        html: html,
        start_line: start_line,
        end_line: end_line
      } <- @cmark_specs do
    test "Section: »#{section}«, Example: #{example}, Lines: #{start_line}-#{end_line}" do
      real_markdown = unquote(markdown)
      actual_html   = Cmark.to_html(real_markdown)
      expected_html = unquote(html)
      error_message = """
      MARKDOWN: #{inspect real_markdown}
      ACTUAL:   #{inspect actual_html}
      EXPECTED: #{inspect expected_html}
      """
      assert actual_html == expected_html, error_message
    end
  end

  @cmark_smart_punct "test/cmark_smart_punct.json" |> File.read! |> Poison.decode!(keys: :atoms)

  for %{
        section: section,
        example: example,
        markdown: markdown,
        html: html,
        start_line: start_line,
        end_line: end_line
      } <- @cmark_smart_punct do
    test "Section: »#{section}«, Example: #{example}, Lines: #{start_line}-#{end_line}" do
      real_markdown = unquote(markdown)
      actual_html   = Cmark.to_html(real_markdown, [:smart])
      expected_html = unquote(html)
      error_message = """
      MARKDOWN: #{inspect real_markdown}
      ACTUAL:   #{inspect actual_html}
      EXPECTED: #{inspect expected_html}
      """
      assert actual_html == expected_html, error_message
    end
  end

  @invalid_when_safe [
    "<script>alert(document.cookie);</script>",
    "</span>",
    "<a href=\"https://example.com\">"
  ]

  for markdown <- @invalid_when_safe do
    test "Removes HTML when :safe is set: #{markdown}" do
      real_markdown = unquote(markdown)
      actual_html  = Cmark.to_html(real_markdown, [:safe])
      expected_html = "<!-- raw HTML omitted -->\n"
      error_message = """
      MARKDOWN: #{inspect real_markdown}
      ACTUAL:   #{inspect actual_html}
      EXPECTED: #{inspect expected_html}
      """
      assert actual_html == expected_html, error_message
    end
  end
end

{'fraction_non_alphanumeric': 0.12164296998420221, 'fraction_numerical': 0.000526592943654555, 'mean_word_length': 2.872579001019368, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5406586', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1234, 'n_words': 281}