How to escape indicator characters (colon and hyphen) in YAML

delimiter, escaping, yaml

Solution

Quotes:

"url: http://www.some-site.example/"

To clarify, I meant “quote the value” and originally thought the entire thing was the value. If `http://www.some-site.example/` is the value, just quote it like so:

url: "http://www.some-site.example/"

Problem

In a config file, I have a key to which I wish to assign a URL. The problem is that YAML interprets `:` and `-` characters as either creating mappings or lists, so it has a problem with the line ``` url: http://www.some-site.example/ ``` (both because of the colon following HTTP and the hyphen in the middle) Is there an explicit way to escape `:` and `-`? Or would it work to just put the whole thing in single quotes and call it a day?

Original source

Related problems