JuliaData / YAML.jl

Parse yer YAMLs
Other
128 stars 45 forks source link

Cannot treat backquote ` well #142

Open Paalon opened 2 months ago

Paalon commented 2 months ago

The following gives an error:

using YAML

text = """
a:
  "`b`": c
"""

dict1 = YAML.load(text)

# write YAML
io = IOBuffer()
YAML.write(io, dict1)

# read written YAML
seekstart(io)
dict2 = YAML.load(io)
ERROR: '`'
Stacktrace:
  [1] fetch_more_tokens(stream::YAML.TokenStream)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/scanner.jl:281
  [2] peek(stream::YAML.TokenStream)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/scanner.jl:198
  [3] parse_block_mapping_value(stream::YAML.EventStream)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/parser.jl:461
  [4] peek(stream::YAML.EventStream)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/parser.jl:54
  [5] compose_node(composer::YAML.Composer)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:93
  [6] __compose_mapping_node(event::YAML.ScalarEvent, composer::YAML.Composer, node::YAML.MappingNode)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:154
  [7] _compose_mapping_node(start_event::YAML.MappingStartEvent, composer::YAML.Composer, anchor::Nothing)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:174
  [8] compose_mapping_node(composer::YAML.Composer, anchor::Nothing)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:183
  [9] handle_event(event::YAML.MappingStartEvent, composer::YAML.Composer)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:86
 [10] compose_node(composer::YAML.Composer)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:94
 [11] compose_document(composer::YAML.Composer)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:50
 [12] compose(events::YAML.EventStream)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/composer.jl:38
 [13] load(ts::YAML.TokenStream, constructor::YAML.Constructor)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/YAML.jl:38
 [14] load(ts::YAML.TokenStream, more_constructors::Nothing, multi_constructors::Dict{…}; dicttype::Type{…}, constructorType::typeof(YAML.SafeConstructor))
    @ YAML ~/.julia/packages/YAML/U6OOW/src/YAML.jl:44
 [15] load
    @ ~/.julia/packages/YAML/U6OOW/src/YAML.jl:44 [inlined]
 [16] load (repeats 2 times)
    @ ~/.julia/packages/YAML/U6OOW/src/YAML.jl:47 [inlined]
 [17] load(input::IOBuffer)
    @ YAML ~/.julia/packages/YAML/U6OOW/src/YAML.jl:47
 [18] top-level scope
    @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.
kescobo commented 2 months ago

Heh - apparently github has issues with it too. Can you just confirm it's a bug using another YAML parse (plenty of web-based ones)?

Paalon commented 2 months ago

Parsing is well but there is a bug in writing. From https://www.bairesdev.com/tools/json2yaml/ スクリーンショット 2024-06-04 11 38 22