-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🍔 Consume myst-parser and role/directive extensions in myst-cli
- Loading branch information
Showing
9 changed files
with
74 additions
and
976 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Root } from 'mdast'; | ||
import { mystParse } from 'myst-parser'; | ||
import { cardDirective } from 'myst-ext-card'; | ||
import { gridDirective } from 'myst-ext-grid'; | ||
import { reactiveDirective, reactiveRole } from 'myst-ext-reactive'; | ||
import { tabDirectives } from 'myst-ext-tabs'; | ||
import { VFile } from 'vfile'; | ||
import type { ISession } from '../session'; | ||
import { logMessagesFromVFile } from '../utils'; | ||
|
||
export function parseMyst(session: ISession, content: string, file: string): Root { | ||
const vfile = new VFile(); | ||
vfile.path = file; | ||
const parsed = mystParse(content, { | ||
markdownit: { linkify: true }, | ||
directives: [cardDirective, gridDirective, reactiveDirective, ...tabDirectives], | ||
roles: [reactiveRole], | ||
vfile, | ||
}); | ||
logMessagesFromVFile(session, vfile); | ||
return parsed; | ||
} |
Oops, something went wrong.