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

Fix Markdown parsing error due to line breaks in generated HTML #4

Merged
merged 2 commits into from
May 24, 2019
Merged

Fix Markdown parsing error due to line breaks in generated HTML #4

merged 2 commits into from
May 24, 2019

Conversation

paulrobertlloyd
Copy link
Contributor

👋🏻 Hey Eric, been a while! Hope you are well ☺️

I’m trying out Cloudinary (as Imgix is burning a hole in my pocket), and seeing as my blog uses 11ty, thought I’d give your plugin a go — it’s made transitioning much easier than it would be otherwise. However, it was generating the following error:

Problem writing Eleventy templates: (full stack in DEBUG output)
> Parse Error: <img
	srcset="https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_320/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg 320w, https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_640/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg 640w, https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_960/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg 960w, https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_1280/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg 1280w, https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_1600/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg 1600w, https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_1920/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg 1920w"
	sizes="100vw"
	src="https://res.cloudinary.com/paulrobertlloyd/image/fetch/q_auto,f_auto,w_640/https://paulrobertlloyd.com/images/2008/09/california_zephyr.jpg"
<p>/&gt;</p>
  <figcaption>
    <p>The landscape you travel across is one of the most scenic routes run by Amtrak.</p>
  </figcaption>
</figure>
<p>The California Zephyr is a 56 hour, 2348 mile long train journey…

Note how the /> was output as <p>/&gt;</p>? I think 11ty’s Markdown parser is upset by the line breaks. I updated the plugin to fix this error while refactoring the code a little to make the returned statement shorter. I also tidied up a few other bits here and there (removing spaces around values, consistent use of => etc., etc.).

I also added a .editorconfig file, which uses the same settings as the main 11ty project. This change (and my syntax formatting) maybe contentious! In which case, feel free to say; I can update this PR to limit it to generating line-break free HTML.

Happy new year!

@paulrobertlloyd paulrobertlloyd changed the title Fix markdown parsing error due to line breaks in generated element Fix Markdown parsing error due to line breaks in generated HTML Jan 5, 2019
@eeeps
Copy link
Owner

eeeps commented May 24, 2019

Paul!

I can't believe I missed this for five months!

Really, really need to re-evaluate my GH notification strategy......

Anyways this looks great; you're not the only one who was running into problems with markdown parsers (or at least I hope that this was the problem in #6) and standardizing on 11ty's style conventions makes a lot of sense.

Thank you, thank you.

@eeeps eeeps merged commit 9f8ad17 into eeeps:master May 24, 2019
@eeeps eeeps mentioned this pull request May 24, 2019
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