Refactoring

This commit is contained in:
syuilo 2018-08-15 20:27:49 +09:00
parent 83dcfec053
commit 08b431723a
4 changed files with 6 additions and 6 deletions

View File

@ -15,6 +15,6 @@ export default function(text: string) {
return { return {
type: 'bold', type: 'bold',
content: bold, content: bold,
bold: bold.substr(2, bold.length - 4) bold: match[1]
} as TextElementBold; } as TextElementBold;
} }

View File

@ -18,7 +18,7 @@ export default function(text: string) {
return { return {
type: 'code', type: 'code',
content: code, content: code,
code: code.substr(3, code.length - 6).trim(), code: match[1],
html: genHtml(code.substr(3, code.length - 6).trim()) html: genHtml(match[1])
} as TextElementCode; } as TextElementCode;
} }

View File

@ -9,12 +9,12 @@ export type TextElementEmoji = {
}; };
export default function(text: string) { export default function(text: string) {
const match = text.match(/^:[a-zA-Z0-9+-_]+:/); const match = text.match(/^:([a-zA-Z0-9+-_]+):/);
if (!match) return null; if (!match) return null;
const emoji = match[0]; const emoji = match[0];
return { return {
type: 'emoji', type: 'emoji',
content: emoji, content: emoji,
emoji: emoji.substr(1, emoji.length - 2) emoji: match[1]
} as TextElementEmoji; } as TextElementEmoji;
} }

View File

@ -15,6 +15,6 @@ export default function(text: string) {
return { return {
type: 'quote', type: 'quote',
content: quote, content: quote,
quote: quote.substr(1, quote.length - 2).trim(), quote: match[1].trim(),
} as TextElementQuote; } as TextElementQuote;
} }