code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(43 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Text.by_line 3 2026-03-08 "Tomo man-pages"
6 .SH NAME
7 Text.by_line \- iterate by line
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Text.by_line\ :\ func(text:\ Text\ ->\ func(->Text?))
13 .fi
14 .SH DESCRIPTION
15 Returns an iterator function that can be used to iterate over the lines in a text.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx
23 l l l.
24 Name Type Description
25 text Text The text to be iterated over, line by line.
26 .TE
27 .SH RETURN
28 An iterator function that returns one line at a time, until it runs out and returns `none`.
30 .SH NOTES
31 This function ignores a trailing newline if there is one. If you don't want this behavior, use `text.by_split($/{1 nl}/)` instead.
33 .SH EXAMPLES
34 .EX
35 text := "
36 line one
37 line two
39 lines := [line for line in text.by_line()]
40 assert lines == ["line one", "line two"]
41 .EE
42 .SH SEE ALSO
43 .BR Tomo-Text (3)