From d6427ae7b21259f5fb3099832f7d8a445785d0af Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 29 May 2024 18:41:25 -0700 Subject: [PATCH] Improve syntax markdown --- doc/syntax.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/syntax.md b/doc/syntax.md index 79fb3e36..014b41aa 100644 --- a/doc/syntax.md +++ b/doc/syntax.md @@ -27,7 +27,8 @@ output instead of the replacement field. The *arg_id* is optionally followed by a *format_spec*, which is preceded by a colon `':'`. These specify a non-default format for the replacement value. -See also the [Format Specification Mini-Language](#formatspec) section. +See also the [Format Specification Mini-Language](#format-specification-mini- +language) section. If the numerical arg_ids in a format string are 0, 1, 2, \... in sequence, they can all be omitted (not just some) and the numbers 0, 1, @@ -56,7 +57,7 @@ the formatting of a value to be dynamically specified. See the [Format Examples](#formatexamples) section for some examples. -## Format Specification Mini-Language {#formatspec} +## Format Specification Mini-Language "Format specifications" are used within replacement fields contained within a format string to define how individual values are presented. Each formattable @@ -69,16 +70,16 @@ supported by the numeric types. The general form of a *standard format specifier* is: - -format_spec ::= [[fill]align]\[sign]["#"]\["0"][width]["." precision]["L"]\[type] +
+format_spec ::= [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type]
 fill        ::= 
 align       ::= "<" | ">" | "^"
 sign        ::= "+" | "-" | " "
-width       ::= [integer](#replacement-field) | "{" [[arg_id](#replacement-field)] "}"
-precision   ::= [integer](#replacement-field) | "{" [[arg_id](#replacement-field)] "}"
+width       ::= integer | "{" [arg_id] "}"
+precision   ::= integer | "{" [arg_id] "}"
 type        ::= "a" | "A" | "b" | "B" | "c" | "d" | "e" | "E" | "f" | "F" |
                 "g" | "G" | "o" | "p" | "s" | "x" | "X" | "?"
-
+
The *fill* character can be any Unicode code point other than `'{'` or `'}'`. The presence of a fill character is signaled by the character @@ -262,8 +263,8 @@ Format specifications for chrono duration and time point types as well as `std::tm` have the following syntax: - -chrono_format_spec ::= \[\[[fill](#replacement-field)][align](#replacement-field)][[width](#replacement-field)]["." [precision](#replacement-field)][chrono_specs] +
+chrono_format_spec ::= [[fill]align][width]["." precision][chrono_specs]
 chrono_specs       ::= [chrono_specs] conversion_spec | chrono_specs literal_char
 conversion_spec    ::= "%" [modifier] chrono_type
 literal_char       ::= 
@@ -272,7 +273,7 @@ chrono_type        ::= "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "F"
                        "g" | "G" | "h" | "H" | "I" | "j" | "m" | "M" | "n" | "p" |
                        "q" | "Q" | "r" | "R" | "S" | "t" | "T" | "u" | "U" | "V" |
                        "w" | "W" | "x" | "X" | "y" | "Y" | "z" | "Z" | "%"
-
+
Literal chars are copied unchanged to the output. Precision is valid only for `std::chrono::duration` types with a floating-point @@ -329,9 +330,9 @@ month) are valid only for `std::tm` and time points but not durations. Format specifications for range types have the following syntax: - -range_format_spec ::= ["n"]\[range_type][range_underlying_spec] - +
+range_format_spec ::= ["n"][range_type][range_underlying_spec]
+
The `'n'` option formats the range without the opening and closing brackets.