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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extracting content from data url #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ttimasdf
Copy link

Expected behaviour:

Extract CSS stylesheet data from base64 encoded string.

<link rel="stylesheet" type="text/css" href="data:text/css;base64,LyotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t"/>

I'm not familiar with JS so I'm not sure whether I'm using the right way to invoke callback function 馃槄 feel free to change the codes.

@jonkemp
Copy link
Owner

jonkemp commented Feb 11, 2020

Hello @ttimasdf! I ask that you please read the contributing guidelines.

https://github.com/jonkemp/inline-css/blob/master/CONTRIBUTING.md#feature-requests

Specifically, this section:

Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.

I have no idea if your pull request addresses a bug or is a feature request, so please ask first before making a pull request, or at least provide more context. Thank you!

@ttimasdf
Copy link
Author

Sorry, I've been working on other projects that almost forgot this PR. I'll add some contexts. @jonkemp

I consider this PR a bug fix that it handles the case that the CSS data is embedded in the corresponding HTML tag.

The following file is an HTML page generated by VSCode Plugin Markdown Extended , from a markdown file with random content with a custom CSS theme.

Test.html.txt (Github is limiting file extension so remove .txt after downloads)

part of the file content as follows

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test.md</title>

<!-- official styles start -->
<!-- markdown.css -->
<link rel="stylesheet" type="text/css" href="data:text/css;base64,LyotLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0KICogIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLiBBbGwgcmlna
HRzIHJlc2VydmVkLgogKiAgTGljZW5zZ...

The current version will fail with some DNS related issues. Maybe it thinks data is a hostname. However, this is a valid stylesheet that could be parsed by any browser.

Error: getaddrinfo ENOTFOUND data
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'data',
  response: undefined
}

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

Successfully merging this pull request may close these issues.

None yet

2 participants