aboutsummaryrefslogtreecommitdiff
path: root/src/components/rich_content/rich_content.jsx
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2021-06-12 21:49:40 +0300
committerHenry Jameson <me@hjkos.com>2021-06-12 21:49:56 +0300
commit9c70f3e4df2e28863b51156fdbd25e253a3a1b98 (patch)
tree4ee91fd50829fe4853d2e2af395163995d4a0709 /src/components/rich_content/rich_content.jsx
parent2c60a9b638a00db33e6c47e8642aff2ffd0ce7a0 (diff)
fixed a bug + made a testcase out of it
Diffstat (limited to 'src/components/rich_content/rich_content.jsx')
-rw-r--r--src/components/rich_content/rich_content.jsx5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
index 0aae7a55..e188763f 100644
--- a/src/components/rich_content/rich_content.jsx
+++ b/src/components/rich_content/rich_content.jsx
@@ -247,12 +247,13 @@ const getLinkData = (attrs, children, index) => {
export const preProcessPerLine = (html, greentext, handleLinks) => {
const lastMentions = []
- let nonEmptyIndex = 0
+ let nonEmptyIndex = -1
const newHtml = convertHtmlToLines(html).reverse().map((item, index, array) => {
// Going over each line in reverse to detect last mentions,
// keeping non-text stuff as-is
if (!item.text) return item
const string = item.text
+ nonEmptyIndex += 1
// Greentext stuff
if (greentext && (string.includes('&gt;') || string.includes('&lt;'))) {
@@ -260,10 +261,8 @@ export const preProcessPerLine = (html, greentext, handleLinks) => {
.replace(/@\w+/gi, '') // remove mentions (even failed ones)
.trim()
if (cleanedString.startsWith('&gt;')) {
- nonEmptyIndex += 1
return `<span class='greentext'>${string}</span>`
} else if (cleanedString.startsWith('&lt;')) {
- nonEmptyIndex += 1
return `<span class='cyantext'>${string}</span>`
}
}