-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from siefkenj/md
Markdown and Vite Support
- Loading branch information
Showing
15 changed files
with
4,836 additions
and
17,073 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
# production | ||
/build | ||
/dist | ||
|
||
# misc | ||
.DS_Store | ||
|
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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
.minipage { | ||
text-align: left; | ||
} | ||
|
||
.section-paragraph { | ||
font-size: unset; | ||
margin-bottom: 0; | ||
margin-top: unset; | ||
} | ||
.section-paragraph ~ p { | ||
margin-top: .3em; | ||
} | ||
|
||
.phantom { | ||
visibility: hidden; | ||
} | ||
|
||
.environment.example { | ||
border-left: 5px solid rgb(0, 0, 200); | ||
background-color: rgba(0,0,0,.05); | ||
padding-left: 5px; | ||
} | ||
|
||
.environment.theorem { | ||
border-left: 5px solid rgb(100, 0, 200); | ||
background-color: rgba(0,0,0,.05); | ||
padding-left: 5px; | ||
} |
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,69 @@ | ||
import React from "react"; | ||
import "katex/dist/katex.min.css"; | ||
import ReactSplitPane from "react-split-pane"; | ||
|
||
import { useCodeMirror } from "@uiw/react-codemirror"; | ||
import { html } from "@codemirror/lang-html"; | ||
import { markdown } from "@codemirror/lang-markdown"; | ||
import { useStoreState } from "../store/hooks"; | ||
import { toMarkdown } from "mdast-util-to-markdown"; | ||
import Markdown from "react-markdown"; | ||
import rehypeKatex from "rehype-katex"; | ||
import remarkMath from "remark-math"; | ||
import remarkGfm from "remark-gfm"; | ||
import type * as Mdast from "mdast"; | ||
|
||
export function MarkdownSourceDisplay() { | ||
const editorRef = React.useRef<HTMLDivElement>(null); | ||
const markdownInput = useStoreState((state) => state.markdown); | ||
const formattedMarkdown = markdownInput; | ||
|
||
useCodeMirror({ | ||
container: editorRef.current, | ||
value: formattedMarkdown, | ||
extensions: [markdown()], | ||
readOnly: true, | ||
height: "100%", | ||
basicSetup: { | ||
lineNumbers: false, | ||
foldGutter: true, | ||
highlightActiveLine: false, | ||
}, | ||
}); | ||
|
||
return ( | ||
<div | ||
style={{ flex: "1 1 auto", height: "100%", width: "100%" }} | ||
ref={editorRef} | ||
/> | ||
); | ||
} | ||
|
||
/** | ||
* Wrapper around ReactSplitPlane so that typescript stops complaining. | ||
*/ | ||
function SplitPane({ children, ...rest }: React.PropsWithChildren<any>) { | ||
return <ReactSplitPane {...rest}>{children}</ReactSplitPane>; | ||
} | ||
|
||
function RenderedMarkdown({ source }: { source: string }) { | ||
return ( | ||
<Markdown | ||
remarkPlugins={[remarkMath]} | ||
rehypePlugins={[rehypeKatex, remarkGfm]} | ||
> | ||
{source} | ||
</Markdown> | ||
); | ||
} | ||
|
||
export function MarkdownView({ mdast, ...rest }: { mdast: string }) { | ||
return ( | ||
<SplitPane split="horizontal" defaultSize="50%"> | ||
<div className="code-container"> | ||
<MarkdownSourceDisplay /> | ||
</div> | ||
<RenderedMarkdown source={mdast} /> | ||
</SplitPane> | ||
); | ||
} |
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.