Public entry points for rendering rows of strings with the clj-string-layout DSL.
Most applications use layout for vector output, layout-str for newline joined output, or layout-seq for large inputs with explicit column widths. The parse-layout and explain-layout helpers are intended for developing and debugging custom layout strings.
Public entry points for rendering rows of strings with the clj-string-layout DSL. Most applications use layout for vector output, layout-str for newline joined output, or layout-seq for large inputs with explicit column widths. The parse-layout and explain-layout helpers are intended for developing and debugging custom layout strings.
Default configuration merged into every layout config.
Important keys include :width, :align-char, :fill-char, :display-width, :col-widths, :row-count, :word-split-char, :row-split-char, and :raw?. The :layout key is intentionally not defaulted and must be supplied by callers.
:align-char defaults to space. :fill-char defaults to whatever :align-char resolves to (so by default :fill-char is also space). Pass :fill-char explicitly when fill regions should use a different glyph than padded cells.
Default configuration merged into every layout config. Important keys include :width, :align-char, :fill-char, :display-width, :col-widths, :row-count, :word-split-char, :row-split-char, and :raw?. The :layout key is intentionally not defaulted and must be supplied by callers. :align-char defaults to space. :fill-char defaults to whatever :align-char resolves to (so by default :fill-char is also space). Pass :fill-char explicitly when fill regions should use a different glyph than padded cells.
(explain-layout layout-string)(explain-layout row-layout? layout-string)Returns parse diagnostics for a column layout string without throwing.
Returns {:valid? true :layout ...} when parsing succeeds, otherwise {:valid? false :message ... :data ...}. The :data value is the ex-data map that parse-layout would have thrown. Use explain-row-layout for row layouts.
The 2-arity form (row-layout? layout-string) is kept for backwards compatibility.
Returns parse diagnostics for a column layout string without throwing.
Returns {:valid? true :layout ...} when parsing succeeds, otherwise
{:valid? false :message ... :data ...}. The :data value is the ex-data map
that parse-layout would have thrown. Use explain-row-layout for row layouts.
The 2-arity form (row-layout? layout-string) is kept for backwards
compatibility.(explain-row-layout layout-string)Returns parse diagnostics for a row layout string without throwing.
Behaves like explain-layout but parses with row-layout semantics.
Returns parse diagnostics for a row layout string without throwing. Behaves like explain-layout but parses with row-layout semantics.
(layout rows layout-config)Renders rows of strings into a vector of layout lines.
rows may be a string, split with :row-split-char and :word-split-char, or a sequence of row sequences containing strings. Short rows are padded with empty cells to the widest input row unless explicit :col-widths are supplied.
layout-config must include [:layout :cols], a vector whose first item is a layout string. Optional [:layout :rows] entries insert virtual rows such as table borders. See clj-string-layout.predicates for repeat and row predicate helpers.
Returns a vector of strings by default. With :raw? true, returns a vector of row-piece vectors instead, which is useful for post-processing individual cells before joining.
Renders rows of strings into a vector of layout lines. rows may be a string, split with :row-split-char and :word-split-char, or a sequence of row sequences containing strings. Short rows are padded with empty cells to the widest input row unless explicit :col-widths are supplied. layout-config must include [:layout :cols], a vector whose first item is a layout string. Optional [:layout :rows] entries insert virtual rows such as table borders. See clj-string-layout.predicates for repeat and row predicate helpers. Returns a vector of strings by default. With :raw? true, returns a vector of row-piece vectors instead, which is useful for post-processing individual cells before joining.
(layout-into! writer rows layout-config)Writes rendered layout lines to a java.io.Writer, one line per write.
Each line is followed by a single newline. Honors layout-config the same way as layout-seq, so :col-widths and :row-count let large lazy inputs stream to the writer without realizing the whole output. Returns the writer.
Writes rendered layout lines to a java.io.Writer, one line per write. Each line is followed by a single newline. Honors layout-config the same way as layout-seq, so :col-widths and :row-count let large lazy inputs stream to the writer without realizing the whole output. Returns the writer.
(layout-seq rows layout-config)Renders rows of strings as a lazy sequence of layout lines.
The rendering rules are the same as layout. For large data sets, pass :col-widths so rows can be rendered without first retaining the whole input to compute automatic widths. If virtual row layouts are present, pass :row-count so last-row? style predicates can be evaluated without counting the input.
Without :col-widths, exact automatic widths still require realizing all rows before the first output row can be produced. With :raw? true, returns lazy row-piece vectors instead of joined strings.
Renders rows of strings as a lazy sequence of layout lines. The rendering rules are the same as layout. For large data sets, pass :col-widths so rows can be rendered without first retaining the whole input to compute automatic widths. If virtual row layouts are present, pass :row-count so last-row? style predicates can be evaluated without counting the input. Without :col-widths, exact automatic widths still require realizing all rows before the first output row can be produced. With :raw? true, returns lazy row-piece vectors instead of joined strings.
(layout-str rows layout-config)Renders rows and joins the resulting lines with newline characters.
This is a convenience wrapper around layout for consumers that expect a single string rather than a vector of lines.
Renders rows and joins the resulting lines with newline characters. This is a convenience wrapper around layout for consumers that expect a single string rather than a vector of lines.
(parse-layout layout-string)(parse-layout row-layout? layout-string)Parses a column layout string into the diagnostic layout representation.
The returned data is useful for debugging custom layouts and error reports, but it is not a stable rendering API. Prefer layout, layout-str, or layout-seq for application code. Use parse-row-layout for row-layout strings, where the character inside brackets is the row drawing character rather than a column alignment marker.
The 2-arity form (row-layout? layout-string) is kept for backwards compatibility; new code should call parse-layout or parse-row-layout explicitly.
Parses a column layout string into the diagnostic layout representation. The returned data is useful for debugging custom layouts and error reports, but it is not a stable rendering API. Prefer layout, layout-str, or layout-seq for application code. Use parse-row-layout for row-layout strings, where the character inside brackets is the row drawing character rather than a column alignment marker. The 2-arity form (row-layout? layout-string) is kept for backwards compatibility; new code should call parse-layout or parse-row-layout explicitly.
(parse-row-layout layout-string)Parses a row layout string into the diagnostic layout representation.
Row-layout markers like [-] or [=] use the bracket character as the row drawing glyph rather than a cell alignment. See parse-layout for the column variant and the same caveats about API stability.
Parses a row layout string into the diagnostic layout representation. Row-layout markers like [-] or [=] use the bracket character as the row drawing glyph rather than a cell alignment. See parse-layout for the column variant and the same caveats about API stability.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |