diff --git a/components/yaml/yaml_format.rst b/components/yaml/yaml_format.rst index 9419526c0cc..c45a45117a2 100644 --- a/components/yaml/yaml_format.rst +++ b/components/yaml/yaml_format.rst @@ -30,12 +30,8 @@ they can also be unquoted: A string in YAML -.. code-block:: yaml - 'A singled-quoted string in YAML' -.. code-block:: yaml - "A double-quoted string in YAML" Quoted styles are useful when a string starts or ends with one or more @@ -45,9 +41,32 @@ their contents. When using single-quoted strings, any single quote ``'`` inside its contents must be doubled to escape it: - .. code-block:: yaml +.. code-block:: yaml - 'A single quote '' inside a single-quoted string' + 'A single quote '' inside a single-quoted string' + +If the string contains any of the following characters, it must be escaped with +single quotes: + +* ``:`` +* ``{`` +* ``}`` +* ``[`` +* ``]`` +* ``,`` +* ``&`` +* ``*`` +* ``#`` +* ``?`` +* ``|`` +* ``-`` +* ``<`` +* ``>`` +* ``=`` +* ``!`` +* ``%`` +* ``@`` +* ``\``` The double-quoted style provides a way to express arbitrary strings, by using ``\`` escape sequences. It is very useful when you need to embed a @@ -57,27 +76,46 @@ using ``\`` escape sequences. It is very useful when you need to embed a "A double-quoted string in YAML\n" -If the string contains any of the following characters, it must be escaped with -single quotes: - -===== ===== ===== ===== ===== -``:`` ``{`` ``}`` ``[`` ``]`` -``,`` ``&`` ``*`` ``#`` ``?`` -``|`` ``-`` ``<`` ``>`` ``=`` -``!`` ``%`` ``@`` ``\``` -===== ===== ===== ===== ===== - If the string contains any of the following control characters, it must be escaped with double quotes. In addition, the escaping must use a double slash ``\\`` to avoid parsing issues: -======== ======== ======== ======== ======== ======== ======== ======== -``\0`` ``\x01`` ``\x02`` ``\x03`` ``\x04`` ``\x05`` ``\x06`` ``\a`` -``\b`` ``\t`` ``\n`` ``\v`` ``\f`` ``\r`` ``\x0e`` ``\x0f`` -``\x10`` ``\x11`` ``\x12`` ``\x13`` ``\x14`` ``\x15`` ``\x16`` ``\x17`` -``\x18`` ``\x19`` ``\x1a`` ``\e`` ``\x1c`` ``\x1d`` ``\x1e`` ``\x1f`` -``\N`` ``\_`` ``\L`` ``\P`` -======== ======== ======== ======== ======== ======== ======== ======== +* ``\0`` +* ``\x01`` +* ``\x02`` +* ``\x03`` +* ``\x04`` +* ``\x05`` +* ``\x06`` +* ``\a`` +* ``\b`` +* ``\t`` +* ``\n`` +* ``\v`` +* ``\f`` +* ``\r`` +* ``\x0e`` +* ``\x0f`` +* ``\x10`` +* ``\x11`` +* ``\x12`` +* ``\x13`` +* ``\x14`` +* ``\x15`` +* ``\x16`` +* ``\x17`` +* ``\x18`` +* ``\x19`` +* ``\x1a`` +* ``\e`` +* ``\x1c`` +* ``\x1d`` +* ``\x1e`` +* ``\x1f`` +* ``\N`` +* ``\_`` +* ``\L`` +* ``\P`` When a string contains line breaks, you can use the literal style, indicated by the pipe (``|``), to indicate that the string will span several lines. In