]> Untitled Git - lemmy-ui.git/commitdiff
Don't render markdown for summaries. Fixes #658 (#659)
authorDessalines <dessalines@users.noreply.github.com>
Mon, 23 May 2022 11:13:41 +0000 (07:13 -0400)
committerGitHub <noreply@github.com>
Mon, 23 May 2022 11:13:41 +0000 (11:13 +0000)
src/assets/css/main.css
src/shared/components/person/profile.tsx
src/shared/components/post/post-listing.tsx
src/shared/components/post/post.tsx
src/shared/utils.ts

index b9fe4b98cafbeeb10775a59614008b1b1609d3b0..fe728ca640dce3e32ce04210d95a2b5bcdb85b6d 100644 (file)
@@ -374,3 +374,11 @@ br.big {
 .slight-radius {
   border-radius: 4px;
 }
+
+.preview-lines {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  display: -webkit-box;
+  -webkit-line-clamp: 3;
+  -webkit-box-orient: vertical;
+}
index 42cb2491d21e4e4dd34b39b78167e61603fbff96..372a899f521a11731793a5429680580cbb85ae7c 100644 (file)
@@ -34,7 +34,6 @@ import {
   isMod,
   mdToHtml,
   numToSI,
-  previewLines,
   relTags,
   restoreScrollPosition,
   routeSortTypeToEnum,
@@ -221,7 +220,7 @@ export class Profile extends Component<any, ProfileState> {
 
   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;
   }
 
index 3a315492d4938a2c3e83191b55c42819a5031482..253eeb4e8adbbb2d321b609e436102168e1caeba 100644 (file)
@@ -35,7 +35,6 @@ import {
   md,
   mdToHtml,
   numToSI,
-  previewLines,
   relTags,
   setupTippy,
   showScores,
@@ -355,9 +354,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
             <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)}
               >
@@ -1093,12 +1090,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
     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>
       )
     );
   }
index 9b59859812f3cfc0b4044c26d970e619ea204af0..5d15e832fab318c355c574ee76aa9a930c1871c2 100644 (file)
@@ -46,7 +46,6 @@ import {
   insertCommentIntoTree,
   isBrowser,
   isImage,
-  previewLines,
   restoreScrollPosition,
   saveCommentRes,
   saveScrollPosition,
@@ -287,8 +286,7 @@ export class Post extends Component<any, PostState> {
   }
 
   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() {
index bf0a6d8184109b4e5ff59e07c6fc5260897c5c10..a0f0376e6dae512143bba57bf52ea4923f152625 100644 (file)
@@ -1034,21 +1034,6 @@ function hsl(num: number) {
   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}`;