REXML::Formatters::Transitive not found.
Nobody has claimed this yet.
- #230 by @Beagle123 — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start by reading Transitive.rb and Pretty.rb to compare the available formatter behavior and how text nodes are handled. Check how REXML exposes formatters, then determine the expected behavior for preserving long text nodes and confirm it with focused coverage before considering the issue done.
Written by the indexing model from the issue text.
Description
Hi:
I tried to use REXML::Formatters::Transitive in my code, but it wasn't found in the package.
Here is the output of irb:
eric@trig:~$ irb
irb(main):001:0> require "rexml"
=> true
irb(main):002:0> REXML::Formatters::Transitive
(irb):2:in `<main>': uninitialized constant REXML::Formatters::Transitive (NameError)
from /home/eric/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from /home/eric/.rbenv/versions/3.1.6/bin/irb:25:in `load'
from /home/eric/.rbenv/versions/3.1.6/bin/irb:25:in `<main>'
irb(main):003:0>
^C
irb(main):003:0>
I tried using the code from github, Transitive.rb, but the output was bad. All the tags were broken onto two lines.
However, I had great success with subclassing Pretty.rb, and outputting the text nodes without formatting which is the result that I wanted. I would suggest making this Formatter:
class PrettyPreserveText < REXML::Formatters::Pretty
def write_text( node, output )
output << node.to_s()
end
end
This is a great result. It has all the benefits of Pretty.rb while preserving long text nodes. It seems like a good idea to preserve text nodes "as-is." In fact, I would suggest changing the Pretty formater to output the unaltered text. When I used Pretty, it worked great except that it would indent every line of a long text string to make it look good. This obviously is rarely a good idea. The users need to be able to control the content of text strings. That's not the job of a formatter.
Thanks for all your work.
Eric
- Dominant language
- Ruby
- Stars
- 181
- Forks
- 105
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/rexml
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
XPath underscored function name is wrongly acceptedPossibly taken @sjh9714 claimed this 80 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Similar issues
-
bug f:request-creation professional
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mysociety/alaveteli#9733 · 1 comment ·
Maintainers usually reply within 1 day
-
needs verification
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 13 days
-
🐛 bug 👩💻 équipe CE 🧑🏭 entreprises
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
betagouv/conseillers-entreprises#4808 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day