1 # Pleroma: A lightweight social networking server
2 # Copyright © 2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4 defmodule Pleroma.EarmarkRendererTest do
8 code = ~s[Hello\n\nWorld!]
9 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
10 assert result == "<p>Hello</p><p>World!</p>"
14 code = ~s[<a href="http://example.org/">OwO</a><!-- what's this?-->]
15 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
16 assert result == "<p>#{code}</p>"
20 code = ~s[before\n\n-----\n\nafter]
21 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
22 assert result == "<p>before</p><hr /><p>after</p>"
26 code = ~s[# h1\n## h2\n### h3\n]
27 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
28 assert result == ~s[<h1>h1</h1><h2>h2</h2><h3>h3</h3>]
32 code = ~s[> whoms't are you quoting?]
33 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
34 assert result == "<blockquote><p>whoms’t are you quoting?</p></blockquote>"
39 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
40 assert result == ~s[<p><code class="inline">mix</code></p>]
43 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
44 assert result == ~s[<p><code class="inline">mix</code></p>]
46 code = ~s[```\nputs "Hello World"\n```]
47 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
48 assert result == ~s[<pre><code class="">puts "Hello World"</code></pre>]
52 code = ~s[- one\n- two\n- three\n- four]
53 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
54 assert result == "<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>"
56 code = ~s[1. one\n2. two\n3. three\n4. four\n]
57 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
58 assert result == "<ol><li>one</li><li>two</li><li>three</li><li>four</li></ol>"
61 test "delegated renderers" do
63 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
64 assert result == "<p>#{code}</p>"
67 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
68 assert result == ~s[<p><em>aaaa~</em></p>]
71 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
72 assert result == ~s[<p><strong>aaaa~</strong></p>]
75 code = ~s[<del>aaaa~</del>]
76 result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer})
77 assert result == ~s[<p><del>aaaa~</del></p>]