Skip to content

Commit

Permalink
handle equal signs in link element's text (PR #72)
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif authored Oct 12, 2023
1 parent f608398 commit 67bc9c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/docbookrx/docbook_visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ def visit_uri node
if (ref = @attributes.key(url))
url = %({#{ref}})
end
label = %("#{label.gsub '"', '\\"'}") if label.include? '='
append_text %(#{prefix}#{url}[#{label}])
end
false
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/docbookrx/docbookrx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
expect(output).to include(expected)
end

it 'should handle equal signs in link element' do
input = <<-EOS
<para xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">Read about <link xlink:href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM = Object RM</link> on Wikipedia.</para>
EOS

expected = 'Read about http://en.wikipedia.org/wiki/Object-relational_mapping["ORM = Object RM"] on Wikipedia.'

output = Docbookrx.convert input

expect(output).to include(expected)
end

it 'should convert uri element to uri macro' do
input = <<-EOS
<article xmlns='http://docbook.org/ns/docbook'>
Expand Down

0 comments on commit 67bc9c0

Please sign in to comment.