features.md: Work around behavior differences between Wiki and plain files

This commit is contained in:
Jean-Sébastien Pédron 2012-12-12 16:33:33 +01:00
parent a7b7048d91
commit 257c62855a

View File

@ -18,19 +18,26 @@
## Features + examples
* Support [YAML 1.2](http://www.yaml.org/spec/1.2/spec.html) parsing:
```erlang
```erlang
yamerl_constr:string("YAML snippet").
```
* Support [YAML 1.1](http://yaml.org/spec/1.1/) parsing:
```erlang
```erlang
yamerl_constr:string("YAML snippet", [{schema, yaml11}]).
```
* Support [JSON](http://json.org/) parsing:
```erlang
```erlang
yamerl_constr:string(<<"JSON snippet">>, [{schema, json}]).
```
* Support **Erlang atom** node type, either when tagged as atom, or if autodetected in plain scalars, and, if asked, only if the atom already exists:
```erlang
```erlang
% Enable support for Erlang atoms.
yamerl_app:set_param(node_mods, [yamerl_node_erlang_atom]),
yamerl_constr:string("!<tag:yamerl,2012:atom> atom").
@ -46,16 +53,20 @@ yamerl_constr:string("atom", [
{erlang_atom_only_if_exist, true}
]).
```
* Support **Erlang fun()** node type:
```erlang
```erlang
% Enable support for Erlang fun().
yamerl_app:set_param(node_mods, [yamerl_node_erlang_fun]),
[Plus_One_Fun] = yamerl_constr:string(<<"!<tag:yamerl,2012:fun> fun(X) -> X + 1 end.">>),
Plus_One_Fun(2). % Return 3.
```
* Provide a **yamler compatibility layer**:
```erlang
```erlang
% Both calls return the same value.
yaml:load_file("input.yaml", [{schema, yaml_schema_failsafe}]),
yamerl_yamler_compat:load_file("input.yaml", [{schema, yaml_schema_failsafe}])