How to replace the last <p> tag in Jekyll
2 answers
In my opinion, the best way is CSS:
.excerpt p:last-child::after {
content: '..';
}
This adds a ".." to the last paragraph of the after
psuedo-element inside the excerpt div
.
<div class="excerpt">
<p>Normal paragraph.</p>
<p>Paragraph with trailing ellipsis.</p>
</div>
If you need to do this with Jekyll, you can use a filter slice
to disable the end </p>
and a filter append
to add '...</p>'
to the end. This will not work if your passage does not end with a paragraph.
+5