Skip to content

Commit 73bc50e

Browse files
committed
fix: add syntax highlighted markdown
1 parent 141b6d5 commit 73bc50e

File tree

10 files changed

+235
-13
lines changed

10 files changed

+235
-13
lines changed

jest.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module.exports = {
77
"testEnvironment": "jsdom",
88
"testPathIgnorePatterns": ["./build"],
99
"preset": "ts-jest",
10+
"transformIgnorePatterns": ['^.+\\.js$'],
1011
"moduleNameMapper": {
11-
"\\.(css|less|sass|scss)$": "jest-transform-css"
12-
}
13-
}
12+
"\\.(css|less|sass|scss)$": "jest-transform-css",
13+
},
14+
};

package-lock.json

Lines changed: 166 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@material-ui/lab": "4.0.0-alpha.47",
1717
"@material-ui/styles": "^4.7.1",
1818
"@open-rpc/examples": "^1.6.1",
19+
"@types/react-syntax-highlighter": "^13.5.0",
1920
"@xops.net/json-schema-to-react-tree": "^1.0.2",
2021
"hash-color-material": "^1.1.3",
2122
"jest-transform-css": "^2.0.0",
@@ -24,7 +25,8 @@
2425
"react": "^16.12.0",
2526
"react-dom": "^16.12.0",
2627
"react-json-view": "^1.19.1",
27-
"react-markdown": "^4.0.6"
28+
"react-markdown": "^4.0.6",
29+
"react-syntax-highlighter": "^15.3.0"
2830
},
2931
"devDependencies": {
3032
"@open-rpc/meta-schema": "^1.11.0",

src/ContentDescriptor/ContentDescriptor.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ReactMarkdown from "react-markdown";
99
import JSONSchemaTree from "@xops.net/json-schema-to-react-tree";
1010
import { ContentDescriptorObject } from "@open-rpc/meta-schema";
1111
import "./ContentDescriptor.css";
12+
import MarkdownDescription from "../MarkdownDescription/MarkdownDescription";
1213

1314
const styles = (theme: Theme) => ({
1415
description: {
@@ -60,7 +61,11 @@ class ContentDescriptor extends Component<IProps> {
6061
<ExpansionPanelDetails style={{ display: "block", overflowX: "auto" }}>
6162
<>
6263
{contentDescriptor.description &&
63-
<ReactMarkdown source={contentDescriptor.description} className={classes.description} />
64+
<MarkdownDescription
65+
uiSchema={uiSchema}
66+
source={contentDescriptor.description}
67+
className={classes.description}
68+
/>
6469
}
6570
{contentDescriptor.schema &&
6671
<>

src/ExamplePairing/ExamplePairing.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import ReactJson from "react-json-view";
55
import ReactMarkdown from "react-markdown";
66
import { ExampleObject, ExamplePairingObject } from "@open-rpc/meta-schema";
77
import _ from "lodash";
8+
import MarkdownDescription from "../MarkdownDescription/MarkdownDescription";
89

910
export type TParamStructure = "either" | "by-name" | "by-position";
1011

1112
interface IProps extends WithStyles<typeof styles> {
1213
examplePairing?: ExamplePairingObject;
1314
paramStructure?: TParamStructure;
1415
methodName?: string;
16+
uiSchema?: any;
1517
reactJsonOptions?: any;
1618
}
1719

@@ -23,7 +25,7 @@ const styles = (theme: Theme) => ({
2325

2426
class ExamplePairing extends Component<IProps, {}> {
2527
public render() {
26-
const { examplePairing, paramStructure, classes, methodName } = this.props;
28+
const { examplePairing, paramStructure, classes, methodName, uiSchema } = this.props;
2729
if (_.isUndefined(examplePairing)) {
2830
return null;
2931
}
@@ -40,7 +42,11 @@ class ExamplePairing extends Component<IProps, {}> {
4042
return (
4143
<Grid container spacing={10}>
4244
<Grid item xs={12}>
43-
<ReactMarkdown source={examplePairing.description} className={classes.description} />
45+
<MarkdownDescription
46+
uiSchema={uiSchema}
47+
source={examplePairing.description}
48+
className={classes.description}
49+
/>
4450
</Grid>
4551
<Grid item xs={6}>
4652
<Card>

0 commit comments

Comments
 (0)