-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-remark-copy-linked-files] Fix #2696 #2871
Conversation
Deploy preview ready! Built with commit 420c617 |
Deploy preview ready! Built with commit 420c617 |
The PR currently modifies examples/using-remark to serve as a testing playground for this particular issue:
|
Good work @fk. There have been a bunch of changes to gatsby-copy-linked files recently that broke my application so I'm back on my custom version of it... haha This looks good though |
@chiedo Thanks for taking a look!
:-( Maybe file an issue? Looking at the gatsby-remark-copy-linked-files history there haven't been too many changes since your PR got merged.
I hope so! ;-) I didn't manage to make room to really look closer today (let alone add tests), but at least I quickly tested BMP and TIFF files, rebuilt a ~150 Markdown files, ~100 images (JPG/PNG), ~30 linked and/or embedded PDFs site with and without gatsby-remark-images/gatsby-remark-copy-linked-files, and also skimmed through the relevant code again — I can't see why removing this should cause any problems/was added in the first place. So I reverted my test commits in using-remark and will label this as good to go, fixes #2696 🎉 |
Awesome @fk ! And if it's working for everyone else, i'll just keep using my custom version. It's been broken since my PR got merged (I just didn't realize until later). A lot of changes happened to merge it and then a few after. But it's just a static site generator haha. So I'm not losing sleep about being on a fork. |
@chiedo sorry to hear that :-( you mind adding a few failing tests with sample code from your site? That'd be super helpful even if you don't have time to chase down why things broke. Also ensure the plugin isn't broken again in the future :-) |
Thanks @fk!! |
Hey @KyleAMathews, Thanks for understanding the time predicament. haha I've been getting slammed for time each day... and haven't got to write code for like a month... All management and marketing these past few days. I didn't want to create an issue because I don't have time to fix it and didn't want to be "that guy" haha But this is the error I currently get when I just try to start my app with the new version of the plugin. I'm not sure what tests to include as sample code without including my whole codebase because I haven't been able to isolate the issue that's preventing my site from launching with
|
That looks like an install error. Node is just saying it can't find a package. Try removing node_modules and reinstalling? |
Also this plugin doesn't use sharp so the problems are unrelated. P.s. sorry about no coding. Hopefully it means your rolling in the dough with huge projects! |
Haha thanks. That's the hope, a solid Q1, if all this marketing and management stuff pays off. Fingers crossed. But yeah, I tried the removing of node_modules and reinstalling. It's one of those freak things that is confusing me haha. If I remove that plugin, all is well. If I add the plugin, things go haywire. At some point, things will slow back down again and I'll get to spend hours coding and debugging. Haha. But for now, my fork is a good temp solution. |
@fk this worked great for me. Thank you so much for the quick fix! You are awesome. |
Was able to do a little bit of Saturday debugging and was able to upgrade packages one-by-one :) So... with all of that being said... An example of a blog post that works perfectly with my forked version but doesn't display any images with the current version can be downloaded here (The link is valid until Nov 18) If someone wanted to debug, write tests, etc that would be awesome! It's something I'll eventually get to if not. But for now, using my forked version works for me. |
Bad news—just checked with regular HTML |
Very icky, but works for now. I broke copying resources referenced for HTML-in-Markdown links, video sources, and images in gatsbyjs#2871 when trying to fix gatsbyjs#2696 by removing writing back the HTML `node.value` via Cheerio’s .html(). Cheerio closes open HTML tags, which in our case caused the problems described in gatsbyjs#2696—an HTML node a with value `<a href=…>` would be written back as `<a href=…`></a>. Since I couldn’t figure out how to do this with either Cheerio nor Rehype/unified, here’s a beginner fix 😬 that replaces the resource links directly in `node.value`…
…xp cannons (#2901) * Fix regression from #2871 with replaceString cannons Very icky, but works for now. I broke copying resources referenced for HTML-in-Markdown links, video sources, and images in #2871 when trying to fix #2696 by removing writing back the HTML `node.value` via Cheerio’s .html(). Cheerio closes open HTML tags, which in our case caused the problems described in #2696—an HTML node a with value `<a href=…>` would be written back as `<a href=…`></a>. Since I couldn’t figure out how to do this with either Cheerio nor Rehype/unified, here’s a beginner fix 😬 that replaces the resource links directly in `node.value`… * Add examples/using-remark-copy-linked-files Not making real tests obsolete at all, but all I could come up with for now. * Tidy example * Drop replace-string, remove unused deps * Add test * Add test `can copy HTML file links` * Add test for `options.ignoreFileExtensions` * Add test `can copy HTML videos`
@chiedo If you find the time please test your Markdown post(s) with the new |
Works like a charm @fk way to go!!! |
Yeah! |
🙏 @chiedo Glad to hear! |
…potentially without any side effects.
This removes a part of #1571 that replaces each Remark HTML node with its Cheerio
.html()
ified equivalent (and changesnode.type
tohtml
). I'm not familiar at all with Cheerio (and have to stay ignorant for now due to time issues), but it seems thathtml()
automagically closes open tags, e.g. an initial node.value of<a href="https://www.gatsbyjs.org">
becomes<a href="https://www.gatsbyjs.org"></a>
.Also, I only briefly looked into this and am not familiar at all with using the part of gatsby-remark-copy-linked-files that seems to have introduced the issue described in #2696.
From what I understand until now, the code I removed is not needed at all.
Maybe @chiedo can take a look again?
I also noticed that the same lines (including the comment) appear in
gatsby/packages/gatsby-remark-images/src/index.js
Lines 211 to 213 in ad0b4e8