Skip to content

Commit 3b6a94d

Browse files
committed
Merge branch 'main' into fly
2 parents 5a9fd70 + 87f2a4a commit 3b6a94d

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/wik/markdown.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ defmodule Wik.Markdown do
1919
|> preserve_html_entities()
2020
end
2121

22+
def cleanup(markdown) do
23+
markdown
24+
|> String.trim()
25+
|> String.replace(~r/(\n\s*){3,}/, "\n\n")
26+
end
27+
2228
defp preserve_html_entities(text) do
2329
text
2430
|> String.replace("&", "&")
@@ -44,7 +50,7 @@ defmodule Wik.Markdown do
4450
end
4551

4652
defp transform_node({"a", [{"href", href}], children, meta}, base_path, _embedded_pages) do
47-
max_length = 50
53+
max_length = 40
4854

4955
simple_link? =
5056
case children do

lib/wik/page.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule Wik.Page do
7171

7272
# TODO: rename to create_or_update
7373
def upsert(user_id, group_slug, slug, body) do
74-
body = Markdown.sanitize(body)
74+
body = body |> Markdown.sanitize() |> Markdown.cleanup()
7575
resource_path = Page.resource_path(group_slug, slug)
7676
before = Page.load_raw(group_slug, slug)
7777
new = body

0 commit comments

Comments
 (0)