Skip to content

Commit 377d3ff

Browse files
Markdown Conversion Option One (#205)
* error coming from package? * issue identified * error persists * remove extra spacing * removing from main package.json
1 parent 1eb9c02 commit 377d3ff

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

packages/dev/docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"globals-docs": "^2.4.1",
2121
"react": "^16.8.0",
2222
"react-dom": "^16.8.0",
23-
"react-lowlight": "^2.0.0"
23+
"react-lowlight": "^2.0.0",
24+
"markdown-to-jsx": "^6.11.0"
2425
}
2526
}

packages/dev/docs/src/types.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Asterisk from '@spectrum-icons/workflow/Asterisk';
22
import {getDoc} from 'globals-docs';
33
import Lowlight from 'react-lowlight';
4+
import Markdown from 'markdown-to-jsx';
45
import React, {useContext} from 'react';
56
import styles from './docs.css';
67
import tableStyles from '@adobe/spectrum-css-temp/components/table/vars.css';
@@ -190,6 +191,14 @@ function LinkType({id}) {
190191
return <a href={'#' + id} data-link={id} className={`${styles.colorLink} token hljs-name`}>{value.name}</a>;
191192
}
192193

194+
function renderHTMLfromMarkdown(description) {
195+
if (description) {
196+
return <Markdown>{description}</Markdown>;
197+
} else {
198+
return '';
199+
}
200+
}
201+
193202
export function InterfaceType({properties, showRequired, showDefault}) {
194203
return (
195204
<table className={`${tableStyles['spectrum-Table']} ${tableStyles['spectrum-Table--quiet']} ${styles.propTable}`}>
@@ -209,7 +218,7 @@ export function InterfaceType({properties, showRequired, showDefault}) {
209218
<span className="token hljs-attr">{prop.name}</span>
210219
</code>
211220
{!prop.optional && showRequired
212-
? <Asterisk size="XXS" UNSAFE_className={styles.requiredIcon} alt="Required" />
221+
? <Asterisk size="XXS" UNSAFE_className={styles.requiredIcon} alt="Required" />
213222
: null
214223
}
215224
</td>
@@ -226,7 +235,7 @@ export function InterfaceType({properties, showRequired, showDefault}) {
226235
}
227236
</td>
228237
}
229-
<td className={tableStyles['spectrum-Table-cell']}>{prop.description}</td>
238+
<td className={tableStyles['spectrum-Table-cell']}>{renderHTMLfromMarkdown(prop.description)}</td>
230239
</tr>
231240
))}
232241
</tbody>

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13306,6 +13306,14 @@ markdown-escapes@^1.0.0:
1330613306
resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535"
1330713307
integrity sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==
1330813308

13309+
markdown-to-jsx@^6.11.0:
13310+
version "6.11.0"
13311+
resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-6.11.0.tgz#a2e3f2bc781c3402d8bb0f8e0a12a186474623b0"
13312+
integrity sha512-RH7LCJQ4RFmPqVeZEesKaO1biRzB/k4utoofmTCp3Eiw6D7qfvK8fzZq/2bjEJAtVkfPrM5SMt5APGf2rnaKMg==
13313+
dependencies:
13314+
prop-types "^15.6.2"
13315+
unquote "^1.1.0"
13316+
1330913317
markdown-to-jsx@^6.9.1, markdown-to-jsx@^6.9.3:
1331013318
version "6.10.3"
1331113319
resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-6.10.3.tgz#7f0946684acd321125ff2de7fd258a9b9c7c40b7"

0 commit comments

Comments
 (0)