Toast Engine
Loading...
Searching...
No Matches
text_format.hpp File Reference

${} inline formatting for localized text More...

#include <functional>
#include <optional>
#include <string>
#include <string_view>
#include <toast/export.hpp>
Include dependency graph for text_format.hpp:

Go to the source code of this file.

Classes

struct  ui::TextFormatContext

Functions

auto ui::formatText (std::string_view input, const TextFormatContext &ctx) -> std::string
 Expands ${} directives in localized text into RML <span> markup.
auto ui::formatText (std::string_view input) -> std::string

Detailed Description

${} inline formatting for localized text

Author
Xein
Date
18 Jul 2026

Function Documentation

◆ formatText()

TOAST_API auto ui::formatText ( std::string_view input,
const TextFormatContext & ctx ) -> std::string
nodiscard

Expands ${} directives in localized text into RML <span> markup.

Supported directives:

  • ${clear} / $c close all open styling spans
  • ${italic} / $i italic span
  • ${bold} / $b bold span
  • ${color:name} colored span (scheme name, else literal color)
  • ${bold,color:red} combine styles in one span (comma-separated)
  • ${data:var} data binding, becomes {{var}}
  • $$ a literal $