-
Notifications
You must be signed in to change notification settings - Fork 61
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
Excerpt Possibly Incorrect #12
Comments
It definitely needs improvement. Ideally you'd just be able to define the excerpt in a non hideous manner. Something like an inline Jinja tag or using the yaml front matter are ideas that come to mind but are equally as bad if not worse. The issue with it only grabbing a paragraph if it's at the start is it may not be convenient with the layout of your posts. The upside being you have more control on what excerpt contains. With it grabbing the first paragraph it sees no matter where it is the issue becomes losing the ability to have an empty excerpt. The upside being it may fit better with the layout of your posts. I think rather than just tweaking the regex a better solution altogether is needed and I'm open to any suggestions. |
I think a simple solution would be using the YAML frontmatter. I looked into writing a Jinja2 extension, but I can think of too many problems for me to like that solution. Specifically - it takes the excerpt away from the actual document markup and makes it a part of the templating system, which doesn't seem like a good idea to me. If there was something like "excerpt_delim" in the frontmatter, mynt could parse the generated code and set the excerpt to be everything before that delimiter, and then strip the delimiter from the generated HTML. The issue I see with this solution is that the delimiter then needs to be chosen by the user, and you run into two issues:
Not to mention, I'm not a huge fan of making the user choose the delimiter. I'll put some more thought into this - it's a nontrivial problem, for sure. |
Yeah, I was thinking of a similar idea sort of hijacking a misaka renderer callback. Something like use the fenced code block but supply a special value for the language to identify it as an excerpt. Not sure how I feel about it as it's still rather hackish and is misaka specific which defeats the idea of mynt being renderer/parser independent. Maybe the use of a rare HTML tag like |
Yeah, I'm a fan of the parser-independence, so I'm not a fan of anything that ties into misaka / jinja2. I came up with another idea, too. Something like this:
The idea being, the post will be parsed, and then mynt looks for the first instance of the stuff in quotes ("of the excerpt."), and grabs everything before that as the excerpt. It might throw a warning if it notices two instances of the search string, like in the above example at the end of the 2nd paragraph. The advantage of this: it's simple, and completely independent of how the content is parsed / rendered. Perhaps not the most elegant, though. Also, I'd hesitate to use |
Not really sure I like the As for the A problem I could see with just using some random tag/string is other renderers may be configured to strip certain/invalid HTML. Although I can see this not being very elegant either as some people may use Tricky problem indeed :s |
Yeah, good point on the lack of a sane default for As for the You'd have to handle |
If you want to do it that way, you probably want something like this:
If you want it fancy and accepting
|
Hrm, just thought of an issue with the Not sure if you're any more familiar than I am (not very) with any of the popular CMSs, but do you know how they handle excerpts? Any worthy ideas to pull from there? |
I'm not incredibly familiar with the way that other CMSs do it, but some quick Googling gives me this: Specifically, it lets you specify the excerpt yourself, or it grabs the first 55 words from the post, or it looks for the
EDIT: And the regex would be something like: |
Yeah, that's pretty much the same thing as the Would be nice to get some more input on this. I'm about to push out 0.2 which adds a default theme and init, watch, and serve subcommands which should make mynt a bit more accessible so maybe some newcomers will see this and have some ideas. For now I think the |
Ok, maybe it's just me, but I'm not sure I understand what you mean by "not wrapped in HTML". Can you clarify what you mean? |
I mean the excerpt should never contain any block level elements. |
It would also be great to allow the possibility to set the start of the excerpt <!-- excerpt_start -->
My excerpt.
<!-- excerpt_end --> If no excerpt_start, parse from the beginning of the dockument until the |
The issue with using comments, as discussed above, is grabbing the excerpt not wrapped in HTML. I imagine the only time you'd want to use the start/end comments would be when you want an excerpt that's longer than 1 paragraph. Which means the excerpt would have to be wrapped in HTML. So then sometimes you'd be getting an excerpt that is wrapped in HTML and sometimes not. The default is, and probably always will be, the first paragraph of the post. If someone wants the first |
The issue I wanted to lift was to give the possibility to set the start for the |
I guess that just seems odd to me because I always viewed the excerpt serving as a summary and it doesn't make much sense to have a summary of a post anywhere other than at the beginning. |
But don't you usually put the summary at the end of a post instead of in |
I need to stop using GitHub when I'm just about to go to sleep or have just woken up like now :s Sorry, summary was somewhat the wrong word and I'm drawing a blank for a better one. I feel the excerpt serves to give the reader a brief overview of what the post is about to help them decide if they want to read the entire post or not. I don't know why a paragraph in the middle of a post would do a better job of that then the first. I suppose an argument could be made for using the last paragraph. Would an option to chose between the first or last paragraph be sufficient? This issue pretty much is the discussion of a solution :p I'm open to any and all ideas. We've only really had 2 solutions come up and I'm not really fond of either. I think to really tackle this issue, we need more information. Specifically, where do people want the excerpt to come from and how do they want that excerpt to be handled. |
Hello, I'm glad to find a discussion about this already. Regarding automatic excerpt: It is not common to write blog post summaries anywhere. The first paragraph however is commonly a good representation as it should be an introduction. When in doubt I suggest to reproduce http://jekyllrb.com/docs/posts/#post-excerpts behavior. I actually came to report the issue that .excerpt produces "None" when the first line of the post contains a header (which might be bad style, which is probably why it didn't get noticed) and providing an image if the first line of the post contains an image (which might be desired though). These issues are currently showing up on pyladies.com/blog EDIT: I just realized that if the first line is surrounded by "*" (making it italic), the paragraph also produces "None". |
Hello,
The "excerpt" feature seems to be not working as I would expect - not sure if this is intended or not. Specifically, it seems to only work if the first
<p>
tag starts at the very beginning of the post. Here's an example - if you take the regex here here's what you get:If this isn't intended, I can try and fix it, if you want.
Also, a bit of a side-note: the regex is case-sensitive, so it doesn't work with upper-case
<p>
tags. This isn't so important, though.Thanks!
The text was updated successfully, but these errors were encountered: