import { Emoji, EmojiSyntax, Heading, ImageTag } from './Regex'
import Twemoji from 'twemoji'
import { KoreanbotsEmoji } from './Constants'
export const anchorHeader = {
type: 'output',
regex: Heading,
replace: function (__match: string, id:string, title:string, level:number): string {
// github anchor style
const href = id.replace(ImageTag, '$1').replace(/"/gi, '')
const octicon_html = `
`
return `${octicon_html}${title}`
}
}
export const twemoji = {
type: 'output',
regex: `${Emoji}{1,2}`,
replace: function(__match: string, two: string, one: string) {
const parsed = __match || two || one
const emoj = Twemoji.parse(parsed, { folder: 'svg', ext: '.svg', base: 'https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/' })
if(!emoj) return parsed
return emoj
}
}
export const customEmoji = {
type: 'output',
regex: EmojiSyntax,
replace: function(__match: string, name: string): string {
const result = KoreanbotsEmoji.find(el => el.short_names.includes(name))
if(!name || !result) return `:${name}:`
return `
`
}
}