moxml 0.5.30 → 0.5.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,23 @@ RSpec.describe Moxml::Adapter::Nokogiri do
12
12
 
13
13
  it_behaves_like "xml adapter"
14
14
 
15
+ describe "HTML parsing" do
16
+ let(:ctx) { Moxml.new(:nokogiri) }
17
+
18
+ it "synthesizes the html/body structure with lowercased names" do
19
+ doc = ctx.parse_html(%(<DIV CLASS="x">t</DIV>))
20
+ expect(doc.root.name).to eq("html")
21
+ body = doc.root.children.find(&:element?)
22
+ expect(body.name).to eq("body")
23
+ expect(body.at_xpath(".//div")["class"]).to eq("x")
24
+ end
25
+
26
+ it "implies end tags and decodes HTML entities" do
27
+ doc = ctx.parse_html(%(<ul><li>caf&eacute;</ul>))
28
+ expect(doc.xpath("//li").map(&:text)).to eq(["caf\u00e9"])
29
+ end
30
+ end
31
+
15
32
  describe "recover-mode error channel" do
16
33
  it "exposes recoverable syntax errors as parse_errors" do
17
34
  doc = Moxml.new(:nokogiri).parse("<root><unclosed>", strict: false)
@@ -13,6 +13,19 @@ RSpec.describe Moxml::Context do
13
13
  end
14
14
  end
15
15
 
16
+ describe "#parse_html" do
17
+ it "delegates to the adapter's HTML mode" do
18
+ ctx = Moxml.new(:nokogiri)
19
+ doc = ctx.parse_html(%(<p>x</p>))
20
+ expect(doc.root.name).to eq("html")
21
+ end
22
+
23
+ it "raises Moxml::AdapterError on adapters without an HTML mode" do
24
+ ctx = Moxml.new(:ox)
25
+ expect { ctx.parse_html(%(<p>x</p>)) }.to raise_error(Moxml::AdapterError, /not supported/)
26
+ end
27
+ end
28
+
16
29
  describe "#config" do
17
30
  it "has a configuration" do
18
31
  expect(context.config).to be_a(Moxml::Config)
@@ -140,4 +140,29 @@ RSpec.describe Moxml::Element do
140
140
  end
141
141
  end
142
142
  end
143
+
144
+ describe "#append_xml" do
145
+ it "appends a fragment's top-level nodes with entities round-tripped" do
146
+ %w[leptris nokogiri oga rexml].each do |adapter|
147
+ ctx = Moxml.new(adapter.to_sym)
148
+ doc = ctx.parse(%(<root/>))
149
+ result = doc.root.append_xml(%(<a x="1">t1 &amp; u</a><b/>tail))
150
+ expect(result).to equal(doc.root)
151
+ out = doc.to_xml
152
+ expect(out).to include(%(<a x="1">t1 &amp; u</a>))
153
+ expect(out).to include("<b></b>")
154
+ expect(out).to include("tail")
155
+ end
156
+ end
157
+
158
+ it "raises AdapterError on the ox adapter" do
159
+ doc = Moxml.new(:ox).parse(%(<root/>))
160
+ expect { doc.root.append_xml(%(<a/>)) }.to raise_error(Moxml::AdapterError, /Ox/)
161
+ end
162
+
163
+ it "raises ParseError for non-well-formed fragments" do
164
+ doc = Moxml.new(:leptris).parse(%(<root/>))
165
+ expect { doc.root.append_xml(%(<a><b></a>)) }.to raise_error(Moxml::ParseError)
166
+ end
167
+ end
143
168
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.30
4
+ version: 0.5.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-04 00:00:00.000000000 Z
11
+ date: 2026-09-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Moxml is a unified XML manipulation library that provides a common API
@@ -205,6 +205,7 @@ files:
205
205
  - lib/moxml/entity_registry.rb
206
206
  - lib/moxml/entity_registry_opal_data.rb
207
207
  - lib/moxml/error.rb
208
+ - lib/moxml/lazy_node_set.rb
208
209
  - lib/moxml/materializer.rb
209
210
  - lib/moxml/namespace.rb
210
211
  - lib/moxml/native_attachment.rb