Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: remarkjs/react-markdown
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7.1.0
Choose a base ref
...
head repository: remarkjs/react-markdown
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7.1.1
Choose a head ref
  • 5 commits
  • 7 files changed
  • 1 contributor

Commits on Nov 21, 2021

  1. Update dev-dependencies

    wooorm committed Nov 21, 2021
    Copy the full SHA
    2a1f5b2 View commit details

Commits on Nov 23, 2021

  1. Refactor

    wooorm committed Nov 23, 2021
    Copy the full SHA
    8e07e9c View commit details

Commits on Nov 29, 2021

  1. Add improved docs

    Closes GH-657
    
    Reviewed-by: Merlijn Vos <merlijn@soverin.net>
    wooorm authored Nov 29, 2021
    Copy the full SHA
    4185f06 View commit details
  2. Update dev-dependencies

    wooorm committed Nov 29, 2021
    Copy the full SHA
    8a3060b View commit details
  3. 7.1.1

    wooorm committed Nov 29, 2021
    Copy the full SHA
    9a25ef8 View commit details
Showing with 275 additions and 121 deletions.
  1. +1 −3 index.js
  2. +10 −10 lib/ast-to-react.js
  3. +3 −1 lib/react-markdown.js
  4. +2 −2 lib/rehype-filter.js
  5. +5 −5 package.json
  6. +242 −88 readme.md
  7. +12 −12 test/test.jsx
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@
* @typedef {import('./lib/ast-to-react.js').Components} Components
*/

import {ReactMarkdown} from './lib/react-markdown.js'

export {uriTransformer} from './lib/uri-transformer.js'

export default ReactMarkdown
export {ReactMarkdown as default} from './lib/react-markdown.js'
20 changes: 10 additions & 10 deletions lib/ast-to-react.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
*
* @callback TransformLink
* @param {string} href
* @param {Array.<ElementContent>} children
* @param {Array<ElementContent>} children
* @param {string?} title
* @returns {string}
*
@@ -37,11 +37,11 @@
* @param {string?} title
* @returns {string}
*
* @typedef {import("react").HTMLAttributeAnchorTarget} TransformLinkTargetType
* @typedef {import('react').HTMLAttributeAnchorTarget} TransformLinkTargetType
*
* @callback TransformLinkTarget
* @param {string} href
* @param {Array.<ElementContent>} children
* @param {Array<ElementContent>} children
* @param {string?} title
* @returns {TransformLinkTargetType|undefined}
*
@@ -53,7 +53,7 @@
* @typedef {JSX.IntrinsicElements['h1'] & ReactMarkdownProps & {level: number}} HeadingProps
* @typedef {JSX.IntrinsicElements['li'] & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
* @typedef {JSX.IntrinsicElements['ol'] & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
* @typedef {JSX.IntrinsicElements['table'] & ReactMarkdownProps & {style?: Object.<string, unknown>, isHeader: boolean}} TableCellProps
* @typedef {JSX.IntrinsicElements['table'] & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: boolean}} TableCellProps
* @typedef {JSX.IntrinsicElements['tr'] & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
* @typedef {JSX.IntrinsicElements['ul'] & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
*
@@ -80,7 +80,7 @@
* @property {TableRowComponent|ReactMarkdownNames} tr
* @property {UnorderedListComponent|ReactMarkdownNames} ul
*
* @typedef {Partial<Omit<import("./complex-types").NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
* @typedef {Partial<Omit<import('./complex-types').NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
*
* @typedef Options
* @property {boolean} [sourcePos=false]
@@ -112,7 +112,7 @@ const tableElements = new Set(['table', 'thead', 'tbody', 'tfoot', 'tr'])
* @param {Element|Root} node
*/
export function childrenToReact(context, node) {
/** @type {Array.<ReactNode>} */
/** @type {Array<ReactNode>} */
const children = []
let childIndex = -1
/** @type {Comment|Doctype|Element|Raw|Text} */
@@ -159,7 +159,7 @@ function toReact(context, node, index, parent) {
/** @type {ReactMarkdownNames} */
// @ts-expect-error assume a known HTML/SVG element.
const name = node.tagName
/** @type {Object.<string, unknown>} */
/** @type {Record<string, unknown>} */
const properties = {}
let schema = parentSchema
/** @type {string} */
@@ -355,7 +355,7 @@ function getElementsBeforeCount(parent, node) {
}

/**
* @param {Object.<string, unknown>} props
* @param {Record<string, unknown>} props
* @param {string} prop
* @param {unknown} value
* @param {Context} ctx
@@ -393,10 +393,10 @@ function addProperty(props, prop, value, ctx) {

/**
* @param {string} value
* @returns {Object.<string, string>}
* @returns {Record<string, string>}
*/
function parseStyle(value) {
/** @type {Object.<string, string>} */
/** @type {Record<string, string>} */
const result = {}

try {
4 changes: 3 additions & 1 deletion lib/react-markdown.js
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ const own = {}.hasOwnProperty
const changelog =
'https://github.com/remarkjs/react-markdown/blob/main/changelog.md'

/** @type {Object.<string, Deprecation>} */
/** @type {Record<string, Deprecation>} */
const deprecated = {
renderers: {to: 'components', id: 'change-renderers-to-components'},
astPlugins: {id: 'remove-buggy-html-in-markdown-parser'},
@@ -65,6 +65,8 @@ const deprecated = {
}

/**
* React component to render markdown.
*
* @param {ReactMarkdownOptions} options
* @returns {ReactElement}
*/
4 changes: 2 additions & 2 deletions lib/rehype-filter.js
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@ import {visit} from 'unist-util-visit'
* @returns {boolean|undefined}
*
* @typedef Options
* @property {Array.<string>} [allowedElements]
* @property {Array.<string>} [disallowedElements=[]]
* @property {Array<string>} [allowedElements]
* @property {Array<string>} [disallowedElements=[]]
* @property {AllowElement} [allowElement]
* @property {boolean} [unwrapDisallowed=false]
*/
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-markdown",
"version": "7.1.0",
"description": "Render Markdown as React components",
"version": "7.1.1",
"description": "React component to render markdown",
"license": "MIT",
"keywords": [
"remark",
@@ -103,7 +103,7 @@
"@types/react-dom": "^17.0.0",
"@types/react-is": "^17.0.0",
"c8": "^7.0.0",
"esbuild": "^0.13.0",
"esbuild": "^0.14.0",
"eslint-config-xo-react": "^0.25.0",
"eslint-plugin-es": "^4.0.0",
"eslint-plugin-react": "^7.0.0",
@@ -119,9 +119,9 @@
"remark-toc": "^8.0.0",
"rimraf": "^3.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"typescript": "~4.4.0",
"uvu": "^0.5.0",
"xo": "^0.45.0"
"xo": "^0.47.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
Loading