Skip to content

Commit 2286b77

Browse files
committed
Refactor text truncation logic in markdown formatter for improved readability
1 parent 2994e6c commit 2286b77

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/ex_doc/formatter/markdown.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@ defmodule ExDoc.Formatter.Markdown do
167167
"No documentation available"
168168

169169
text ->
170-
text
171-
|> String.slice(0, 150)
172-
|> then(fn s -> if String.length(s) == 150, do: s <> "...", else: s end)
170+
if String.length(text) > 150 do
171+
String.slice(text, 0, 150) <> "..."
172+
else
173+
text
174+
end
173175
end
174176
end
175177

0 commit comments

Comments
 (0)