fmt.fmt
fmt.fmt(quantity, unit=None, precision=1, commas=True, prefix='', suffix='')Format a Pint Quantity (or plain number) for narrative text. Returns a MarkdownStr so Quarto inserts the value verbatim (no escape).
The prefix and suffix arguments collapse the old MarkdownStr(f”…“) escape-hatch idiom into a single canonical helper. Common uses:
fmt(price, precision=0, prefix="$") # "$1,000"
fmt(rate * 100, precision=1, commas=False, suffix="%") # "12.4%"
fmt(bw_mb_s, precision=1, commas=False, suffix=" MB/s") # "2.4 MB/s"
fmt(speedup, precision=0, commas=False, suffix="x") # "8x"
Safety: Raises ValueError if formatting would hide meaningful magnitude: non-zero values displayed as 0, non-integers displayed with precision=0, or integer-like values shown with spurious decimals (512.0). Use fmt_int(...) when integer display is intentional.