diff options
Diffstat (limited to 'src/mfm/parse/elements/math.ts')
| -rw-r--r-- | src/mfm/parse/elements/math.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mfm/parse/elements/math.ts b/src/mfm/parse/elements/math.ts new file mode 100644 index 0000000000..b10efe515f --- /dev/null +++ b/src/mfm/parse/elements/math.ts @@ -0,0 +1,20 @@ +/** + * Math + */ + +export type TextElementMath = { + type: 'math'; + content: string; + formula: string; +}; + +export default function(text: string) { + const match = text.match(/^\$(.+?)\$/); + if (!match) return null; + const math = match[0]; + return { + type: 'math', + content: math, + formula: match[1] + } as TextElementMath; +} |