Skip to content
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

feat: add remark gfm plugin #641

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"react-stately": "3.29.1",
"react-use-measure": "2.1.1",
"rehype-raw": "7.0.0",
"remark-gfm": "4.0.0",
"resize-observer-polyfill": "1.5.1",
"styled-container-query": "1.3.5",
"type-fest": "4.8.3",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Children, useMemo } from 'react'
import { Div } from 'honorable'
import { Children, useMemo } from 'react'
import ReactMarkdown from 'react-markdown'
import rehypeRaw from 'rehype-raw'
import remarkGfm from 'remark-gfm'
import styled, { useTheme } from 'styled-components'

import { isExternalUrl, removeTrailingSlashes } from '../utils/urls'
Expand Down Expand Up @@ -232,6 +233,7 @@ function Markdown({ text, gitUrl, mainBranch }: MarkdownProps) {
() => (
<ReactMarkdown
rehypePlugins={[rehypeRaw]}
remarkPlugins={[remarkGfm]}
components={{
blockquote: render({ component: MdBlockquote }),
ul: render({ component: MdUl }),
Expand Down
3 changes: 2 additions & 1 deletion src/stories/Markdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ console.info(sum(num1, num2));
\`\`\`

###### Links
https://google.com
[Absolute url](https://google.com)
[Absolute url - no protocol](//google.com)
[Relative url – Console Readme](README.md)
[Root relative url – Console Security](/SECURITY.md)
[Root relative url – Console Security](/SECURITY.md)

___

Expand Down
222 changes: 222 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3119,6 +3119,7 @@ __metadata:
react-transition-group: 4.4.5
react-use-measure: 2.1.1
rehype-raw: 7.0.0
remark-gfm: 4.0.0
resize-observer-polyfill: 1.5.1
rimraf: 5.0.5
storybook: 7.6.5
Expand Down Expand Up @@ -10802,6 +10803,13 @@ __metadata:
languageName: node
linkType: hard

"escape-string-regexp@npm:^5.0.0":
version: 5.0.0
resolution: "escape-string-regexp@npm:5.0.0"
checksum: 20daabe197f3cb198ec28546deebcf24b3dbb1a5a269184381b3116d12f0532e06007f4bc8da25669d6a7f8efb68db0758df4cd981f57bc5b57f521a3e12c59e
languageName: node
linkType: hard

"escodegen@npm:^1.13.0, escodegen@npm:^1.8.1":
version: 1.14.3
resolution: "escodegen@npm:1.14.3"
Expand Down Expand Up @@ -15007,6 +15015,13 @@ __metadata:
languageName: node
linkType: hard

"markdown-table@npm:^3.0.0":
version: 3.0.3
resolution: "markdown-table@npm:3.0.3"
checksum: 8fcd3d9018311120fbb97115987f8b1665a603f3134c93fbecc5d1463380c8036f789e2a62c19432058829e594fff8db9ff81c88f83690b2f8ed6c074f8d9e10
languageName: node
linkType: hard

"markdown-to-jsx@npm:^7.1.8":
version: 7.4.7
resolution: "markdown-to-jsx@npm:7.4.7"
Expand Down Expand Up @@ -15050,6 +15065,18 @@ __metadata:
languageName: node
linkType: hard

"mdast-util-find-and-replace@npm:^3.0.0":
version: 3.0.1
resolution: "mdast-util-find-and-replace@npm:3.0.1"
dependencies:
"@types/mdast": ^4.0.0
escape-string-regexp: ^5.0.0
unist-util-is: ^6.0.0
unist-util-visit-parents: ^6.0.0
checksum: 05d5c4ff02e31db2f8a685a13bcb6c3f44e040bd9dfa54c19a232af8de5268334c8755d79cb456ed4cced1300c4fb83e88444c7ae8ee9ff16869a580f29d08cd
languageName: node
linkType: hard

"mdast-util-from-markdown@npm:^2.0.0":
version: 2.0.1
resolution: "mdast-util-from-markdown@npm:2.0.1"
Expand All @@ -15070,6 +15097,83 @@ __metadata:
languageName: node
linkType: hard

"mdast-util-gfm-autolink-literal@npm:^2.0.0":
version: 2.0.1
resolution: "mdast-util-gfm-autolink-literal@npm:2.0.1"
dependencies:
"@types/mdast": ^4.0.0
ccount: ^2.0.0
devlop: ^1.0.0
mdast-util-find-and-replace: ^3.0.0
micromark-util-character: ^2.0.0
checksum: 5630b12e072d7004cb132231c94f667fb5813486779cb0dfb0a196d7ae0e048897a43b0b37e080017adda618ddfcbea1d7bf23c0fa31c87bfc683e0898ea1cfe
languageName: node
linkType: hard

"mdast-util-gfm-footnote@npm:^2.0.0":
version: 2.0.0
resolution: "mdast-util-gfm-footnote@npm:2.0.0"
dependencies:
"@types/mdast": ^4.0.0
devlop: ^1.1.0
mdast-util-from-markdown: ^2.0.0
mdast-util-to-markdown: ^2.0.0
micromark-util-normalize-identifier: ^2.0.0
checksum: 45d26b40e7a093712e023105791129d76e164e2168d5268e113298a22de30c018162683fb7893cdc04ab246dac0087eed708b2a136d1d18ed2b32b3e0cae4a79
languageName: node
linkType: hard

"mdast-util-gfm-strikethrough@npm:^2.0.0":
version: 2.0.0
resolution: "mdast-util-gfm-strikethrough@npm:2.0.0"
dependencies:
"@types/mdast": ^4.0.0
mdast-util-from-markdown: ^2.0.0
mdast-util-to-markdown: ^2.0.0
checksum: fe9b1d0eba9b791ff9001c008744eafe3dd7a81b085f2bf521595ce4a8e8b1b44764ad9361761ad4533af3e5d913d8ad053abec38172031d9ee32a8ebd1c7dbd
languageName: node
linkType: hard

"mdast-util-gfm-table@npm:^2.0.0":
version: 2.0.0
resolution: "mdast-util-gfm-table@npm:2.0.0"
dependencies:
"@types/mdast": ^4.0.0
devlop: ^1.0.0
markdown-table: ^3.0.0
mdast-util-from-markdown: ^2.0.0
mdast-util-to-markdown: ^2.0.0
checksum: 063a627fd0993548fd63ca0c24c437baf91ba7d51d0a38820bd459bc20bf3d13d7365ef8d28dca99176dd5eb26058f7dde51190479c186dfe6af2e11202957c9
languageName: node
linkType: hard

"mdast-util-gfm-task-list-item@npm:^2.0.0":
version: 2.0.0
resolution: "mdast-util-gfm-task-list-item@npm:2.0.0"
dependencies:
"@types/mdast": ^4.0.0
devlop: ^1.0.0
mdast-util-from-markdown: ^2.0.0
mdast-util-to-markdown: ^2.0.0
checksum: 37db90c59b15330fc54d790404abf5ef9f2f83e8961c53666fe7de4aab8dd5e6b3c296b6be19797456711a89a27840291d8871ff0438e9b4e15c89d170efe072
languageName: node
linkType: hard

"mdast-util-gfm@npm:^3.0.0":
version: 3.0.0
resolution: "mdast-util-gfm@npm:3.0.0"
dependencies:
mdast-util-from-markdown: ^2.0.0
mdast-util-gfm-autolink-literal: ^2.0.0
mdast-util-gfm-footnote: ^2.0.0
mdast-util-gfm-strikethrough: ^2.0.0
mdast-util-gfm-table: ^2.0.0
mdast-util-gfm-task-list-item: ^2.0.0
mdast-util-to-markdown: ^2.0.0
checksum: 62039d2f682ae3821ea1c999454863d31faf94d67eb9b746589c7e136076d7fb35fabc67e02f025c7c26fd7919331a0ee1aabfae24f565d9a6a9ebab3371c626
languageName: node
linkType: hard

"mdast-util-mdx-expression@npm:^2.0.0":
version: 2.0.0
resolution: "mdast-util-mdx-expression@npm:2.0.0"
Expand Down Expand Up @@ -15267,6 +15371,99 @@ __metadata:
languageName: node
linkType: hard

"micromark-extension-gfm-autolink-literal@npm:^2.0.0":
version: 2.1.0
resolution: "micromark-extension-gfm-autolink-literal@npm:2.1.0"
dependencies:
micromark-util-character: ^2.0.0
micromark-util-sanitize-uri: ^2.0.0
micromark-util-symbol: ^2.0.0
micromark-util-types: ^2.0.0
checksum: e00a570c70c837b9cbbe94b2c23b787f44e781cd19b72f1828e3453abca2a9fb600fa539cdc75229fa3919db384491063645086e02249481e6ff3ec2c18f767c
languageName: node
linkType: hard

"micromark-extension-gfm-footnote@npm:^2.0.0":
version: 2.1.0
resolution: "micromark-extension-gfm-footnote@npm:2.1.0"
dependencies:
devlop: ^1.0.0
micromark-core-commonmark: ^2.0.0
micromark-factory-space: ^2.0.0
micromark-util-character: ^2.0.0
micromark-util-normalize-identifier: ^2.0.0
micromark-util-sanitize-uri: ^2.0.0
micromark-util-symbol: ^2.0.0
micromark-util-types: ^2.0.0
checksum: ac6fb039e98395d37b71ebff7c7a249aef52678b5cf554c89c4f716111d4be62ef99a5d715a5bd5d68fa549778c977d85cb671d1d8506dc8a3a1b46e867ae52f
languageName: node
linkType: hard

"micromark-extension-gfm-strikethrough@npm:^2.0.0":
version: 2.1.0
resolution: "micromark-extension-gfm-strikethrough@npm:2.1.0"
dependencies:
devlop: ^1.0.0
micromark-util-chunked: ^2.0.0
micromark-util-classify-character: ^2.0.0
micromark-util-resolve-all: ^2.0.0
micromark-util-symbol: ^2.0.0
micromark-util-types: ^2.0.0
checksum: cdb7a38dd6eefb6ceb6792a44a6796b10f951e8e3e45b8579f599f43e7ae26ccd048c0aa7e441b3c29dd0c54656944fe6eb0098de2bc4b5106fbc0a42e9e016c
languageName: node
linkType: hard

"micromark-extension-gfm-table@npm:^2.0.0":
version: 2.1.0
resolution: "micromark-extension-gfm-table@npm:2.1.0"
dependencies:
devlop: ^1.0.0
micromark-factory-space: ^2.0.0
micromark-util-character: ^2.0.0
micromark-util-symbol: ^2.0.0
micromark-util-types: ^2.0.0
checksum: 249d695f5f8bd222a0d8a774ec78ea2a2d624cb50a4d008092a54aa87dad1f9d540e151d29696cf849eb1cee380113c4df722aebb3b425a214832a2de5dea1d7
languageName: node
linkType: hard

"micromark-extension-gfm-tagfilter@npm:^2.0.0":
version: 2.0.0
resolution: "micromark-extension-gfm-tagfilter@npm:2.0.0"
dependencies:
micromark-util-types: ^2.0.0
checksum: cf21552f4a63592bfd6c96ae5d64a5f22bda4e77814e3f0501bfe80e7a49378ad140f827007f36044666f176b3a0d5fea7c2e8e7973ce4b4579b77789f01ae95
languageName: node
linkType: hard

"micromark-extension-gfm-task-list-item@npm:^2.0.0":
version: 2.1.0
resolution: "micromark-extension-gfm-task-list-item@npm:2.1.0"
dependencies:
devlop: ^1.0.0
micromark-factory-space: ^2.0.0
micromark-util-character: ^2.0.0
micromark-util-symbol: ^2.0.0
micromark-util-types: ^2.0.0
checksum: b1ad86a4e9d68d9ad536d94fb25a5182acbc85cc79318f4a6316034342f6a71d67983cc13f12911d0290fd09b2bda43cdabe8781a2d9cca2ebe0d421e8b2b8a4
languageName: node
linkType: hard

"micromark-extension-gfm@npm:^3.0.0":
version: 3.0.0
resolution: "micromark-extension-gfm@npm:3.0.0"
dependencies:
micromark-extension-gfm-autolink-literal: ^2.0.0
micromark-extension-gfm-footnote: ^2.0.0
micromark-extension-gfm-strikethrough: ^2.0.0
micromark-extension-gfm-table: ^2.0.0
micromark-extension-gfm-tagfilter: ^2.0.0
micromark-extension-gfm-task-list-item: ^2.0.0
micromark-util-combine-extensions: ^2.0.0
micromark-util-types: ^2.0.0
checksum: 2060fa62666a09532d6b3a272d413bc1b25bbb262f921d7402795ac021e1362c8913727e33d7528d5b4ccaf26922ec51208c43f795a702964817bc986de886c9
languageName: node
linkType: hard

"micromark-factory-destination@npm:^2.0.0":
version: 2.0.0
resolution: "micromark-factory-destination@npm:2.0.0"
Expand Down Expand Up @@ -17947,6 +18144,20 @@ __metadata:
languageName: node
linkType: hard

"remark-gfm@npm:4.0.0":
version: 4.0.0
resolution: "remark-gfm@npm:4.0.0"
dependencies:
"@types/mdast": ^4.0.0
mdast-util-gfm: ^3.0.0
micromark-extension-gfm: ^3.0.0
remark-parse: ^11.0.0
remark-stringify: ^11.0.0
unified: ^11.0.0
checksum: 84bea84e388061fbbb697b4b666089f5c328aa04d19dc544c229b607446bc10902e46b67b9594415a1017bbbd7c811c1f0c30d36682c6d1a6718b66a1558261b
languageName: node
linkType: hard

"remark-parse@npm:^11.0.0":
version: 11.0.0
resolution: "remark-parse@npm:11.0.0"
Expand Down Expand Up @@ -17983,6 +18194,17 @@ __metadata:
languageName: node
linkType: hard

"remark-stringify@npm:^11.0.0":
version: 11.0.0
resolution: "remark-stringify@npm:11.0.0"
dependencies:
"@types/mdast": ^4.0.0
mdast-util-to-markdown: ^2.0.0
unified: ^11.0.0
checksum: 59e07460eb629d6c3b3c0f438b0b236e7e6858fd5ab770303078f5a556ec00354d9c7fb9ef6d5f745a4617ac7da1ab618b170fbb4dac120e183fecd9cc86bce6
languageName: node
linkType: hard

"remove-accents@npm:0.4.2":
version: 0.4.2
resolution: "remove-accents@npm:0.4.2"
Expand Down
Loading