An ampersand at the start of a YAML entry is normally seen as a label for a set of data that can be referenced later. How do you escape a legitimate ampersand at the start of a YAML entry. For example:
---
- news:
news_text: “Text!’
I am looking to not have &ldquo be a label within the yaml file, but rather when I get parse the YAML file to have the news_text come back with the “ in the entry.
Verb. escape, avoid, evade, elude, shun, eschew mean to get away or keep away from something. escape stresses the fact of getting away or being passed by not necessarily through effort or by conscious intent.
[count] : an act of escaping from a place, situation, etc. The prisoners attempted a daring escape. He celebrated his escape from his boring job with a long vacation. She had a lucky escape when she wasn't injured in the accident.
escape from somebody/something He escaped from prison this morning. She attempted to escape from the pirates holding her hostage. escape somebody/something She managed to escape her captors. He escaped prison with two other inmates.
[transitive, no passive] to avoid something unpleasant or dangerous escape something She was lucky to escape punishment. The pilot escaped death by seconds. There was no escaping the fact that he was overweight. escape doing something He narrowly escaped being killed.
Just put quotes around the text
require 'yaml'
data = <<END
---
- news:
news_text: "“Text!’"
END
puts YAML::load(data).inspect
# produces => [{"news"=>{"news_text"=>"“Text!’"}}]
You probably can enclose the text in quotes:
---
- news:
news_text: "“Text!’"
Besides, you can probably just as well use the proper characters there:
---
- news:
news_text: “Text!’
Putting escapes specific to a totally different markup language into a document written in another markup language seems ... odd to me, somehow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With