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

Issue with inserting a Hyperlink via HTML content. #167

Open
sangpark opened this issue May 15, 2021 · 2 comments
Open

Issue with inserting a Hyperlink via HTML content. #167

sangpark opened this issue May 15, 2021 · 2 comments

Comments

@sangpark
Copy link

I've been trying to insert a dynamic hyperlink via a mailmerge field but am running into issues.

The context json looks like

{
  "html:test_link": "<a href=\"https://google.com\">Click me</a>"
}

And the template docx is pretty simple with only the following

template_docx

but when I run the sample command line executable

cat test.json | ./exe/sablon Test_Template.docx Out.docx

I get the following output.
sample_output

I'm really not sure where the trailing \h comes from or how to make this work. I've dug through the code and added some debug and I see the Nokogiri element being parsed correctly and I see the WordML struct coming back as

#<struct Sablon::Content::WordML xml=#<Nokogiri::XML::DocumentFragment:0x3fc43ad909ac name="#document-fragment" children=[#<Nokogiri::XML::Element:0x3fc43ad905c4 name="w:hyperlink" attributes=[#<Nokogiri::XML::Attr:0x3fc43ad902a4 name="r:id" value="rId18">]>]>>

I'm not sure if I'm doing something incorrectly or if this is a bug.

@stadelmanma
Copy link
Collaborator

stadelmanma commented May 15, 2021

@sangpark we test hyperlink insertion using this HTML block, https://github.com/senny/sablon/blob/master/test/fixtures/html/html_test_content.html and yours looks fine. Unfortunately I don't have easy access to MS Word to test things anymore. Can you try wrapping the link in a <div></div> tag? If you want you can attach your word doc template to the issue and I'll try it out.

@sangpark
Copy link
Author

Thanks @stadelmanma . I tried wrapping my anchor link in a <div></div> and also <p></p> but I get similar results. I've attached the template file below.

Out.docx

For other information, I'm running using version 0.3.1 of the Sablon gem, on Ruby 2.6.5 and Word version 16.49 on a Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants