mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-19 22:05:42 -04:00
Add comments to origin and reason for stripping of body
This commit is contained in:
@@ -9,8 +9,11 @@ import React from "react";
|
||||
import { formatDifferenceForHumans } from "sharedHelpers/dateAndTime";
|
||||
import { useTranslation } from "sharedHooks";
|
||||
|
||||
function stripHtmlForPreview( body: string ): string {
|
||||
return body.replace( /<[^>]+>/g, " " ).replace( /\s+/g, " " ).trim( );
|
||||
// Similar to computeProperties in ExplorePost.m from iNaturalistIOS
|
||||
function stripBodyForExcerpt( body: string ): string {
|
||||
// Port of stringByStrippingHTML from NSString+Helpers.m from iNaturalistIOS
|
||||
// /<[^>]+>/g matches anything between < and >, e.g. "<p>Hello world</p>" => "Hello world".
|
||||
return body.replace( /<[^>]+>/g, "" ).replace( /\n/g, "" ).trim( );
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -27,7 +30,7 @@ const PostListItem = ( {
|
||||
}
|
||||
|
||||
const excerpt = item.body
|
||||
? stripHtmlForPreview( item.body )
|
||||
? stripBodyForExcerpt( item.body )
|
||||
: "";
|
||||
|
||||
let bodyNumberOfLines = 3;
|
||||
|
||||
Reference in New Issue
Block a user