From 67bc9c09a42525a7942ead709c0e463ee1275ee7 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 12 Oct 2023 11:40:53 +0300 Subject: [PATCH] handle equal signs in link element's text (PR #72) --- lib/docbookrx/docbook_visitor.rb | 1 + spec/lib/docbookrx/docbookrx_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/docbookrx/docbook_visitor.rb b/lib/docbookrx/docbook_visitor.rb index f056644..b6b55f3 100644 --- a/lib/docbookrx/docbook_visitor.rb +++ b/lib/docbookrx/docbook_visitor.rb @@ -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 diff --git a/spec/lib/docbookrx/docbookrx_spec.rb b/spec/lib/docbookrx/docbookrx_spec.rb index b8545fd..f5c4b90 100644 --- a/spec/lib/docbookrx/docbookrx_spec.rb +++ b/spec/lib/docbookrx/docbookrx_spec.rb @@ -76,6 +76,18 @@ expect(output).to include(expected) end + it 'should handle equal signs in link element' do + input = <<-EOS +Read about ORM = Object RM on Wikipedia. + 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