Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 6d49890

Browse files
author
Dom Harrington
committed
Get markdown rendering in blocks
1 parent fab9103 commit 6d49890

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

packages/api-explorer-ui/lib/create-docs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = (oas, apiSetting) => {
3232
body: `
3333
[block:textarea]
3434
{
35-
"text": "This is text area"
35+
"text": "# This is text area"
3636
}
3737
[/block]
3838
[block:html]
@@ -82,7 +82,7 @@ module.exports = (oas, apiSetting) => {
8282
1136,
8383
"#9e918d"
8484
],
85-
"caption": "doggo"
85+
"caption": "*doggo*"
8686
}
8787
]
8888
}
@@ -108,7 +108,7 @@ module.exports = (oas, apiSetting) => {
108108
[block:parameters]
109109
{
110110
"data": {
111-
"0-0": "arbitrary",
111+
"0-0": "*arbitrary*",
112112
"0-1": "info",
113113
"0-2": "test",
114114
"h-0": "test",

packages/api-explorer-ui/src/block-types/Image.jsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const React = require('react');
22
const PropTypes = require('prop-types');
3-
// const Marked = require('../lib/marked');
3+
const markdown = require('../lib/markdown');
44

55
const ImageBlock = ({ block }) => {
66
const myImage = block.data.images.map((image, i) => {
@@ -23,14 +23,8 @@ const ImageBlock = ({ block }) => {
2323
</a>
2424
</figure>
2525
{image.caption && (
26-
<figcaption>
27-
<p>
28-
{
29-
// TODO add marked
30-
image.caption
31-
}
32-
</p>
33-
</figcaption>
26+
// eslint-disable-next-line react/no-danger
27+
<figcaption dangerouslySetInnerHTML={{ __html: markdown(image.caption) }} />
3428
)}
3529
</div>
3630
)}

packages/api-explorer-ui/src/block-types/Parameters.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const React = require('react');
22
const PropTypes = require('prop-types');
3-
// import Marked from '../lib/marked';
3+
const markdown = require('../lib/markdown');
44

55
const Parameters = ({ block }) => {
66
const columns = block.data.cols;
@@ -23,10 +23,8 @@ const Parameters = ({ block }) => {
2323

2424
for (let c = 0; c < columns; c += 1) {
2525
tdCells.push(
26-
<div className="td" key={c}>
27-
{// TODO add marked
28-
block.data.data[`${r}-${c}`] || ''}
29-
</div>,
26+
// eslint-disable-next-line react/no-danger
27+
<div className="td" key={c} dangerouslySetInnerHTML={{ __html: markdown(block.data.data[`${r}-${c}`] || '') }} />
3028
);
3129
}
3230
return tdCells;

packages/api-explorer-ui/src/block-types/TextArea.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
// import Marked from '../lib/marked';
21
const React = require('react');
32
const PropTypes = require('prop-types');
3+
const markdown = require('../lib/markdown');
44

55
const Textarea = ({ block }) => {
66
return (
7-
<div className="magic-block-textarea">
8-
{
9-
// TODO add marked
10-
block.text
11-
}
12-
</div>
7+
// eslint-disable-next-line react/no-danger
8+
<div className="magic-block-textarea" dangerouslySetInnerHTML={{ __html: markdown(block.text) }} />
139
);
1410
};
1511

0 commit comments

Comments
 (0)