forked from pragdave/earmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As discussed in pragdave#393 (comment). I did not name the option "single_line", since newlines in code blocks are preserved even with it on and since Earmark passes the single newlines from the input to the final output. Also removes some string concatenations and replaces single-character binaries with character codes. I did not find a file the tests for this feature would fit in, so I created a new one at `test/acceptance/html/compact_output_test.exs` Closes pragdave#391
- Loading branch information
rinpatch
committed
Nov 25, 2020
1 parent
1193ce4
commit 9983c7b
Showing
4 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
defmodule Acceptance.Html.CompactModeTest do | ||
use Support.AcceptanceTestCase | ||
|
||
describe "Compact mode" do | ||
test "avoids creating newlines" do | ||
markdown = "# h1\n## h2\n### h3\n\n**bold** text *italics*\n>blockquote\n1. list element\n2. list element \n\n `code` [link](http://example.com)" | ||
{:ok, html, _} = as_html(markdown, compact_output: true) | ||
refute html =~ "\n" | ||
end | ||
test "preserves newlines in code blocks" do | ||
markdown = """ | ||
```elixir | ||
Earmark.as_html!(markdown, compact_output: true) | ||
Earmark.as_html!(markdown, compact_output: false) | ||
``` | ||
""" | ||
expected = "<pre><code class=\"elixir\"> Earmark.as_html!(markdown, compact_output: true)\n Earmark.as_html!(markdown, compact_output: false)</code></pre>" | ||
{:ok, html, _} = as_html(markdown, compact_output: true) | ||
assert html == expected | ||
end | ||
end | ||
end |