Add >greentext and <cyantext.
I cannot recommend running it yet.
This commit is contained in:
parent
87b18da811
commit
3c8cf27d34
|
@ -83,6 +83,24 @@ export const defaultState = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const greentextify = (shtml) => {
|
||||||
|
let rows = []
|
||||||
|
const removeMastodon = shtml.replace(/<br>/g, '<br />')
|
||||||
|
.replace(/<p>/g, '')
|
||||||
|
.replace(/<\/p>/g, '<br />')
|
||||||
|
each(removeMastodon.split('<br />'), (row) => {
|
||||||
|
row = row.replace('\n', '').replace('<span>', '').replace('</span>', '')
|
||||||
|
if (row.match(/^[ ]?>/)) {
|
||||||
|
rows.push(`<span class="base0B">${row}</span><br />`)
|
||||||
|
} else if (row.match(/^[ ]?</)) {
|
||||||
|
rows.push(`<span class="base0D">${row}</span><br />`)
|
||||||
|
} else {
|
||||||
|
rows.push(`${row}<br />`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return rows.join('').replace('<br /><br />', '<br />')
|
||||||
|
}
|
||||||
|
|
||||||
const isNsfw = (status) => {
|
const isNsfw = (status) => {
|
||||||
const nsfwRegex = /#nsfw/i
|
const nsfwRegex = /#nsfw/i
|
||||||
return includes(status.tags, 'nsfw') || !!status.text.match(nsfwRegex)
|
return includes(status.tags, 'nsfw') || !!status.text.match(nsfwRegex)
|
||||||
|
@ -94,6 +112,12 @@ export const prepareStatus = (status) => {
|
||||||
status.nsfw = isNsfw(status)
|
status.nsfw = isNsfw(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add greentext
|
||||||
|
if (!status.greentextified) {
|
||||||
|
status.statusnet_html = greentextify(status.statusnet_html)
|
||||||
|
status.greentextified = true
|
||||||
|
}
|
||||||
|
|
||||||
// Set deleted flag
|
// Set deleted flag
|
||||||
status.deleted = false
|
status.deleted = false
|
||||||
|
|
||||||
|
@ -137,10 +161,13 @@ const mergeOrAdd = (arr, obj, item) => {
|
||||||
const oldItem = obj[item.id]
|
const oldItem = obj[item.id]
|
||||||
|
|
||||||
if (oldItem) {
|
if (oldItem) {
|
||||||
|
// save the greentext to avoid re-processing
|
||||||
|
const greentext = oldItem.statusnet_html
|
||||||
// We already have this, so only merge the new info.
|
// We already have this, so only merge the new info.
|
||||||
merge(oldItem, item)
|
merge(oldItem, item)
|
||||||
// Reactivity fix.
|
// Reactivity fix.
|
||||||
oldItem.attachments.splice(oldItem.attachments.length)
|
oldItem.attachments.splice(oldItem.attachments.length)
|
||||||
|
oldItem.statusnet_html = greentext
|
||||||
return {item: oldItem, new: false}
|
return {item: oldItem, new: false}
|
||||||
} else {
|
} else {
|
||||||
// This is a new item, prepare it
|
// This is a new item, prepare it
|
||||||
|
|
Loading…
Reference in New Issue