Reputation: 93
I'm trying to make a simple line break between a header h2
and the first paragraph of a post in a <data:post.snippet>
in Blogger.
This post kind of helps (How to increase character lengh in blogger snippet instead of using limited length, 'data:post.snippet'?), but I limited the amount of characters using this javascript code (https://groups.google.com/d/msg/bloggerdev/8jUR9uISmA0/J8dmGwACJDgJ) (I don't want to show <data:post.body>
until the read more tag).
Is there a way to style the snippet to make a line break after a heading?
Upvotes: 1
Views: 703
Reputation: 5651
You will need to utilize the new snippet
operator introduced with new themes. It has an option to preserve the line breaks which are present in the actual post content. The code for the same will look like -
<b:eval expr='snippet(data:post.body, {length: 450, linebreaks: true})' />
This will process the data:post.body
data tag and extract the first 450 characters from it while preserving the line breaks present in it.
For more detailed documentation of the snippet
operator -
snippet(string, options)
Produces a short snippet from an HTML string.
options: Object specifying the snippeting options, which are:
- links: boolean for whether to preserve anchors/links in the snippet. Defaults to true.
- linebreaks: boolean for whether to preserve linebreaks (tags) in the snippet. Defaults to true.
- ellipsis: boolean for whether to append an ellipsis (…) to the end of the snippet. Defaults to true.
- length: Number specifying the maximum length of the snippet.
Upvotes: 0