vxml/io_lines

Line-based input and output helpers.

InputLine and OutputLine store leading indentation separately from the remaining line suffix and attach Blame to both. They provide the bridge between files or strings and VXML parsers or serializers.

String conversion normalizes CRLF and CR endings to LF, converts leading ASCII spaces into an indentation count, preserves all other whitespace, and represents a terminal newline as a final empty line.

Types

A source line with its leading whitespace count, remaining suffix, and blame.

pub type InputLine {
  InputLine(blame: blame.Blame, indent: Int, suffix: String)
}

Constructors

  • InputLine(blame: blame.Blame, indent: Int, suffix: String)

An output line with its leading-space count, remaining suffix, and blame.

pub type OutputLine {
  OutputLine(blame: blame.Blame, indent: Int, suffix: String)
}

Constructors

  • OutputLine(blame: blame.Blame, indent: Int, suffix: String)

Values

pub fn input_line_to_string(line: InputLine) -> String

Restores one input line’s indentation and suffix.

pub fn input_lines_table(
  content: List(InputLine),
  banner: String,
  indent: Int,
) -> String

Renders input lines as a blame-annotated table using default margins.

pub fn input_lines_to_output_lines(
  lines: List(InputLine),
) -> List(OutputLine)

Converts input lines to equivalent output lines, preserving blame.

pub fn input_lines_to_string(lines: List(InputLine)) -> String

Converts input lines to one newline-separated string.

pub fn normalize_line_endings(source: String) -> String

Normalizes CRLF and CR line endings to LF.

pub fn output_line_to_string(line: OutputLine) -> String

Restores one output line’s indentation and suffix.

pub fn output_lines_table(
  content: List(OutputLine),
  banner: String,
  indent: Int,
) -> String

Renders output lines as a table string using default margin constraints.

pub fn output_lines_table_lines(
  content: List(OutputLine),
  banner: String,
  indent: Int,
) -> List(String)

Renders output lines as table lines using default margin constraints.

pub fn output_lines_table_lines_with(
  content: List(OutputLine),
  banner: String,
  indent: Int,
  blame_digest_margin: blame.BlameTableMarginColumnsMinMax,
  comments_margin: blame.BlameTableMarginColumnsMinMax,
) -> List(String)

Renders output lines as table lines using explicit margin constraints.

pub fn output_lines_table_with(
  content: List(OutputLine),
  banner: String,
  indent: Int,
  blame_digest_margin: blame.BlameTableMarginColumnsMinMax,
  comments_margin: blame.BlameTableMarginColumnsMinMax,
) -> String

Renders output lines as a table string using explicit margin constraints.

pub fn output_lines_to_string(lines: List(OutputLine)) -> String

Converts output lines to a newline-separated string.

pub fn path_to_input_lines(
  path: String,
  added_indentation: Int,
) -> Result(List(InputLine), simplifile.FileError)

Reads a file path into input lines.

pub fn read(
  path: String,
  added_indentation: Int,
) -> Result(List(InputLine), simplifile.FileError)

Alias for path_to_input_lines.

pub fn string_to_input_lines(
  source: String,
  path: String,
  added_indentation: Int,
) -> List(InputLine)

Converts a string to input lines, preserving its path and trailing content.

Leading ASCII spaces are removed from each suffix and counted in indent. Tabs and other whitespace remain in the suffix. added_indentation is added to the space count. A terminal newline produces a final empty InputLine.

Search Document