Skip to content

Commit 5237ee3

Browse files
committed
Extract Line.text/1
1 parent 2803c63 commit 5237ee3

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/mudbrick/text_block/line.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ defmodule Mudbrick.TextBlock.Line do
1818
def wrap(text, opts) do
1919
%__MODULE__{parts: [Part.wrap(text, opts)]}
2020
end
21+
22+
def text(line) do
23+
Enum.map_join(line.parts, "", & &1.text)
24+
end
2125
end

lib/mudbrick/text_block/output.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,19 @@ defmodule Mudbrick.TextBlock.Output do
5858

5959
alias Mudbrick.TextBlock.Output
6060

61-
defp text(line) do
62-
Enum.map_join(line.parts, "", & &1.text)
63-
end
64-
6561
def reduce_lines(output, [line], measure) do
6662
output
6763
|> Output.end_block()
6864
|> reduce_parts(line)
69-
|> measure.(text(line), 1)
65+
|> measure.(Line.text(line), 1)
7066
|> Output.start_block()
7167
end
7268

7369
def reduce_lines(output, [line | lines], measure) do
7470
output
7571
|> Output.end_block()
7672
|> reduce_parts(line)
77-
|> measure.(text(line), length(lines) + 1)
73+
|> measure.(Line.text(line), length(lines) + 1)
7874
|> Output.start_block()
7975
|> reduce_lines(lines, measure)
8076
end

0 commit comments

Comments
 (0)