REXML::Formatters::Transitive not found.
還沒有人認領這個 Issue。
- #230 來自 @Beagle123 —— 已關閉,未合併
評估
研究方向
先閱讀 Transitive.rb 和 Pretty.rb,比較可用 formatter 的行為以及文字節點的處理方式。檢查 REXML 如何提供 formatter,接著判斷保留長文字節點時的預期行為,並透過針對性的涵蓋範圍加以確認,再考慮將該 issue 視為完成。
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- Ruby
- 星號
- 181
- 分支
- 105
- 平均合併
- 8 天 16 小時
- 30 天內合併 PR
- 2
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ruby/rexml 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
-
XPath underscored function name is wrongly accepted可能已有人在做 @sjh9714 於 57 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
-
難度 3/5 1-2 天 新手友好度 55/100
-
難度 4/5 3-5 天 新手友好度 48/100
-
難度 5/5 一週以上 新手友好度 35/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
rubyevents/rubyevents#2277 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 92/100
維護者通常 2 天內回覆