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
Re-implement handling Liquid blocks in excerpts #7250
Conversation
6526f8f
to
d46fdd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the inline comments.
As part of excerpt generator, do we need to be concerned about liquid object tag pairs ({{
and }}
)?
lib/jekyll/excerpt.rb
Outdated
@@ -131,36 +131,44 @@ def render_with_liquid? | |||
# | |||
# Returns excerpt String | |||
|
|||
LIQUID_TAG_REGEX = %r!{%-?\s*(\w+).+\s*-?%}!m | |||
LIQUID_TAG_REGEX = %r!{%-?\s*(\w+).+?\s*-?%}!m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The capture for this regular expression isn't 100% correct. A liquid tag of {%highlight%}
will lose the last letter, meaning that the capture group will contain highligh
instead of highlight
I wrote a quick test case for this on Rubular as well, as an extra example: http://rubular.com/r/umPU5g5PiH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching this @mattr- 🙂
@mattr- No, we shouldn't handle deviation from the formats used by the majority of the users: |
@ashmaroli Sorry, not sure I understood you. Are you saying that since |
No more error thrown, just the warning. Good job. |
@mattr- Not at all.. |
Oh.. The Utterson Report doesn't look good.. 🙁
|
@ashmaroli Correctness wins over performance 👍🏼 |
" #{doc.excerpt_separator.inspect}. " | ||
Jekyll.logger.warn "", "The block has been modified with the appropriate closing tag." | ||
Jekyll.logger.warn "", "Feel free to define a custom excerpt or excerpt_separator in the" | ||
Jekyll.logger.warn "", "document's Front Matter if the generated excerpt is unsatisfactory." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all the same warning, not separate messages, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pathawks Yes. These calls are for the same warning.
I split them out into separate calls so that the messages appear to be formatted on the CLI.
I can't use a heredoc to emulate the formatting because Jekyll's logger
squashes all whitespace into a single space
char, which causes heredoc messages to simply print as a single line message.
ref: Liquid::BlockBody::FullToken https://git.io/fAyaY
1c58230
to
61831d4
Compare
@jekyllbot: merge +bug |
Resolves #7248
This re-implementation should be able to handle multiple Liquid blocks in excerpts.
@djacquel I invite you to test this branch against various valid combinations of Liquid blocks so that we can get rid of this issue for good. Thanks in advance.
@jekyll/core I request this PR to be considered a.s.a.p and be backported to the
3.8-stable
series