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

hyperlink and XML entities issue #90

Closed
ZouhaierSebri opened this issue May 19, 2017 · 6 comments
Closed

hyperlink and XML entities issue #90

ZouhaierSebri opened this issue May 19, 2017 · 6 comments
Assignees
Milestone

Comments

@ZouhaierSebri
Copy link

ZouhaierSebri commented May 19, 2017

Hi @gitbrent
i'm testing hyperlink both in image and text

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();
    slide .addText([
          {text: 'test A & B', options: {hyperlink: {url: 'https://github.com/gitbrent/pptxgenjs?a=1&b=2', tooltip: ' A&B'}}}
          ], {x: 0.62, y: 1, w: 5.3, h: 0.34, font_size: 14, color: '667184', bullet: {code: '27A2'}}
     );
pptx.save('testhyperlink');

image

The problem is in & because when i change & by & the exemple works fine.

as a solution i propose to use decodeXmlEntities()
line 2389 : change
Target="'+ rel.Target+'"
BY
Target="'+ decodeXmlEntities(rel.Target) +'"
line 1579 : change
tooltip="'+ (opts.hyperlink.tooltip ? opts.hyperlink.tooltip : '') +'"
BY
tooltip="'+ (opts.hyperlink.tooltip ? decodeXmlEntities(opts.hyperlink.tooltip) : '') +'"

@ZouhaierSebri ZouhaierSebri changed the title hyperlink and & issue hyperlink and XML entities issue May 19, 2017
@gitbrent gitbrent self-assigned this May 20, 2017
@gitbrent gitbrent added this to the v1.5.0 milestone May 20, 2017
gitbrent pushed a commit that referenced this issue May 22, 2017
@gitbrent
Copy link
Owner

Thanks @ZouhaierSebri !

I added decoding to both the text and the image hyperlink tooltips.

@ZouhaierSebri
Copy link
Author

ZouhaierSebri commented May 22, 2017

Hi @gitbrent
issue not fixed.
we need encoding for url

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();
    slide .addText([
          {text: 'test A & B', options: {hyperlink: {url: 'https://github.com/gitbrent/pptxgenjs?a=1&b=2', tooltip: ' A&B'}}}
          ], {x: 0.62, y: 1, w: 5.3, h: 0.34, font_size: 14, color: '667184', bullet: {code: '27A2'}}
     );
pptx.save('testhyperlink');

not work due to "a=1&b=2" in url
You are missing :: Target="'+ decodeXmlEntities(rel.Target) +'"

@lejard-h
Copy link

lejard-h commented Nov 8, 2018

still having the issue on hyperlink, version 2.4.0 and Powerpoint 2016

var pptx = new PptxGenJS();
	var slide = pptx.addNewSlide();
	var opts = { x:1.0, y:1.0, fontSize:42, color:'00FF00',
        hyperlink: { url: 'https://google.fr', tooltip: 'Google' }
  }
slide.addText('Hello World!', opts);
pptx.save();

@gitbrent
Copy link
Owner

gitbrent commented Nov 9, 2018

Hi @lejard-h

This code will indeed cause warnings on PPT startup.

You'll want to follow the example in the docs and use a complex text type instead (not a simple string with a global option)

Example

slide.addText(
    [{
        text: 'Hello world!',
        options: { hyperlink:{ url:'https://google.fr', tooltip:'Google' } }
    }],
    { x:1.0, y:1.0, fontSize:42, color:'00FF00' }
);

screen shot 2018-11-08 at 22 07 35

@Tehnix
Copy link

Tehnix commented Jun 13, 2019

Having the exact same issue as @ZouhaierSebri, in the newest version of the library (2.5.0). Can't place any & in the URLs.

@gitbrent
Copy link
Owner

@Tehnix - Please open a new issue for problems using "&" in a URL.

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

No branches or pull requests

4 participants