-
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.
feat: unify entity description parsing logic
and update the VSCode extension to use the body parsing logic in hover previews. Still a few polishing items to do here: - expand internal references to linked names - fix katex styling oddities but this is a reasonable enough start to at least publish as a prerelease version.
- Loading branch information
1 parent
4e23d2d
commit 3ffa14a
Showing
28 changed files
with
1,169 additions
and
339 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
coverage | ||
dist | ||
out | ||
pnpm-lock.yaml | ||
.svelte-kit | ||
.vscode-test |
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,19 @@ | ||
import * as z from 'zod' | ||
import * as yaml from 'js-yaml' | ||
|
||
// TODO: unify with logic in packages/compiler | ||
export function parseDocument<T>(schema: z.ZodSchema<T>, contents: string) { | ||
const match = contents.match( | ||
/^(---)?\s*(?<frontmatter>[\s\S]*?)\s*---(?<body>[\s\S]*)/, | ||
) | ||
if (!match?.groups) { | ||
return | ||
} | ||
|
||
const { frontmatter, body } = match.groups | ||
const meta = yaml.load(frontmatter) | ||
const data = { description: body.trim() } | ||
const raw = typeof meta === 'object' ? { ...meta, ...data } : data | ||
|
||
return schema.safeParse(raw) | ||
} |
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 |
---|---|---|
|
@@ -21,4 +21,4 @@ export type SerializedTheorem = { | |
then: Formula<number> | ||
description: string | ||
refs: Ref[] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"] | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"amodio.tsl-problem-matcher", | ||
"ms-vscode.extension-test-runner" | ||
] | ||
} |
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 was deleted.
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
Oops, something went wrong.