Skip to content

Commit

Permalink
Refactor to use Markdown as identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 27, 2023
1 parent 4346276 commit abb9a69
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* @typedef {import('./lib/index.js').Options} Options
*/

export {ReactMarkdown as default, uriTransformer} from './lib/index.js'
export {Markdown as default, uriTransformer} from './lib/index.js'
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const deprecated = {
* @returns {JSX.Element}
* React element.
*/
export function ReactMarkdown(options) {
export function Markdown(options) {
const allowedElements = options.allowedElements
const allowElement = options.allowElement
const children = options.children || ''
Expand Down Expand Up @@ -299,7 +299,7 @@ export function ReactMarkdown(options) {
}
}

ReactMarkdown.propTypes = {
Markdown.propTypes = {
// Core options:
children: PropTypes.string,
// Layout options:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"xo": "^0.56.0"
},
"scripts": {
"build": "tsc --build --clean && tsc --build && type-coverage && esbuild index.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=ReactMarkdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.ReactMarkdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return ReactMarkdown;})));\"",
"build": "tsc --build --clean && tsc --build && type-coverage && esbuild index.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=Markdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.Markdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return Markdown;})));\"",
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix",
"prepack": "npm run build && npm run format",
"test": "npm run build && npm run format && npm run test-coverage",
Expand Down
38 changes: 19 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ npm install react-markdown
In Deno with [`esm.sh`][esmsh]:

```js
import ReactMarkdown from 'https://esm.sh/react-markdown@7'
import Markdown from 'https://esm.sh/react-markdown@7'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
import ReactMarkdown from 'https://esm.sh/react-markdown@7?bundle'
import Markdown from 'https://esm.sh/react-markdown@7?bundle'
</script>
```

Expand All @@ -113,10 +113,10 @@ A basic hello world:

```jsx
import React from 'react'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import ReactDom from 'react-dom'

ReactDom.render(<ReactMarkdown># Hello, *world*!</ReactMarkdown>, document.body)
ReactDom.render(<Markdown># Hello, *world*!</Markdown>, document.body)
```

<details>
Expand All @@ -137,13 +137,13 @@ tables, tasklists and URLs directly):
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'

const markdown = `Just a link: https://reactjs.com.`

ReactDom.render(
<ReactMarkdown children={markdown} remarkPlugins={[remarkGfm]} />,
<Markdown children={markdown} remarkPlugins={[remarkGfm]} />,
document.body
)
```
Expand All @@ -163,7 +163,7 @@ ReactDom.render(

This package exports the following identifier:
[`uriTransformer`][uri-transformer].
The default export is `ReactMarkdown`.
The default export is `Markdown`.

### `props`

Expand Down Expand Up @@ -221,7 +221,7 @@ tasklists and URLs directly:

```jsx
import React from 'react'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import ReactDom from 'react-dom'
import remarkGfm from 'remark-gfm'

Expand All @@ -240,7 +240,7 @@ A table:
`

ReactDom.render(
<ReactMarkdown children={markdown} remarkPlugins={[remarkGfm]} />,
<Markdown children={markdown} remarkPlugins={[remarkGfm]} />,
document.body
)
```
Expand Down Expand Up @@ -291,14 +291,14 @@ second.

```jsx
import React from 'react'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import ReactDom from 'react-dom'
import remarkGfm from 'remark-gfm'

ReactDom.render(
<ReactMarkdown remarkPlugins={[[remarkGfm, {singleTilde: false}]]}>
<Markdown remarkPlugins={[[remarkGfm, {singleTilde: false}]]}>
This ~is not~ strikethrough, but ~~this is~~!
</ReactMarkdown>,
</Markdown>,
document.body
)
```
Expand All @@ -325,7 +325,7 @@ In this case, we apply syntax highlighting with the seriously super amazing
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'
import {dark} from 'react-syntax-highlighter/dist/esm/styles/prism'

Expand All @@ -338,7 +338,7 @@ console.log('It works!')
`

ReactDom.render(
<ReactMarkdown
<Markdown
children={markdown}
components={{
code(props) {
Expand Down Expand Up @@ -387,14 +387,14 @@ is used to support math in markdown, and a transform plugin
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'

import 'katex/dist/katex.min.css' // `rehype-katex` does not import the CSS for you

ReactDom.render(
<ReactMarkdown
<Markdown
children={`The lift coefficient ($C_L$) is a dimensionless coefficient.`}
remarkPlugins={[remarkMath]}
rehypePlugins={[rehypeKatex]}
Expand Down Expand Up @@ -506,7 +506,7 @@ can spare the bundle size (±60kb minzipped), then you can use
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import rehypeRaw from 'rehype-raw'

const input = `<div class="note">
Expand All @@ -516,7 +516,7 @@ Some *emphasis* and <strong>strong</strong>!
</div>`

ReactDom.render(
<ReactMarkdown rehypePlugins={[rehypeRaw]} children={input} />,
<Markdown rehypePlugins={[rehypeRaw]} children={input} />,
document.body
)
```
Expand All @@ -542,7 +542,7 @@ markdown!
You can also change the things that come from markdown:

```jsx
<ReactMarkdown
<Markdown
children="*hi*"
components={{
// Map `h1` (`# heading`) to use `h2`s.
Expand Down

0 comments on commit abb9a69

Please sign in to comment.