-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: support Math in Markdown #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1129c0a
33389e3
2738318
d4d1a09
8881315
69d750c
fca5c21
9e95964
b323f1e
052bf88
1c9d590
7a2e0c8
814104e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -66,7 +66,8 @@ export function useAST() { | |||||
| } | ||||||
|
|
||||||
| case "markdown": { | ||||||
| const { markdownMode, markdownFrontmatter } = markdownOptions; | ||||||
| const { markdownMode, markdownFrontmatter, markdownMath } = | ||||||
| markdownOptions; | ||||||
| const language = markdown.languages[markdownMode]; | ||||||
| astParseResult = language.parse( | ||||||
| { body: code.markdown, path: "", physicalPath: "", bom: false }, | ||||||
|
|
@@ -76,6 +77,7 @@ export function useAST() { | |||||
| markdownFrontmatter === "off" | ||||||
| ? false | ||||||
| : markdownFrontmatter, | ||||||
| math: markdownMath, | ||||||
|
||||||
| math: markdownMath, | |
| math: markdownMath ?? false, |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,6 +48,7 @@ export type JsonOptions = { | |||||||||||||||||||||||||||
| export type MarkdownOptions = { | ||||||||||||||||||||||||||||
| markdownMode: MarkdownMode; | ||||||||||||||||||||||||||||
| markdownFrontmatter: MarkdownFrontmatter; | ||||||||||||||||||||||||||||
| markdownMath: boolean; | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| type PersistedMarkdownOptions = Omit<MarkdownOptions, "markdownMath"> & { | |
| markdownMath?: boolean; | |
| }; | |
| export const normalizeMarkdownOptions = ( | |
| markdownOptions?: PersistedMarkdownOptions, | |
| ): MarkdownOptions => ({ | |
| ...defaultMarkdownOptions, | |
| ...markdownOptions, | |
| markdownMath: markdownOptions?.markdownMath ?? false, | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll dig into this problem a bit more in the near future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked={markdownMath}assumes the value is always a boolean, but if a user has older persisted state (beforemarkdownMathexisted) it can beundefinedand cause controlled/uncontrolled issues. Either ensure rehydration/migration fillsmarkdownMath, or defensively coalesce here (e.g. default tofalse).