4,554
edits
No edit summary |
No edit summary |
||
Line 1,857: | Line 1,857: | ||
if ($("#show-article-wrapper-entry").length) { | if ($("#show-article-wrapper-entry").length) { | ||
function formatParagraphs(text) { | function formatParagraphs(text) { | ||
return text | |||
.split("\n") | |||
.filter((p) => p.trim() !== "") | |||
.map((p) => "<p>" + p.trim() + "</p>") | |||
.map( | |||
.join(""); | .join(""); | ||
} | } | ||
$( | |||
"#show-article .article-description, #show-article .article-reflection" | |||
).each(function () { | |||
// Skip if already has <p> children (means it's formatted) | |||
$(" | if ($(this).children("p").length > 0) return; | ||
const rawText = $(this).text(); | |||
$(this).html(formatParagraphs(rawText)); | |||
}); | |||
$( | |||
} | |||
} | } | ||