yumechi-no-kuni/src/mfm/parse/elements/bold.ts

21 lines
341 B
TypeScript
Raw Normal View History

2016-12-28 16:49:51 -06:00
/**
* Bold
*/
2018-06-17 05:55:39 -05:00
export type TextElementBold = {
2018-06-18 00:28:43 -05:00
type: 'bold'
2018-06-17 05:55:39 -05:00
content: string
bold: string
};
export default function(text: string) {
2017-02-10 11:32:00 -06:00
const match = text.match(/^\*\*(.+?)\*\*/);
if (!match) return null;
const bold = match[0];
return {
type: 'bold',
content: bold,
bold: bold.substr(2, bold.length - 4)
2018-06-17 05:55:39 -05:00
} as TextElementBold;
}