Giter Site home page Giter Site logo

Comments (7)

dumbbell avatar dumbbell commented on July 28, 2024

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.

dumbbell avatar dumbbell commented on July 28, 2024

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.

obahareth avatar obahareth commented on July 28, 2024

Yeah that seems perfect, thanks @dumbbell!

from yamerl.

dumbbell avatar dumbbell commented on July 28, 2024

Cool! Thanks :)

from yamerl.

lud avatar lud commented on July 28, 2024

Hi,

How do you provide tag handlers to the parser ?

Thank you

from yamerl.

dumbbell avatar dumbbell commented on July 28, 2024

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.

lud avatar lud commented on July 28, 2024

Perfect, thank you!

from yamerl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.