-
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(vscode): share body parsing and external ref logic with core (#160)
* feat: initial working vscode web extension * chore: update sveltekit and vite This fixes the underlying issue that required a `skipLibCheck` in the first place. * refactor: fold shared logic back in to core package * fix: correct link in markdown hover preview * fix: hover markdown links in codespaces * docs: brain dump next steps * chore: fix build-time warnings * refactor: push Ref logic down to core * chore: clean up imports * refactor: simplify citation rendering defining it as a function means we can simplify the reactivity * refactor: push SerializedTheorem down to core * 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
74becb7
commit fe47feb
Showing
68 changed files
with
8,962 additions
and
3,460 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
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 |
---|---|---|
|
@@ -2,3 +2,6 @@ coverage/ | |
dist/ | ||
node_modules/ | ||
data/ | ||
out | ||
.vscode-test/ | ||
*.vsix |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Pinned here and in devcontainer to avoid OOM issues stemming from | ||
# https://github.com/TypeStrong/ts-node/issues/1995 | ||
nodejs 20.11.0 | ||
nodejs 20.14.0 |
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,12 @@ | ||
#!/bin/bash | ||
set -exo pipefail | ||
|
||
# VSCode extensions can only use CommonJS modules (for now), but we want to | ||
# continue using our standard Vite/ESM build process elsewhere. This builds | ||
# both versions, corresponding to `package.json`'s `exports` field. | ||
|
||
tsc --module es2022 --outDir dist/esm/ | ||
echo '{"type": "module"}' > dist/esm/package.json | ||
|
||
tsc --module commonjs --outDir dist/cjs/ | ||
echo '{"type": "commonjs"}' > dist/cjs/package.json |
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 |
---|---|---|
|
@@ -14,23 +14,27 @@ | |
}, | ||
"license": "MIT", | ||
"author": "James Dabbs <[email protected]> (https://jdabbs.com)", | ||
"main": "./dist/esm/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"exports": { | ||
"types": "./dist/types/index.d.ts", | ||
"require": "./dist/cjs/index.js", | ||
"import": "./dist/esm/index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/pi-base/web.git" | ||
}, | ||
"scripts": { | ||
"build:peg": "peggy --plugin ./node_modules/ts-pegjs/dist/tspegjs -o src/Formula/Grammar.ts --cache src/Formula/Grammar.pegjs", | ||
"build": "pnpm build:peg && tsc", | ||
"build": "pnpm build:peg && ./bin/build", | ||
"dev": "pnpm build:peg && tsc --watch", | ||
"test": "vitest run", | ||
"test:cov": "vitest run --coverage", | ||
"test:watch": "vitest" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.3.4", | ||
"micromark-util-types": "1.0.2", | ||
"js-yaml": "^4.1.0", | ||
"rehype-katex": "^6.0.3", | ||
"rehype-stringify": "^9.0.4", | ||
"remark": "^14.0.3", | ||
|
@@ -40,15 +44,17 @@ | |
"unified": "^10.1.2", | ||
"unist-util-is": "^5.2.1", | ||
"unist-util-visit": "^4.1.2", | ||
"zod": "^3.22.4" | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.12", | ||
"@types/hast": "^2.3.9", | ||
"@types/js-yaml": "^4.0.9", | ||
"@types/mdast": "^3.0.15", | ||
"@types/unist": "^2.0.10", | ||
"hast-util-to-html": "^8.0.4", | ||
"mdast-util-from-markdown": "1.3.0", | ||
"micromark-util-types": "1.0.2", | ||
"peggy": "^3.0.2", | ||
"ts-pegjs": "^4.2.1" | ||
} | ||
|
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
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
Oops, something went wrong.