-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add use remark sync hook #18
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
761d303
feat: add use remark sync hook
ChristianMurphy 71489d7
chore: update package lock file
ChristianMurphy 966bd58
test: improve unit tests for useRemark hook
ChristianMurphy 35585cc
test: useRemarkSync hook
ChristianMurphy cbd6fef
ci: test on node 16
ChristianMurphy 64f450f
ci: check coverage as part of test process
ChristianMurphy d55c5e2
docs: add storybook examples for useRemarkSync
ChristianMurphy ea5a79b
docs: add an example of server side rendering with useRemarkSync
ChristianMurphy 206e25f
docs: correct remark to rehype options example
ChristianMurphy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,5 +2,6 @@ | |
.DS_Store | ||
node_modules | ||
.cache | ||
dist | ||
storybook-static | ||
dist/ | ||
storybook-static/ | ||
coverage/ |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,71 @@ | ||
import { useEffect } from 'react'; | ||
import remarkGfm from 'remark-gfm'; | ||
import remarkMath from 'remark-math'; | ||
import rehypeKatex from 'rehype-katex'; | ||
import rehypeRaw from 'rehype-raw'; | ||
import rehypeSanitize from 'rehype-sanitize'; | ||
import 'katex/dist/katex.min.css'; | ||
|
||
import { useRemarkSync } from '../src'; | ||
|
||
export default { | ||
title: 'Remark Hooks/sync and ssr with useRemarkSync', | ||
component: useRemarkSync, | ||
}; | ||
|
||
export const CommonMark = ({ content }) => { | ||
return useRemarkSync(content); | ||
}; | ||
CommonMark.args = { | ||
content: `# header | ||
|
||
1. ordered | ||
2. list | ||
|
||
* unordered | ||
* list`, | ||
}; | ||
|
||
export const GithubFlavoredMarkdown = ({ content }) => { | ||
return ( | ||
useRemarkSync(content, { | ||
remarkPlugins: [remarkGfm], | ||
}) || <></> | ||
); | ||
}; | ||
GithubFlavoredMarkdown.args = { | ||
content: `# header | ||
|
||
| column 1 | column 2 | | ||
| -------- | -------- | | ||
| first | row | | ||
`, | ||
}; | ||
|
||
export const MarkdownWithMath = ({ content }) => { | ||
return useRemarkSync(content, { | ||
remarkPlugins: [remarkMath], | ||
rehypePlugins: [rehypeKatex], | ||
}); | ||
}; | ||
MarkdownWithMath.args = { | ||
content: `Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following equation. | ||
|
||
$$ | ||
L = \\frac{1}{2} \\rho v^2 S C_L | ||
$$`, | ||
}; | ||
|
||
export const MixedHTMLSanitized = ({ content }) => { | ||
return useRemarkSync(content, { | ||
remarkToRehypeOptions: { allowDangerousHtml: true }, | ||
rehypePlugins: [rehypeRaw, rehypeSanitize], | ||
}); | ||
}; | ||
MixedHTMLSanitized.args = { | ||
content: `# header | ||
|
||
<strong>mixed</strong> | ||
<em>with</em> | ||
<kbd>html</kbd>`, | ||
}; |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.