diff --git a/lib/docbookrx/docbook_visitor.rb b/lib/docbookrx/docbook_visitor.rb index 47162fe..f20ef58 100644 --- a/lib/docbookrx/docbook_visitor.rb +++ b/lib/docbookrx/docbook_visitor.rb @@ -1497,6 +1497,9 @@ def visit_screenshot node # FIXME share logic w/ visit_inlinemediaobject, which is the same here except no block_title and uses append_text, not append_line def visit_figure node append_blank_line + if (id = (resolve_id node, normalize: @normalize_ids)) + append_line %([[#{id}]]) + end append_block_title node if (image_node = node.at_css('imageobject imagedata')) src = image_node.attr('fileref') diff --git a/spec/lib/docbookrx/docbookrx_spec.rb b/spec/lib/docbookrx/docbookrx_spec.rb index 446f6ce..1055a27 100644 --- a/spec/lib/docbookrx/docbookrx_spec.rb +++ b/spec/lib/docbookrx/docbookrx_spec.rb @@ -1149,7 +1149,39 @@ EOS output = Docbookrx.convert input expect(output).to eq(expected) -end + end + + it 'adds an XML ID for figures' do + + input = <<-EOS +
+ See +
+ Local History + + + + + +
+ +
+ EOS + + expected = <<-EOS.rstrip +See <<_sample_figure>> + +[[_sample_figure]] +.Local History +image::images/dummy.png[] + EOS + + output = Docbookrx.convert input + + expect(output).to include(expected) + end it 'should correctly convert varlistentry elements with nested lists' do input = <<-EOS