.slight-radius {
border-radius: 4px;
}
+
+.preview-lines {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-line-clamp: 3;
+ -webkit-box-orient: vertical;
+}
isMod,
mdToHtml,
numToSI,
- previewLines,
relTags,
restoreScrollPosition,
routeSortTypeToEnum,
get bioTag(): string {
return this.state.personRes.person_view.person.bio
- ? previewLines(this.state.personRes.person_view.person.bio)
+ ? this.state.personRes.person_view.person.bio
: undefined;
}
md,
mdToHtml,
numToSI,
- previewLines,
relTags,
setupTippy,
showScores,
<li className="list-inline-item">
<button
className="text-muted btn btn-sm btn-link p-0"
- data-tippy-content={md.render(
- previewLines(post_view.post.body)
- )}
+ data-tippy-content={md.render(post_view.post.body)}
data-tippy-allowHtml={true}
onClick={linkEvent(this, this.handleShowBody)}
>
return (
post.body &&
!this.showBody && (
- <div
- className="md-div mb-1"
- dangerouslySetInnerHTML={{
- __html: md.render(previewLines(post.body)),
- }}
- />
+ <div className="md-div mb-1 preview-lines">{post.body}</div>
)
);
}
insertCommentIntoTree,
isBrowser,
isImage,
- previewLines,
restoreScrollPosition,
saveCommentRes,
saveScrollPosition,
}
get descriptionTag(): string {
- let body = this.state.postRes.post_view.post.body;
- return body ? previewLines(body) : undefined;
+ return this.state.postRes.post_view.post.body;
}
render() {
return `hsla(${num}, 35%, 50%, 1)`;
}
-export function previewLines(
- text: string,
- maxChars = 300,
- maxLines = 1
-): string {
- return (
- text
- .slice(0, maxChars)
- .split("\n")
- // Use lines * 2 because markdown requires 2 lines
- .slice(0, maxLines * 2)
- .join("\n") + "..."
- );
-}
-
export function hostname(url: string): string {
let cUrl = new URL(url);
return cUrl.port ? `${cUrl.hostname}:${cUrl.port}` : `${cUrl.hostname}`;