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

Commit

Permalink
Get markdown rendering in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed Sep 13, 2017
1 parent fab9103 commit 6d49890
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
6 changes: 3 additions & 3 deletions packages/api-explorer-ui/lib/create-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = (oas, apiSetting) => {
body: `
[block:textarea]
{
"text": "This is text area"
"text": "# This is text area"
}
[/block]
[block:html]
Expand Down Expand Up @@ -82,7 +82,7 @@ module.exports = (oas, apiSetting) => {
1136,
"#9e918d"
],
"caption": "doggo"
"caption": "*doggo*"
}
]
}
Expand All @@ -108,7 +108,7 @@ module.exports = (oas, apiSetting) => {
[block:parameters]
{
"data": {
"0-0": "arbitrary",
"0-0": "*arbitrary*",
"0-1": "info",
"0-2": "test",
"h-0": "test",
Expand Down
12 changes: 3 additions & 9 deletions packages/api-explorer-ui/src/block-types/Image.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const React = require('react');
const PropTypes = require('prop-types');
// const Marked = require('../lib/marked');
const markdown = require('../lib/markdown');

const ImageBlock = ({ block }) => {
const myImage = block.data.images.map((image, i) => {
Expand All @@ -23,14 +23,8 @@ const ImageBlock = ({ block }) => {
</a>
</figure>
{image.caption && (
<figcaption>
<p>
{
// TODO add marked
image.caption
}
</p>
</figcaption>
// eslint-disable-next-line react/no-danger
<figcaption dangerouslySetInnerHTML={{ __html: markdown(image.caption) }} />
)}
</div>
)}
Expand Down
8 changes: 3 additions & 5 deletions packages/api-explorer-ui/src/block-types/Parameters.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const React = require('react');
const PropTypes = require('prop-types');
// import Marked from '../lib/marked';
const markdown = require('../lib/markdown');

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

for (let c = 0; c < columns; c += 1) {
tdCells.push(
<div className="td" key={c}>
{// TODO add marked
block.data.data[`${r}-${c}`] || ''}
</div>,
// eslint-disable-next-line react/no-danger
<div className="td" key={c} dangerouslySetInnerHTML={{ __html: markdown(block.data.data[`${r}-${c}`] || '') }} />
);
}
return tdCells;
Expand Down
10 changes: 3 additions & 7 deletions packages/api-explorer-ui/src/block-types/TextArea.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// import Marked from '../lib/marked';
const React = require('react');
const PropTypes = require('prop-types');
const markdown = require('../lib/markdown');

const Textarea = ({ block }) => {
return (
<div className="magic-block-textarea">
{
// TODO add marked
block.text
}
</div>
// eslint-disable-next-line react/no-danger
<div className="magic-block-textarea" dangerouslySetInnerHTML={{ __html: markdown(block.text) }} />
);
};

Expand Down

0 comments on commit 6d49890

Please sign in to comment.