Skip to content

Commit

Permalink
fixed links to images (PR #59)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbolton authored Oct 12, 2023
1 parent b9314be commit 06f4336
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/docbookrx/docbook_visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
34 changes: 33 additions & 1 deletion spec/lib/docbookrx/docbookrx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<article xmlns='http://docbook.org/ns/docbook'
xmlns:xl="http://www.w3.org/1999/xlink"
version="5.0" xml:lang="en">
<para>See <xref linkend="sample-figure"/>
<figure xml:id="sample-figure">
<title>Local History</title>
<mediaobject>
<imageobject>
<imagedata fileref="images/dummy.png"/>
</imageobject>
</mediaobject>
</figure>
</article>
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
Expand Down

0 comments on commit 06f4336

Please sign in to comment.