-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
154 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {MarkdownNodes} from '../MarkdownNodes.js'; | ||
import {walkRecursiveSync} from '../markdownNodesUtils.js'; | ||
|
||
export function convertMathMl(markdownChunks: MarkdownNodes) { | ||
walkRecursiveSync(markdownChunks.body, (chunk, ctx: { nodeIdx: number }) => { | ||
if (!(chunk.isTag && chunk.tag === 'MATHML')) { | ||
return; | ||
} | ||
|
||
const prevChunk = chunk.parent.children[ctx.nodeIdx - 1]; | ||
const nextChunk = chunk.parent.children[ctx.nodeIdx + 1]; | ||
|
||
if (prevChunk?.isTag === false || nextChunk?.isTag === false) { | ||
const text = chunk.children.filter(c => c.isTag === false).map(c => c['text']).join('\n'); | ||
chunk.parent.children.splice(ctx.nodeIdx, 1, { | ||
isTag: false, | ||
text: '$$' + text + '$$' | ||
}); | ||
return; | ||
} | ||
|
||
chunk.tag = 'PRE'; | ||
chunk.payload.lang = 'math'; | ||
const brNode = markdownChunks.createNode('EMPTY_LINE/'); | ||
chunk.parent.children.splice(ctx.nodeIdx + 1, 0, brNode); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters