Comments (7)
Hi!
Sorry, I didn't notice your issue...
The !foobar
notation is a tag handle in YAML: it tells the following tree (in your example the map with color
, background
and italic
) should be interpreted in a specific way by the application, and not as a regular YAML node (i.e. a plain map in your example). Without this, the YAML constructor is unable to build the expected structure. That's why you're supposed to provide a module which is able to construct some kind of object from this map.
If you try your document with other online parsers, they will complain like yamerl:
That said, as YAML tags are quite complex, I don't pretend I totally understand how they work so I may be misinterpreting the specification. Thus I will add an option to ignore unrecognized tags and proceed as if it's a bare YAML document.
from yamerl.
I just added the option. Here is an example with a subset of your document:
yamerl:decode_file("issue-26.yaml", [{ignore_unrecognized_tags, true}]).
[[{"IDE",
[{"editor",
[{"themes",
[{"base16-zenburn",
[{"built-in",
[{"color","#dc8cc3"},
{"background","#3f3f3f"},
{"italic",false}]}]}]}]}]}]]
Is it good enough for your use case?
from yamerl.
Yeah that seems perfect, thanks @dumbbell!
from yamerl.
Cool! Thanks :)
from yamerl.
Hi,
How do you provide tag handlers to the parser ?
Thank you
from yamerl.
Hi @lud!
Tags are handled at the construction step, not the parsing step.
To implement your own node construction, I suggest you take a look at the Erlang anonymous function node construction:
https://github.com/yakaz/yamerl/blob/master/src/yamerl_node_erlang_fun.erl
You have to implement the same three exported functions:
tags/0
construct_token/3
node_pres/1
To use this module, you need to configure it in the yamerl application. Here is an example with the Erlang function construction module:
yamerl_app:set_param(node_mods, [yamerl_node_erlang_fun]).
I should probably implement a behavior to ease that process.
from yamerl.
Perfect, thank you!
from yamerl.
Related Issues (20)
- Error compiling yamerl in Windows HOT 8
- Trivial Untrusted DoS vuln HOT 7
- Some non ascii are not parsed corectly HOT 5
- Add options to return maps and strings as binaries HOT 6
- Hex strings are incorrectly parsed as exponentials HOT 3
- Document version ignored when choosing the schema
- Latest release HOT 1
- Length of term or ending position HOT 1
- Upper limit on entries HOT 1
- Tagging a flow style map behaves differently from tagging a block style map HOT 2
- Infinite loop on empty yaml document HOT 2
- fields without type information
- Duplicate key allowed in map HOT 11
- Block scalar style parse error
- Unclosed inline map fails entire document silently HOT 3
- _build/default/lib/yamerl/include/internal/yamerl_constr.hrl:30: can't find include file "yamerl_nodes.hrl" HOT 2
- Whether to support list to yaml? HOT 1
- Add an option to allow duplicate keys in mappings HOT 3
- Multiple documents and TAG directive won't parse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamerl.