-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d46c5d
commit 17872a8
Showing
17 changed files
with
4,580 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,2 +1,30 @@ | ||
# use-markdown | ||
React hook for converting Markdown to HTML | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
project: ["./tsconfig.json", "./tsconfig.node.json"], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}; | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
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,38 @@ | ||
import { build } from "vite"; | ||
import pkg from "./package.json" assert { type: "json" }; | ||
|
||
(async () => { | ||
await build({ | ||
build: { | ||
outDir: `dist`, | ||
sourcemap: true, | ||
lib: { | ||
name: "use-markdown", | ||
entry: "./src/use-markdown.tsx", | ||
fileName: "use-markdown", | ||
}, | ||
minify: "esbuild", | ||
rollupOptions: { | ||
external: [ | ||
...Object.keys(pkg.dependencies || {}), | ||
...Object.keys(pkg.peerDependencies || {}), | ||
], | ||
output: { | ||
globals: { | ||
react: "React", | ||
"react-dom": "ReactDOM", | ||
"rehype-raw": "rehypeRaw", | ||
"rehype-stringify": "rehypeStringify", | ||
"remark-gfm": "remarkGfm", | ||
"remark-parse": "remarkParse", | ||
"remark-rehype": "remarkRehype", | ||
unified: "unified", | ||
}, | ||
exports: "named", | ||
inlineDynamicImports: true, | ||
}, | ||
treeshake: true, | ||
}, | ||
}, | ||
}); | ||
})(); |
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,75 @@ | ||
export const sample = `# Sample GitHub Flavored Markdown Document | ||
## Introduction | ||
This document is a demonstration of GitHub flavored Markdown which includes various elements like headers, lists, code blocks, and more. | ||
## Basix Formatting | ||
This is a **bold** text. | ||
This is an *italic* text. | ||
This is a \`code\` text. | ||
This is a ~~strikethrough~~ text. | ||
## Code Blocks | ||
Syntax highlighting is a feature of GitHub flavored Markdown that allows you to add color to your code: | ||
\`\`\`python | ||
def hello_world(): | ||
print("Hello, world!") | ||
\`\`\` | ||
## Lists | ||
### Unordered List | ||
- Item 1 | ||
- Item 2 | ||
- Subitem 2.1 | ||
- Subitem 2.2 | ||
### Ordered List | ||
1. First item | ||
2. Second item | ||
1. Subitem 2.1 | ||
2. Subitem 2.2 | ||
## Tables | ||
| Syntax | Description | | ||
| --------- | ----------- | | ||
| Header | Title | | ||
| Paragraph | Text | | ||
## Footnotes | ||
You can create footnotes like this[^1]. | ||
[^1]: This is a footnote. | ||
## Task List | ||
- [x] Task 1 | ||
- [ ] Task 2 | ||
- [ ] Task 3 | ||
## Links and Images | ||
[Dog](https://en.wikipedia.org/wiki/Dog) | ||
![Dog](https://upload.wikimedia.org/wikipedia/commons/a/af/Golden_retriever_eating_pigs_foot.jpg) | ||
## Blockquotes | ||
> Blockquotes can also be nested. | ||
>> Like this. | ||
## Auto Link Literals | ||
http://www.example.com | ||
`; |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>@nulib/use-markdown</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/index.tsx"></script> | ||
</body> | ||
</html> |
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,15 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import { sample } from "./fixtures/markdown"; | ||
import useMarkdown from "./src/use-markdown"; | ||
|
||
const App = () => { | ||
const { jsx } = useMarkdown(sample); | ||
return jsx; | ||
}; | ||
|
||
ReactDOM.createRoot(document.getElementById("root")!).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); |
Oops, something went wrong.