Skip to content

Commit 1b4a0a6

Browse files
committed
Some nicer formatting
1 parent ab6109d commit 1b4a0a6

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/syntax_tree/xml/format.rb

+5-8
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,11 @@ def visit_misc(node)
226226

227227
# Format a text by splitting nicely at newlines and spaces.
228228
def format_text(q, value)
229-
q.seplist(
230-
value.strip.split("\n"),
231-
-> { q.breakable(force: true, indent: false) }
232-
) do |line|
233-
q.seplist(
234-
line.split(/\b(?: +)\b/),
235-
-> { q.group { q.breakable } }
236-
) { |segment| q.text(segment) }
229+
sep_line = -> { q.breakable(force: true, indent: false) }
230+
sep_word = -> { q.group { q.breakable } }
231+
232+
q.seplist(value.strip.split("\n"), sep_line) do |line|
233+
q.seplist(line.split(/\b(?: +)\b/), sep_word) { |word| q.text(word) }
237234
end
238235
end
239236
end

0 commit comments

Comments
 (0)