Quantcast
Channel: User Prayag Verma - Stack Overflow
Viewing all articles
Browse latest Browse all 39

Answer by Prayag Verma for How to change blogger post snippet length without affecting other widget text?

$
0
0

This issue arose because data:post.body data tag contains the whole content of the post including the HTML unlike the data:post.snippet or data:post.longSnippet data tags which strip these away internally.

Even though the snippet operator only counts text content when determining the length but it doesn't explicitly strip away the HTML tags associated with that content (It only provides options for stripping away anchor (<a>) tags via the links option and <br> tags via linebreaks option but no options for other tags like bold or italics).

In this particular case, there is an HTML tag present for italicizing the text which couldn't be closed properly because of the character length limit of the snippet (In the screenshot, we can observe that the bold text from the post content is displaying correctly as the opening and closing tags were included within the snippet length itself). Due to the missing closing tag used for italicizing the text, the browser italicized all the text after the snippet (as it couldn't figure out where the italicizing should be stopped)

If the requirement for snippet length is not more than 850 characters, then using data:post.longSnippet would be a better choice than data:post.body. Previously data:post.longSnippet was limited to 300-400 characters but that limit has now been increased. Coupling it with the snippet operator would give you more control over the character length. The new code snippet would look like -

<b:eval expr='snippet(data:post.longSnippet, {length: 650, linebreaks: false, links: false})' />

Viewing all articles
Browse latest Browse all 39

Trending Articles