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

Modify Token plugin\Data-URI #9

Open
LukeTOBrien opened this issue Apr 22, 2018 · 0 comments
Open

Modify Token plugin\Data-URI #9

LukeTOBrien opened this issue Apr 22, 2018 · 0 comments

Comments

@LukeTOBrien
Copy link

Hello there,

I am working with the Modify Token plugin and I have a function that reads the image a embeds it as a data-uri using this plugin.
Here is the code:

var modifyTokenFunction = function (token, env) {

  switch (token.type) {
    case 'image':
      console.log(path.dirname(env.path) + '/' + token.attrObj.src)
      let ext = path.extname(env.path);
      console.log('Encoding file: ' + path.dirname(env.path) + '/' + token.attrObj.src + '...')
      token.attrObj.src = datauri.format(ext, fs.readFileSync(path.dirname(env.path) + '/' + token.attrObj.src)).content
      break;
    case 'link_open':
      token.attrObj.target = '_blank'; // set all links to open in new window 
      break;
  }
};

This does serialize the video as data-uri correctly, but render as <img> and your plugin is never called.

The trouble is that you are using the image syntax, so the case in my function is being hit, ideally I think you should use a different syntax, @[]() is used in the video plugin.

I believe I might be able to use customRenderFn to serialise as data-url, but I also need to stop the modify plugin being called.

Can you see what I am doing here? Any ideas?

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

1 participant