learner

Module format

Source
Expand description

Text formatting utilities for standardizing document titles and filenames.

This module provides functionality for cleaning and standardizing text strings, particularly focused on converting document titles into filesystem-friendly filenames. It handles common transformations like converting to lowercase, replacing spaces with underscores, and enforcing length limits while preserving word boundaries.

§Examples

use learner::format;

let title = "This Is A Very Long Document Title";

// Default formatting (50 char limit)
let formatted = format::format_title(title, None);
assert_eq!(formatted, "this_is_a_very_long_document_title");

// Custom length limit
let formatted = format::format_title(title, Some(20));
assert_eq!(formatted, "this_is_a_very_long");

Functions§

  • Formats a title string for use as a filename or identifier.