mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-06 21:26:20 +02:00
Change EmojiConverter to EmojiUtil
This commit is contained in:
@@ -3,7 +3,7 @@ package gitbucket.core.util
|
||||
/**
|
||||
* Converts an Emoji like :smiley: to its related image
|
||||
*/
|
||||
trait EmojiConverter {
|
||||
object EmojiUtil {
|
||||
|
||||
private val emojis = Set(
|
||||
"+1",
|
||||
@@ -895,7 +895,7 @@ trait EmojiConverter {
|
||||
|
||||
private val emojiPattern = """\:[a-z0-9_\-\+]+\:""".r
|
||||
|
||||
protected def convertEmojis(text: String)(implicit context: gitbucket.core.controller.Context): String =
|
||||
def convertEmojis(text: String)(implicit context: gitbucket.core.controller.Context): String =
|
||||
emojiPattern replaceAllIn(text, e => {
|
||||
val emoji = e.group(0) replaceAll(":", "")
|
||||
if (!emojis.contains(emoji)) s":$emoji:"
|
||||
@@ -6,7 +6,7 @@ import java.util.Locale
|
||||
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||
import gitbucket.core.util.{EmojiConverter, StringUtil}
|
||||
import gitbucket.core.util.{EmojiUtil, StringUtil}
|
||||
import io.github.gitbucket.markedj._
|
||||
import io.github.gitbucket.markedj.Utils._
|
||||
|
||||
@@ -58,7 +58,7 @@ object Markdown {
|
||||
enableTaskList: Boolean,
|
||||
hasWritePermission: Boolean,
|
||||
pages: List[String])
|
||||
(implicit val context: Context) extends Renderer(options) with LinkConverter with EmojiConverter with RequestCache {
|
||||
(implicit val context: Context) extends Renderer(options) with LinkConverter with RequestCache {
|
||||
|
||||
override def heading(text: String, level: Int, raw: String): String = {
|
||||
val id = generateAnchorName(text)
|
||||
@@ -114,7 +114,7 @@ object Markdown {
|
||||
val t2 = if(enableTaskList) convertCheckBox(t1, hasWritePermission) else t1
|
||||
|
||||
// convert emoji to image
|
||||
val t3 = convertEmojis(t2)
|
||||
val t3 = EmojiUtil.convertEmojis(t2)
|
||||
|
||||
t3
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user