-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add sandboxes to repo #6
Changes from all commits
d0c12e0
509ccb7
2443f29
7356c0f
f35e86d
152e8f7
cb9269e
f72c93f
c4bda0d
2bf73b8
e897055
9eccb88
8e0febb
2632eaa
57dee0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.md | ||
*.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,48 @@ | |
"contributors": [ | ||
"Titus Wormer <[email protected]> (wooorm.com)" | ||
], | ||
"workspaces": [ | ||
"sandbox-templates/react-markdown-with-create-react-app", | ||
"sandbox-templates/remark-rehype-with-parcel", | ||
"sandbox-templates/remark-with-parcel" | ||
], | ||
"devDependencies": { | ||
"eslint-config-xo-react": "^0.25.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-frontmatter": "^4.0.0", | ||
"remark-preset-wooorm": "^9.0.0" | ||
"remark-preset-wooorm": "^9.0.0", | ||
"xo": "^0.46.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test": "npm run format" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"extends": "xo-react", | ||
"prettier": true, | ||
"env": [ | ||
"browser" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"sandbox-templates/**/*.tsx" | ||
], | ||
"rules": { | ||
"@typescript-eslint/naming-convention": "off" | ||
} | ||
} | ||
] | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"frontmatter", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"startCommand": "npm start" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "react-markdown-with-create-react-app", | ||
"version": "1.0.0", | ||
"private": true, | ||
"main": "src/index.tsx", | ||
"dependencies": { | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"react-markdown": "7.1.0", | ||
"react-scripts": "4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "17.0.36", | ||
"@types/react-dom": "17.0.11", | ||
"typescript": "4.4.4" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>react-markdown + CRA</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"startScript": "start" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ⚠️ Important! Please make sure the dependencies are up to date. | ||
// On code sandbox, you can refresh them in the Dependencies section (left-bottom) | ||
// On stackblitz, you can open the package.json file, update the versions, | ||
// then run npm install in the stackblitz terminal | ||
|
||
import React from 'react' | ||
import Markdown from 'react-markdown' | ||
|
||
const markdownSource = ` | ||
# heading | ||
|
||
* list | ||
* items | ||
|
||
\`\`\`js | ||
function () {} | ||
\`\`\` | ||
` | ||
|
||
const App = () => <Markdown>{markdownSource}</Markdown> | ||
|
||
export default App |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, {StrictMode} from 'react' | ||
import * as ReactDOM from 'react-dom' | ||
|
||
import App from './app' | ||
|
||
const rootElement = document.querySelector('#root') | ||
|
||
ReactDOM.render( | ||
<StrictMode> | ||
<App /> | ||
</StrictMode>, | ||
rootElement | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"startCommand": "npm start" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>remark-rehype + Parcel demo</title> | ||
<meta charset="utf-8"> | ||
</head> | ||
|
||
<body> | ||
<h1><code>remark-rehype</code> with Parcel</h1> | ||
<h2>source</h2> | ||
ChristianMurphy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<pre id="source"></pre> | ||
<h2>result</h2> | ||
<iframe id="result"></iframe> | ||
<h2>error</h2> | ||
<pre id="error">none</pre> | ||
|
||
<script src="src/index.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "remark-rehype-with-parcel", | ||
"version": "1.0.0", | ||
"private": true, | ||
"main": "index.html", | ||
"scripts": { | ||
"start": "parcel index.html --open", | ||
"build": "parcel build index.html" | ||
}, | ||
"dependencies": { | ||
"rehype-stringify": "9.0.2", | ||
"remark-parse": "10.0.1", | ||
"remark-rehype": "10.0.1", | ||
"unified": "10.1.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.16.0", | ||
"parcel-bundler": "1.12.5" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"startScript": "start" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
// ⚠️ Important! Please make sure the dependencies are up to date. | ||||||||||||||||||||||||||||||||||||||||||||||||||
// On code sandbox, you can refresh them in the Dependencies section (left-bottom) | ||||||||||||||||||||||||||||||||||||||||||||||||||
// On stackblitz, you can open the package.json file, update the versions, | ||||||||||||||||||||||||||||||||||||||||||||||||||
// then run npm install in the stackblitz terminal | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
import {unified} from 'unified' | ||||||||||||||||||||||||||||||||||||||||||||||||||
import remarkParse from 'remark-parse' | ||||||||||||||||||||||||||||||||||||||||||||||||||
import remarkRehype from 'remark-rehype' | ||||||||||||||||||||||||||||||||||||||||||||||||||
import rehypeStringify from 'rehype-stringify' | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
const sourceMarkdown = ` | ||||||||||||||||||||||||||||||||||||||||||||||||||
# heading | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
* list | ||||||||||||||||||||||||||||||||||||||||||||||||||
* item | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
\`\`\`js | ||||||||||||||||||||||||||||||||||||||||||||||||||
function () {} | ||||||||||||||||||||||||||||||||||||||||||||||||||
\`\`\` | ||||||||||||||||||||||||||||||||||||||||||||||||||
` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
async function main() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
document.querySelector('#source').textContent = sourceMarkdown | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
const file = await unified() | ||||||||||||||||||||||||||||||||||||||||||||||||||
.use(remarkParse) | ||||||||||||||||||||||||||||||||||||||||||||||||||
// Add any remark plugins here | ||||||||||||||||||||||||||||||||||||||||||||||||||
.use(remarkRehype) | ||||||||||||||||||||||||||||||||||||||||||||||||||
// Add any rehype plugins here | ||||||||||||||||||||||||||||||||||||||||||||||||||
.use(rehypeStringify) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.process(sourceMarkdown) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
document.querySelector('#result').contentWindow.document.body.innerHTML = | ||||||||||||||||||||||||||||||||||||||||||||||||||
String(file) | ||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
document.querySelector('#error').textContent = error | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+25
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷♂️ |
||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
main() | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main itself has a try catch block for error catching. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function body is currently wrapped in a try/catch. I’m assuming that people are going to change the function body and introduce errors outside the try/catch, resulting in uncaught exceptions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"startCommand": "npm start" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>remark + Parcel demo</title> | ||
<meta charset="utf-8" /> | ||
</head> | ||
|
||
<body> | ||
<h1><code>remark</code> with Parcel</h1> | ||
<h2>source</h2> | ||
ChristianMurphy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<pre id="source"></pre> | ||
<h2>result</h2> | ||
<pre id="result"></pre> | ||
<h2>error</h2> | ||
<pre id="error">none</pre> | ||
|
||
<script src="src/index.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "remark-with-parcel", | ||
"version": "1.0.0", | ||
"private": true, | ||
"main": "index.html", | ||
"scripts": { | ||
"start": "parcel index.html --open", | ||
"build": "parcel build index.html" | ||
}, | ||
"dependencies": { | ||
"remark": "14.0.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.16.0", | ||
"parcel-bundler": "1.12.5" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"startScript": "start" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// ⚠️ Important! Please make sure the dependencies are up to date. | ||
// On code sandbox, you can refresh them in the Dependencies section (left-bottom) | ||
// On stackblitz, you can open the package.json file, update the versions, | ||
// then run npm install in the stackblitz terminal | ||
|
||
import {remark} from 'remark' | ||
|
||
const sourceMarkdown = ` | ||
# heading | ||
|
||
* list | ||
* item | ||
|
||
\`\`\`js | ||
function () {} | ||
\`\`\` | ||
` | ||
|
||
async function main() { | ||
document.querySelector('#source').textContent = sourceMarkdown | ||
|
||
try { | ||
const file = await remark() | ||
// .use remark plugins here | ||
.process(sourceMarkdown) | ||
|
||
document.querySelector('#result').textContent = String(file) | ||
} catch (error) { | ||
document.querySelector('#error').textContent = error | ||
} | ||
} | ||
|
||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temporary links until merged