Skip to content

Commit 92271f3

Browse files
author
Sergei Orlov
committed
✨ Add support for inline math equations
1 parent f9ff004 commit 92271f3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/block-to-string.js

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const ifTrue = (predicate, transformer, orElse) => (data) =>
77

88
const id = (x) => x
99

10+
const annotateEquation = ifTrue(
11+
pick("equation"),
12+
({ content }) => ({ content: `$${content}$` }),
13+
id,
14+
)
1015
const annotateBold = ifTrue(pick("bold"), ({ content }) => ({ content: `**${content}**` }), id)
1116
const annotateItalic = ifTrue(pick("italic"), ({ content }) => ({ content: `_${content}_` }), id)
1217
const annotateCode = ifTrue(pick("code"), ({ content }) => ({ content: `\`${content}\`` }), id)
@@ -38,6 +43,7 @@ const stylize = pipeExtend(annotateBold)
3843
.pipeExtend(annotateUnderline)
3944
.pipeExtend(annotateColor)
4045
.pipeExtend(annotateLink)
46+
.pipeExtend(annotateEquation)
4147

4248
exports.blockToString = (textBlocks) =>
4349
textBlocks.reduce((text, textBlock) => {
@@ -46,6 +52,11 @@ exports.blockToString = (textBlocks) =>
4652
...textBlock.annotations,
4753
}
4854

55+
if (textBlock.type == "equation") {
56+
data.content = textBlock.equation.expression
57+
data.equation = true
58+
}
59+
4960
if (textBlock.type == "mention") {
5061
if (textBlock.mention.type == "user") {
5162
data.content = textBlock.plain_text

0 commit comments

Comments
 (0)