From 022c52eef6a8d662db569bf2798ea4c2fce88de4 Mon Sep 17 00:00:00 2001 From: mathias234 Date: Thu, 8 Oct 2026 14:50:22 +0200 Subject: [PATCH] fix: Preserve bullet lists in desktop Word --- lib/notare/xml/numbering.rb | 15 ++++++++++----- test/list_test.rb | 4 ++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/notare/xml/numbering.rb b/lib/notare/xml/numbering.rb index c9ad5f4..92c949a 100644 --- a/lib/notare/xml/numbering.rb +++ b/lib/notare/xml/numbering.rb @@ -16,11 +16,8 @@ module Notare xml.numbering("xmlns:w" => NAMESPACE) do xml.parent.namespace = xml.parent.namespace_definitions.find { |ns| ns.prefix == "w" } - @lists.each do |list| - render_abstract_num(xml, list) - - render_num(xml, list) - end + render_abstract_nums(xml) + render_nums(xml) end end builder.to_xml @@ -28,6 +25,14 @@ module Notare private + def render_abstract_nums(xml) + @lists.each { |list| render_abstract_num(xml, list) } + end + + def render_nums(xml) + @lists.each { |list| render_num(xml, list) } + end + def render_abstract_num(xml, list) xml["w"].abstractNum("w:abstractNumId" => list.num_id.to_s) do 9.times do |level| diff --git a/test/list_test.rb b/test/list_test.rb index b6facd4..e804898 100644 --- a/test/list_test.rb +++ b/test/list_test.rb @@ -115,6 +115,10 @@ class ListTest < Minitest::Test assert_includes doc_xml, "List 1 Item 1" assert_includes doc_xml, "List 2 Item 1" assert_includes doc_xml, "Separator paragraph" + + numbering_xml = Nokogiri::XML(xml_files["word/numbering.xml"]) + child_names = numbering_xml.root.element_children.map(&:name) + assert_equal %w[abstractNum abstractNum num num], child_names end def test_mixed_list_types -- 2.40.1