Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress errors raised when calling to_html to docx with internal links #143

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/docx/containers/text_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def underlined?
end

def hyperlink?
@node.name == 'hyperlink'
@node.name == 'hyperlink' && external_link?
end

def external_link?
!@node.attributes['id'].nil?
end

def href
Expand Down
9 changes: 9 additions & 0 deletions spec/docx/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,13 @@
end
end

describe '#to_html' do
before do
@doc = Docx::Document.open(@fixtures_path + '/internal-links.docx')
end

it 'should not raise error' do
expect { @doc.to_html }.to_not raise_error
end
end
end
Binary file added spec/fixtures/internal-links.docx
Binary file not shown.
Loading