Excerpts include layout! #1321

Closed
6twenty opened this Issue Jul 17, 2013 · 22 comments

Projects

None yet

10 participants

@6twenty
6twenty commented Jul 17, 2013

Commit 015ace6 introduced self.extracted_excerpt.do_layout(payload, layouts) on line 255 of lib/jekyll/post.rb. For me, this caused all of my post excerpts to render with the layout. Using Maruku, this was cause build errors as it was unable to parse the crazy HTML; using Redcarpet the build would succeed but my page would be full of broken HTML.

I was able to resolve my issue by commenting out this line; I'm not sure though what the original purpose of this line was so I'm not yet submitting a pull request for this change.

@rwboyer
rwboyer commented Jul 17, 2013

See bug #1307 and my comment on that line - you effectively just un-did that feature.

@6twenty
6twenty commented Jul 17, 2013

I should add that Maruku only complains when the excerpt is being markdownified (eg {{ post.except | markdownify }})

@6twenty
6twenty commented Jul 17, 2013

So self.extracted_excerpt.do_layout(payload, layouts) is to allow Liquid within excerpts? This sounds like the wrong approach to the problem, no?

@mattr-
Member
mattr- commented Jul 17, 2013

@6twenty Sorry, but I'm a bit confused. Which problem are you referring to?

I think you should be able to fix your issue if you don't markdownify your excerpt. Does removing the markdownification help at all?

@6twenty
6twenty commented Jul 17, 2013

The issue is that {{ post.excerpt }} is rendering the entire layout instead of just the excerpt. So the issue remains with or without markdownify.

@6twenty
6twenty commented Jul 17, 2013

As far as I can tell, self.extracted_excerpt.do_layout(payload, layouts) is changing the content of post.excerpt. Prior to this line I can see that my posts excerpts are being generated fine; after this line, the excerpts are being wrapped with the layout.

Also please note that my excerpts are being generated via the built in excerpt_separator; not as part of the YAML front matter. I've done a test putting the excerpt into the YAML front matter and it seems to work fine; so perhaps there's an issue in how Jekyll automatically extracts the excerpt from the post content?

@6twenty
6twenty commented Jul 17, 2013

Here's a simplified example of the malformed output from {{ post.excerpt }}:

<!DOCTYPE html>
<html>
  <head>
    [snip]
  </head>
  <body>
    <article>
      <!-- This is where {{ post.excerpt }} was -->
      <!DOCTYPE html>
      <html>
        <head>
          [snip]
        </head>
        <body>
          <!-- This is where the actual excerpt ends up -->
          [snip]
        </body>
      </html>
    </article>
  </body>
</html>
@parkr
Member
parkr commented Jul 17, 2013

This specific problem can be solved by just overriding render_all_layouts and setting self.output = self.content and leaving it at that. I'm having trouble testing now where the output isn't set soon enough or something so I'm getting the un-transformed content on the page (#to_s is called but self.output is nil). I'll keep working on it.

@rwboyer
rwboyer commented Jul 17, 2013

from my point of view this is all pretty much the same issue as #1307 and it all stems from:

self.extracted_excerpt.do_layout(payload, layouts)

without any regard to context...

@parkr
Member
parkr commented Jul 17, 2013

we simply can't know about context. we need to convert and parse liquid as is without the layout.

@WickyNilliams

Just came to report the exact same bug - I noticed this issue when upgrading also.

{{page.excerpt}} will literally render the the HTML of the page, up to the end of the first paragraph. The DOM is left completely malformed. For now I can work around it by manually assigning excerpts in each post, but that's far from ideal.

@thenayr
thenayr commented Jul 18, 2013

screen shot 2013-07-17 at 10 37 59 pm
Same issue after upgrade, excerpts render with the full layout as mentioned above. Manual yaml front matter excerpts render fine.

@miyagawa

Same problem with post.excerpt having the entire layout, breaking index and feeds.

@flxw
flxw commented Jul 19, 2013

Just encountered the same problem as miyagawa to notice a nice effect of inceptiooooon :D
2013-07-19-224321_989x728_scrot

@rwboyer
rwboyer commented Jul 19, 2013

FYI - @parkr pulled 1.1.0 because of the fallout of rendering liquid in excerpts so...

back to 1.0.3 for everyone I guess - I sorta figured...

Just encountered the same problem as miyagawa to notice a nice effect of inceptiooooon :D

@WickyNilliams

Where did you find that info, @rwboyer?

@rwboyer
rwboyer commented Jul 20, 2013

It's in the jekyll issues threads that I have been following all week since opening some bugs...

[https://github.com/mojombo/jekyll/issues/1329]

@WickyNilliams

Thanks mate, back to 1.0.3 it is then :)

@parkr parkr closed this Jul 20, 2013
@parkr parkr reopened this Jul 20, 2013
This was referenced Jul 20, 2013
@mattr- mattr- closed this in #1339 Jul 24, 2013
@6twenty
6twenty commented Jul 24, 2013

Thanks @parkr and @mattr- -- your hard work is very much appreciated! 😃

@joaoafrmartins

hey! i am having this issue on version 1.4.3 when using autogenerated excerpts

@flashlib

@joaoafrmartins Please check if your file format is 'dos'. My excerpts get work after I change the file type form 'dos' to 'unix'.

@joaoafrmartins

@flashlib no in my case is not because of EOL but thank you!

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