-
-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Labels
Description
Describe the bug
undefined method `value' for nil:NilClass
error thrown when calling to_html on a file with internal hyperlinks (hyperlinks to a bookmark or a heading within the file).
Backtrace:
docx (0.8.0) lib/docx/containers/text_run.rb:106:in `hyperlink_id'
docx (0.8.0) lib/docx/containers/text_run.rb:102:in `href'
docx (0.8.0) lib/docx/containers/text_run.rb:81:in `to_html'
docx (0.8.0) lib/docx/containers/paragraph.rb:48:in `block in to_html'
docx (0.8.0) lib/docx/containers/paragraph.rb:47:in `each'
docx (0.8.0) lib/docx/containers/paragraph.rb:47:in `to_html'
docx (0.8.0) lib/docx/document.rb:119:in `map'
docx (0.8.0) lib/docx/document.rb:119:in `to_html'
According to here the anchor
attribute is used instead of the id
attribute for internal hyperlinks, breaking line 106 in text_run.rb.
To Reproduce
Open a docx file with a hyperlink to either a heading or a bookmark in the same file and call to_html.
example
require 'docx'
doc = Docx::Document.new('/path/to/your/docx/file_with_internal_hyperlink.docx')
doc.to_html
Sample docx file
Expected behavior
No exception thrown; html gets returned as normal.
Environment
- Ruby version: 3.2.2
docx
gem version: 0.8.0- OS: Alpine 3.17 docker container