ruby / ruby/rexml

Problem with context raw?

Open
#43 1 comment 0 reactions 1 assignee View on GitHub

@kou is already working on this.

Since Feb 2, 2021.

question
Dominant language
Ruby
Stars
182
Forks
99
Avg merge
2d 23h
Merged PRs (30d)
8

Description

Running ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [i386-mingw32]

  xml_string = '<root><foo>&amp;</foo><bar>&lt;</bar><baz>&gt;</baz><bat>&quot;</bat></root>'
  d = Document.new(xml_string, {raw: ['foo', 'baz']})
  d.to_s # => "<root><foo>&amp;</foo><bar>&lt;</bar><baz>&gt;</baz><bat>&quot;</bat></root>"
  root = d.root # => <root> ... </>
  foo, bar, baz, bat = *d.root
  # Each is an Element object:
  [foo, bar, baz, bat].map {|e| e.class }.uniq # => [REXML::Element]
  # Each element is marked as raw/not-raw as appropriate:
  [foo, bar, baz, bat].map {|e| e.raw } # => [true, false, true, false]
  # The first child of each is a Text object:
  [foo, bar, baz, bat].map {|e| e.first.class }.uniq # => [REXML::Text]
  # Each text is marked as raw/not-raw as appropriate:
  [foo, bar, baz, bat].map {|e| e.first.raw } # => [true, true, true, true]

Is this correct? I expected that last result to be [true, false, true, false].

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.